Home Manager: Difference between revisions
m Fix syntax highlight for some nix code snippets |
Removed options that are not only not needed for HM as system module, but might be harmful when used (wrong) |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 53: | Line 53: | ||
=== 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 [[Flakes|flake]]: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
{ | { | ||
inputs = { | inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24. | nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; | ||
home-manager = { | home-manager = { | ||
url = "github:nix-community/home-manager/release-24. | url = "github:nix-community/home-manager/release-24.11"; | ||
inputs.nixpkgs.follows = "nixpkgs" | inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | }; | ||
}; | }; | ||
outputs = { self, nixpkgs, home-manager }@inputs: | outputs = { self, nixpkgs, home-manager, ... }@inputs: | ||
nixosConfigurations. | nixosConfigurations.exampleMachine = nixosConfiguration "exampleMachine" | ||
system = "x86_64-linux"; | system = "x86_64-linux"; | ||
modules = [ | modules = [ | ||
home-manager. | ./configuration.nix | ||
home-manager.nixosModules.home-manager | |||
{ | |||
home-manager.useGlobalPkgs = true; | home-manager.useGlobalPkgs = true; | ||
home-manager.useUserPackages = true; | home-manager.useUserPackages = true; | ||
home-manager.users.your-username = import ./home.nix; | |||
} | |||
]; | ]; | ||
}; | }; | ||
Line 80: | Line 80: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Here's an example of home manager configuration in ./home.nix | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
{ config, pkgs, ... }: | |||
{ | { | ||
# This value determines the Home Manager release that your | |||
# configuration is compatible with. This helps avoid breakage | |||
# when a new Home Manager release introduces backwards | |||
# incompatible changes. | |||
# | |||
# You can update Home Manager without changing this value. See | |||
# the Home Manager release notes for a list of state version | |||
# changes in each release. | |||
home.stateVersion = "24.11"; | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |