Home Manager: Difference between revisions

Euxane (talk | contribs)
m Fix syntax highlight for some nix code snippets
Rrdpad (talk | contribs)
fix home manager module and add home manager config
Line 63: Line 63:
     };
     };
   };
   };
   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 {
          ./configuration.nix
          nix.registry.nixos.flake = inputs.self;
          home-manager.nixosModules.home-manager
          home-manager.useGlobalPkgs = true;
          {
          home-manager.useUserPackages = true;
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.users.your-username = import ./home.nix;
         };
         };
        # Anything else you need to import, for example
        ./Devices/ExampleMachine.nix
       ];
       ];
     };
     };
Line 80: Line 80:
</syntaxhighlight>
</syntaxhighlight>
        
        
From there, in your configuration simply needs to make use of Home Manager.  
Here's an example of home manager configuration in ./home.nix
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
{ config, pkgs, ... }:
{
{
   home-manager.users.exampleuser = {
  # Home Manager needs a bit of information about you and the
    home.stateVersion = "24.04";
  # paths it should manage.
   };
  home.username = "your-username";
   home.homeDirectory = "/home/your-username";
 
  # 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.05";
 
   # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;
}
}
</syntaxhighlight>
</syntaxhighlight>