fork/home-manager
git clone https://git.julia.blue/fork/home-manager
ca4126e3
master
1# This module is the common base for the NixOS and nix-darwin modules. 2# For OS-specific configuration, please edit nixos/default.nix or nix-darwin/default.nix instead. 3 4{ config , lib , pkgs , ...} : 5 6with lib ; 7 8let 9 10cfg = config . home-manager ; 11 12extendedLib = import ../modules/lib/stdlib-extended.nix lib ; 13 14hmModule = types . submoduleWith { 15description = "Home Manager module" ; 16specialArgs = { 17lib = extendedLib ; 18osConfig = config ; 19modulesPath = builtins . toString ../modules ; 20} // cfg . extraSpecialArgs ; 21modules = [ 22({ name , ...} :{ 23imports = import ../modules/modules.nix { 24inherit pkgs ; 25lib = extendedLib ; 26useNixpkgsModule = ! cfg . useGlobalPkgs ; 27}; 28 29config = { 30submoduleSupport . enable = true ; 31submoduleSupport . externalPackageInstall = cfg . useUserPackages ; 32 33home . username = config . users . users .${ name }. name ; 34home . homeDirectory = config . users . users .${ name }. home ; 35 36# Make activation script use same version of Nix as system as a whole. 37# This avoids problems with Nix not being in PATH. 38nix . package = config . nix . package ; 39}; 40}) 41] ++ cfg . sharedModules ; 42}; 43 44in { 45options . home-manager = { 46useUserPackages = mkEnableOption '' 47installation of user packages through the 48{option}`users.users.<name>.packages` option'' ; 49 50useGlobalPkgs = mkEnableOption '' 51using the system configuration's `pkgs` 52argument in Home Manager. This disables the Home Manager 53options {option}`nixpkgs.*`'' ; 54 55backupFileExtension = mkOption { 56type = types . nullOr types . str ; 57default = null ; 58example = "backup" ; 59description = '' 60On activation move existing files by appending the given 61file extension rather than exiting with an error. 62'' ; 63}; 64 65extraSpecialArgs = mkOption { 66type = types . attrs ; 67default = { }; 68example = literalExpression "{ inherit emacs-overlay; }" ; 69description = '' 70Extra `specialArgs` passed to Home Manager. This 71option can be used to pass additional arguments to all modules. 72'' ; 73}; 74 75sharedModules = mkOption { 76type = with types ; listOf raw ; 77default = [ ]; 78example = literalExpression "[ { home.packages = [ nixpkgs-fmt ]; } ]" ; 79description = '' 80Extra modules added to all users. 81'' ; 82}; 83 84verbose = mkEnableOption "verbose output on activation" ; 85 86users = mkOption { 87type = types . attrsOf hmModule ; 88default = { }; 89# Prevent the entire submodule being included in the documentation. 90visible = "shallow" ; 91description = '' 92Per-user Home Manager configuration. 93'' ; 94}; 95}; 96 97config = ( mkMerge [ 98# Fix potential recursion when configuring home-manager users based on values in users.users #594 99( mkIf ( cfg . useUserPackages && cfg . users != { }) { 100users . users = 101( mapAttrs ( username :usercfg :{ packages = [ usercfg . home . path ]; }) 102cfg . users ); 103environment . pathsToLink = [ "/etc/profile.d" ]; 104}) 105( mkIf ( cfg . users != { }) { 106warnings = flatten ( flip mapAttrsToList cfg . users ( user :config : 107flip map config . warnings ( warning :" ${ user } profile: ${ warning } " ))); 108 109assertions = flatten ( flip mapAttrsToList cfg . users ( user :config : 110flip map config . assertions ( assertion :{ 111inherit ( assertion ) assertion ; 112message = " ${ user } profile: ${ assertion . message } " ; 113}))); 114}) 115]); 116}