From ddeeb031fdf9b82e7a964bbe8a2df84c4546c2a1 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 19 Jul 2021 23:07:02 +0200 Subject: [PATCH] nixos: add nix package to activation script path Fixes #2178 --- modules/home-environment.nix | 30 +++++++++++++++++++++--------- nixos/default.nix | 4 ++++ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 872fcd8f..ee9c3bd2 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -373,6 +373,16 @@ in description = "The package containing the complete activation script."; }; + home.extraActivationPath = mkOption { + internal = true; + type = types.listOf types.package; + default = [ ]; + description = '' + Extra packages to add to PATH within the activation + script. + ''; + }; + home.extraBuilderCommands = mkOption { type = types.lines; default = ""; @@ -570,15 +580,17 @@ in # Programs that always should be available on the activation # script's PATH. - activationBinPaths = lib.makeBinPath [ - pkgs.bash - pkgs.coreutils - pkgs.diffutils # For `cmp` and `diff`. - pkgs.findutils - pkgs.gnugrep - pkgs.gnused - pkgs.ncurses # For `tput`. - ] + activationBinPaths = lib.makeBinPath ( + [ + pkgs.bash + pkgs.coreutils + pkgs.diffutils # For `cmp` and `diff`. + pkgs.findutils + pkgs.gnugrep + pkgs.gnused + pkgs.ncurses # For `tput`. + ] ++ config.home.extraActivationPath + ) + optionalString (!cfg.emptyActivationPath) "\${PATH:+:}$PATH"; activationScript = pkgs.writeShellScript "activation-script" '' diff --git a/nixos/default.nix b/nixos/default.nix index fec59c62..b5d02257 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -32,6 +32,10 @@ let home.username = config.users.users.${name}.name; home.homeDirectory = config.users.users.${name}.home; + + # Make activation script use same version of Nix as system as a whole. + # This avoids problems with Nix not being in PATH. + home.extraActivationPath = [ config.nix.package ]; }; }) ] ++ cfg.sharedModules;