diff options
Diffstat (limited to 'templates')
| -rw-r--r-- | templates/nixos/modules/basic.nix | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/templates/nixos/modules/basic.nix b/templates/nixos/modules/basic.nix index f1f7a81..fb67701 100644 --- a/templates/nixos/modules/basic.nix +++ b/templates/nixos/modules/basic.nix @@ -5,7 +5,7 @@ ... }: let inherit (builtins) attrNames map; - inherit (lib) filterAttrs mapAttrs mkDefault mkEnableOption mkIf mkOption types; + inherit (lib) filterAttrs mapAttrs mkDefault mkEnableOption mkIf mkOption optionals types; cfg = config.getchoo.basicConfig; mapInputs = fn: map fn (attrNames inputs); @@ -14,7 +14,7 @@ in { enable = mkEnableOption "getchoo's basic config" // {default = true;}; channelPath = { enable = - mkEnableOption "enable channels" + mkEnableOption "enable channel path management" // {default = true;}; dirname = mkOption { type = types.str; @@ -25,25 +25,27 @@ in { }; config = mkIf cfg.enable { - nix = { - gc = { - automatic = mkDefault true; - options = mkDefault "-d --delete-older-than 2d"; - }; - - nixPath = mapInputs (i: "${i}=${cfg.channelPath.dirname i}"); + nix = + { + gc = { + automatic = mkDefault true; + options = mkDefault "-d --delete-older-than 2d"; + }; - registry = - {n.flake = inputs.nixpkgs;} - // (mapAttrs (_: flake: {inherit flake;}) - (filterAttrs (n: _: n != "nixpkgs") inputs)); + registry = + {n.flake = inputs.nixpkgs;} + // (mapAttrs (_: flake: {inherit flake;}) + (filterAttrs (n: _: n != "nixpkgs") inputs)); - settings = { - auto-optimise-store = true; - experimental-features = ["nix-command" "flakes" "auto-allocate-uids" "repl-flake"]; + settings = { + auto-optimise-store = true; + experimental-features = ["nix-command" "flakes" "auto-allocate-uids" "repl-flake"]; + }; + } + // mkIf cfg.channelPath.enable { + nixPath = mapInputs (i: "${i}=${cfg.channelPath.dirname}/${i}"); }; - }; - systemd.tmpfiles.rules = mapInputs (i: "L+ ${cfg.channelPath i} - - - - ${inputs.${i}.outPath}"); + systemd.tmpfiles.rules = optionals cfg.channelPath.enable (mapInputs (i: "L+ ${cfg.channelPath.dirname}/${i} - - - - ${inputs.${i}.outPath}")); }; } |
