fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , name , extendModules , lib , ...} : 2 3with lib ; 4 5{ 6imports = 7[ ( mkRenamedOptionModule [ "specialization" ] [ "specialisation" ]) ]; 8 9options . specialisation = mkOption { 10type = types . attrsOf ( types . submodule { 11options = { 12configuration = mkOption { 13type = let 14extended = extendModules { 15modules = [{ 16# Prevent infinite recursion 17specialisation = mkOverride 0 { }; 18 19# If used inside the NixOS/nix-darwin module, we get conflicting definitions 20# of `name` inside the specialisation: one is the user name coming from the 21# NixOS module definition and the other is `configuration`, the name of this 22# option. Thus we need to explicitly wire the former into the module arguments. 23# See discussion at https://github.com/nix-community/home-manager/issues/3716 24_module . args . name = mkForce name ; 25}]; 26}; 27in extended . type ; 28default = { }; 29visible = "shallow" ; 30description = '' 31Arbitrary Home Manager configuration settings. 32'' ; 33}; 34}; 35}); 36default = { }; 37description = '' 38A set of named specialized configurations. These can be used to extend 39your base configuration with additional settings. For example, you can 40have specialisations named "light" and "dark" 41that apply light and dark color theme configurations. 42 43::: {.note} 44This is an experimental option for now and you therefore have to 45activate the specialisation by looking up and running the activation 46script yourself. Running the activation script will create a new 47Home Manager generation. 48::: 49 50For example, to activate the "dark" specialisation, you can 51first look up your current Home Manager generation by running 52 53```console 54$ home-manager generations | head -1 552022-05-02 22:49 : id 1758 -> /nix/store/jy…ac-home-manager-generation 56``` 57 58then run 59 60```console 61$ /nix/store/jy…ac-home-manager-generation/specialisation/dark/activate 62Starting Home Manager activation 63… 64``` 65 66::: {.warning} 67Since this option is experimental, the activation process may 68change in backwards incompatible ways. 69::: 70'' ; 71}; 72 73config = mkIf ( config . specialisation != { }) { 74home . extraBuilderCommands = let 75link = n :v : 76let pkg = v . configuration . home . activationPackage ; 77in "ln -s ${ pkg } $out/specialisation/ ${ n } " ; 78in '' 79mkdir $out/specialisation 80${ concatStringsSep "\n" ( mapAttrsToList link config . specialisation )} 81'' ; 82}; 83}