• Shareni@programming.devOP
    link
    fedilink
    arrow-up
    3
    arrow-down
    1
    ·
    7 months ago

    It’s pretty easy for home-manager use, but still really useful. You can:

    • choose which packages to install from stable and which from unstable
    • add packages from repos that have flake.nix in them
    • correctly match nix and home-manager versions, and always update them at the same time
    • allow-unfree without nixpkgs conf, so 1 less directory required in .config (if they accepted the “experimental” features it’d be down to 1)

    Here’s an example:

    flake.nix
    {
      description = "home flake";
    
      inputs = {
        nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
        home-manager.url = "github:nix-community/home-manager/master";
        home-manager.inputs.nixpkgs.follows = "nixpkgs";
        nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-23.11";
    
        # nixgl.url = "github:guibou/nixGL";
      };
    
      outputs =
        {
          self,
          nixpkgs,
          nixpkgs-stable,
          home-manager,
          # nixgl,
          ...
        }@inputs:
        let
          system = "x86_64-linux";
          pkgs = import nixpkgs {
            system = system;
            config = {
              allowUnfree = true;
            };
          };
          pkgsStable = import nixpkgs-stable {
            system = system;
            config = {
              allowUnfree = true;
            };
          };
        in
        {
          homeConfigurations = {
            shareni = home-manager.lib.homeManagerConfiguration {
              inherit pkgs;
              modules = [ ./home.nix ];
              extraSpecialArgs = {
                inherit inputs;
                inherit system;
    
                kmonad = pkgsStable.kmonad;
              };
            };
          };
        };
    }
    
    • PuddleOfKittens@kbin.social
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      edit-2
      7 months ago

      The ‘code’ tag here does not respect newlines, I tried to fix it but this is the best I could do:

      `{ description = “home flake”;

       inputs = {     nixpkgs.url = “github:nixos/nixpkgs/nixos-unstable”;
      
       home-manager.url = “github:nix-community/home-manager/master”;
      
       home-manager.inputs.nixpkgs.follows = “nixpkgs”;
      
       nixpkgs-stable.url = “github:nixos/nixpkgs/nixos-23.11;
      
        # nixgl.url = “github:guibou/nixGL”;
      
      

      };

      outputs =     {
      
         self,
      
         nixpkgs,
      
         nixpkgs-stable,
      
         home-manager,
      
         # nixgl,
      
         …
      
       }
      
      

      @inputs:

       let
      
         system = “x86_64-linux”;
      
         pkgs = import nixpkgs {
      
           system = system;
      
           config = {
      
             allowUnfree = true;
      
           };
      
         };
      
         pkgsStable = import nixpkgs-stable {
      
           system = system;
      
           config = {
      
             allowUnfree = true;
      
           };
      
         };
      
       in     {
      
         homeConfigurations = {
      
           shareni = home-manager.lib.homeManagerConfiguration {
      
             inherit pkgs;
      
             modules = [ ./home.nix ];
      
             extraSpecialArgs = {
      
               inherit inputs;
      
               inherit system;
      
                kmonad = pkgsStable.kmonad;
      
             };
      
           };
      
         };
      
       };
      
      

      }`