From f0a93f878b3820a0dfab3ab3100c9b0306d6ae3a Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 30 Mar 2023 09:58:46 +0000 Subject: [PATCH] home: nix: add 'NIX_PATH' handling Still waiting for the actual home-manager module option to be added [1]. In the meantime, just do it by hand. [1]: https://github.com/nix-community/home-manager/pull/2677 --- home/nix/default.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/home/nix/default.nix b/home/nix/default.nix index c46e990..d8618e5 100644 --- a/home/nix/default.nix +++ b/home/nix/default.nix @@ -26,10 +26,24 @@ in addToRegistry = my.mkDisableOption "add inputs and self to registry"; + addToNixPath = my.mkDisableOption "add inputs and self to nix path"; + overrideNixpkgs = my.mkDisableOption "point nixpkgs to pinned system version"; }; config = lib.mkIf cfg.enable (lib.mkMerge [ + { + assertions = [ + { + assertion = cfg.addToNixPath -> cfg.linkInputs; + message = '' + enabling `my.home.nix.addToNixPath` needs to have + `my.home.nix.linkInputs = true` + ''; + } + ]; + } + { nix = { package = lib.mkDefault pkgs.nix; # NixOS module sets it unconditionally @@ -60,5 +74,9 @@ in in makeLinks channels; }) + + (lib.mkIf cfg.addToNixPath { + home.sessionVariables.NIX_PATH = "${config.xdg.configHome}/nix/inputs\${NIX_PATH:+:$NIX_PATH}"; + }) ]); }