From 6eb87c21b7be926d7a09a3fa582fc0919b57339d Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 23 Feb 2023 21:00:30 +0000 Subject: [PATCH] modules: system: nix: use stable 'NIX_PATH' Since the links are updated on system switch, NIX_PATH will automatically point to the actual system version of the inputs at all times --- modules/system/nix/default.nix | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/modules/system/nix/default.nix b/modules/system/nix/default.nix index bae6e6f..463c0f5 100644 --- a/modules/system/nix/default.nix +++ b/modules/system/nix/default.nix @@ -17,6 +17,18 @@ in }; config = lib.mkIf cfg.enable (lib.mkMerge [ + { + assertions = [ + { + assertion = cfg.addToNixPath -> cfg.linkInputs; + message = '' + enabling `my.system.nix.addToNixPath` needs to have + `my.system.nix.linkInputs = true` + ''; + } + ]; + } + { nix = { package = pkgs.nix; @@ -60,11 +72,11 @@ in (lib.mkIf cfg.addToNixPath { nix.nixPath = [ - "self=${inputs.self}" - "pkgs=${inputs.nixpkgs}" - "nur=${inputs.nur}" + "self=/etc/nix/inputs/self" + "pkgs=/etc/nix/inputs/nixpkgs" + "nur=/etc/nix/inputs/nur" ] - ++ lib.optional cfg.overrideNixpkgs "nixpkgs=${inputs.nixpkgs}" + ++ lib.optional cfg.overrideNixpkgs "nixpkgs=/etc/nix/inputs/nixpkgs" ++ options.nix.nixPath.default; }) ]);