Home Manager: Difference between revisions
m Remove accidental 11 at the end of the sentence. |
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 = { | |||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; | |||
home-manager = { | |||
url = "github:nix-community/home-manager/release-24.05"; | |||
inputs.nixpkgs.follows = "nixpkgs" | |||
}; | |||
}; | |||
outputs = { self, nixpkgs, home-manager }@inputs: | |||
nixosConfigurations.ExampleMachine = nixosConfiguration "ExmapleMachine" | |||
system = "x86_64-linux"; | |||
modules = [ | |||
home-manager.nixosmodules.home-manager { | |||
nix.registry.nixos.flake = inputs.self; | |||
home-manager.useGlobalPkgs = true; | |||
home-manager.useUserPackages = true; | |||
}; | |||
# Anything else you need to import, for example | |||
./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"; | |||
}; | |||
} | |||
</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. | ||