Home Manager: Difference between revisions

Krutonium (talk | contribs)
m Remove accidental 11 at the end of the sentence.
Euxane (talk | contribs)
m Fix syntax highlight for some nix code snippets
Line 54: Line 54:
=== Usage as a NixOS module in a Flake ===
=== Usage as a NixOS module in a Flake ===
Here is the skeleton of how to add Home Manager as a module to your system(s) via your flake:
Here is the skeleton of how to add Home Manager as a module to your system(s) via your flake:
{
<syntaxhighlight lang="nix">
{
  inputs = {
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
    home-manager = {
    home-manager = {
      url = "github:nix-community/home-manager/release-24.05";
      url = "github:nix-community/home-manager/release-24.05";
      inputs.nixpkgs.follows = "nixpkgs"
      inputs.nixpkgs.follows = "nixpkgs"
    };
    };
  };
  };
  outputs = { self, nixpkgs, home-manager }@inputs:
  outputs = { self, nixpkgs, home-manager }@inputs:
    nixosConfigurations.ExampleMachine = nixosConfiguration "ExmapleMachine"
    nixosConfigurations.ExampleMachine = nixosConfiguration "ExmapleMachine"
      system = "x86_64-linux";
      system = "x86_64-linux";
      modules = [
      modules = [
        home-manager.nixosmodules.home-manager {
        home-manager.nixosmodules.home-manager {
          nix.registry.nixos.flake = inputs.self;
          nix.registry.nixos.flake = inputs.self;
          home-manager.useGlobalPkgs = true;
          home-manager.useGlobalPkgs = true;
          home-manager.useUserPackages = true;
          home-manager.useUserPackages = true;
        };
        };
        # Anything else you need to import, for example  
        # Anything else you need to import, for example  
        ./Devices/ExampleMachine.nix
        ./Devices/ExampleMachine.nix
      ];
      ];
    };
    };
  };
  };
}
}
</syntaxhighlight>
        
        
From there, in your configuration simply needs to make use of Home Manager.  
From there, in your configuration simply needs to make use of Home Manager.  
{
<syntaxhighlight lang="nix">
  home-manager.users.exampleuser = {
{
    home.stateVersion = "24.04";
  home-manager.users.exampleuser = {
  };
    home.stateVersion = "24.04";
}
  };
}
</syntaxhighlight>
 
Of course you'll probably want to keep more stuff in there than just a state version, but the state version is required.
Of course you'll probably want to keep more stuff in there than just a state version, but the state version is required.