From 4f44e0dd130dd47defd143d5fdff98705db335f0 Mon Sep 17 00:00:00 2001 From: Timothy DeHerrera Date: Wed, 17 Feb 2021 12:54:41 -0700 Subject: [PATCH] nix: patch nix directly for experimental features The bash wrapper was causing issues with deploy-rs and the experimental-features option in the config was causing hercules-ci to spit out a bunch of junk in the logs. Patching nix with the default values required for flakes fixes both of these issues. --- overlays/nixFlakes.nix | 8 ++++++ ...01-nix-command-and-flakes-by-default.patch | 28 +++++++++++++++++++ profiles/core/default.nix | 2 +- shell/default.nix | 18 ++++++------ shell/devshell.toml | 3 ++ 5 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 overlays/nixFlakes.nix create mode 100644 pkgs/tools/package-management/nix/0001-nix-command-and-flakes-by-default.patch diff --git a/overlays/nixFlakes.nix b/overlays/nixFlakes.nix new file mode 100644 index 0000000..f557f0c --- /dev/null +++ b/overlays/nixFlakes.nix @@ -0,0 +1,8 @@ +final: prev: { + nixFlakes = prev.nixFlakes.overrideAttrs + (self: { + patches = [ + ../pkgs/tools/package-management/nix/0001-nix-command-and-flakes-by-default.patch + ]; + }); +} diff --git a/pkgs/tools/package-management/nix/0001-nix-command-and-flakes-by-default.patch b/pkgs/tools/package-management/nix/0001-nix-command-and-flakes-by-default.patch new file mode 100644 index 0000000..e22793a --- /dev/null +++ b/pkgs/tools/package-management/nix/0001-nix-command-and-flakes-by-default.patch @@ -0,0 +1,28 @@ +From a47bbae869ff35095eb2fe4d4d5145054ea81049 Mon Sep 17 00:00:00 2001 +From: Timothy DeHerrera +Date: Wed, 17 Feb 2021 12:26:48 -0700 +Subject: [PATCH] nix-command and flakes by default + +--- + src/libstore/globals.hh | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh +index eabd83e3f..e851e2a79 100644 +--- a/src/libstore/globals.hh ++++ b/src/libstore/globals.hh +@@ -889,7 +889,10 @@ public: + value. + )"}; + +- Setting experimentalFeatures{this, {}, "experimental-features", ++ Setting experimentalFeatures{ ++ this, ++ {"nix-command", "flakes", "ca-references"}, ++ "experimental-features", + "Experimental Nix features to enable."}; + + bool isExperimentalFeatureEnabled(const std::string & name); +-- +2.28.0 + diff --git a/profiles/core/default.nix b/profiles/core/default.nix index b78d713..9c091fe 100644 --- a/profiles/core/default.nix +++ b/profiles/core/default.nix @@ -138,10 +138,10 @@ in trustedUsers = [ "root" "@wheel" ]; extraOptions = '' - experimental-features = nix-command flakes ca-references min-free = 536870912 keep-outputs = true keep-derivations = true + fallback = true ''; }; diff --git a/shell/default.nix b/shell/default.nix index 8fa5014..5273627 100644 --- a/shell/default.nix +++ b/shell/default.nix @@ -22,7 +22,7 @@ pkgs.devshell.mkShell nixos-install nixos-generate-config nixos-enter - ] ++ lib.optional (system == "x86_64-linux") pkgs.deploy-rs; + ]; git.hooks = { pre-commit.text = lib.fileContents ./pre-commit.sh; @@ -32,13 +32,11 @@ pkgs.devshell.mkShell { package = flk; } - { - name = "nix"; - help = nixFlakes.meta.description; - command = '' - ${nixFlakes}/bin/nix --option experimental-features \ - "nix-command flakes ca-references" "$@" - ''; - } - ] ++ lib.optional (system != "i686-linux") { package = cachix; }; + ] + ++ lib.optional (system != "i686-linux") { package = cachix; } + ++ lib.optional (system == "x86_64-linux") { + name = "deploy"; + package = deploy-rs; + help = "A simple multi-profile Nix-flake deploy tool."; + }; } diff --git a/shell/devshell.toml b/shell/devshell.toml index f261fdc..1b86944 100644 --- a/shell/devshell.toml +++ b/shell/devshell.toml @@ -25,5 +25,8 @@ category = "documentation" package = "mdbook" category = "documentation" +[[commands]] +package = "nixFlakes" + [git.hooks] enable = true