diff options
Diffstat (limited to 'modules/shared/defaults/nix.nix')
| -rw-r--r-- | modules/shared/defaults/nix.nix | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/modules/shared/defaults/nix.nix b/modules/shared/defaults/nix.nix new file mode 100644 index 0000000..e5d7607 --- /dev/null +++ b/modules/shared/defaults/nix.nix @@ -0,0 +1,50 @@ +{ + config, + lib, + pkgs, + ... +}: +let + inherit (pkgs.stdenv.hostPlatform) isLinux; + + # TODO: remove this nonsense when all implementations remove repl-flake + hasReplFlake = + lib.versionOlder config.nix.package.version "2.22.0" # repl-flake was removed in nix 2.22.0 + || lib.versionAtLeast config.nix.package.version "2.90.0"; # but not in lix yet + + hasAlwaysAllowSubstitutes = lib.versionAtLeast config.nix.package.version "2.19.0"; +in +{ + config = lib.mkMerge [ + { + nix = { + settings = { + auto-optimise-store = lib.mkDefault isLinux; + experimental-features = [ + "nix-command" + "flakes" + "auto-allocate-uids" + ]; + + trusted-substituters = [ "https://getchoo.cachix.org" ]; + trusted-public-keys = [ "getchoo.cachix.org-1:ftdbAUJVNaFonM0obRGgR5+nUmdLMM+AOvDOSx0z5tE=" ]; + }; + + gc = { + automatic = lib.mkDefault true; + options = lib.mkDefault "--delete-older-than 2d"; + }; + }; + + nixpkgs.config.allowUnfree = lib.mkDefault true; + } + + (lib.mkIf hasReplFlake { + nix.settings.experimental-features = [ "repl-flake" ]; + }) + + (lib.mkIf hasAlwaysAllowSubstitutes { + nix.settings.always-allow-substitutes = true; + }) + ]; +} |
