summaryrefslogtreecommitdiff
path: root/modules/shared/base/nix.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/shared/base/nix.nix')
-rw-r--r--modules/shared/base/nix.nix66
1 files changed, 38 insertions, 28 deletions
diff --git a/modules/shared/base/nix.nix b/modules/shared/base/nix.nix
index a46d8cd..2ef91bf 100644
--- a/modules/shared/base/nix.nix
+++ b/modules/shared/base/nix.nix
@@ -7,6 +7,13 @@
let
inherit (pkgs.stdenv.hostPlatform) isLinux;
cfg = config.base.nixSettings;
+
+ # 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
{
options.base.nixSettings = {
@@ -20,41 +27,44 @@ in
};
};
- config = lib.mkIf cfg.enable {
- nix = {
- package = lib.mkIf cfg.lix.enable pkgs.lix;
-
- settings =
- {
- auto-optimise-store = isLinux;
- experimental-features =
- [
+ config = lib.mkIf cfg.enable (
+ lib.mkMerge [
+ {
+ nix = {
+ settings = {
+ auto-optimise-store = isLinux;
+ experimental-features = [
"nix-command"
"flakes"
"auto-allocate-uids"
- ]
- # TODO: remove this nonsense when all implementations remove repl-flake
- ++ lib.optional (
- 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
- ) "repl-flake";
+ ];
- trusted-substituters = [ "https://getchoo.cachix.org" ];
- trusted-public-keys = [ "getchoo.cachix.org-1:ftdbAUJVNaFonM0obRGgR5+nUmdLMM+AOvDOSx0z5tE=" ];
+ trusted-substituters = [ "https://getchoo.cachix.org" ];
+ trusted-public-keys = [ "getchoo.cachix.org-1:ftdbAUJVNaFonM0obRGgR5+nUmdLMM+AOvDOSx0z5tE=" ];
- nix-path = config.nix.nixPath;
- }
- // lib.mkIf (lib.versionAtLeast config.nix.package.version "2.19.0") {
- always-allow-substitutes = true;
+ nix-path = config.nix.nixPath;
+ };
+ gc = {
+ automatic = lib.mkDefault true;
+ options = lib.mkDefault "--delete-older-than 2d";
+ };
};
- gc = {
- automatic = lib.mkDefault true;
- options = lib.mkDefault "--delete-older-than 2d";
- };
- };
+ nixpkgs.config.allowUnfree = lib.mkDefault true;
+ }
- nixpkgs.config.allowUnfree = lib.mkDefault true;
- };
+ (lib.mkIf cfg.lix.enable {
+ nix.package = pkgs.lix;
+ })
+
+ (lib.mkIf hasReplFlake {
+ nix.settings.experimental-features = [ "repl-flake" ];
+ })
+
+ (lib.mkIf hasAlwaysAllowSubstitutes {
+ nix.settings.always-allow-substitutes = true;
+ })
+ ]
+ );
}