You’re doing a couple of pretty crazy things there, I’m not surprised it’s borked.
Firstly, that wrapper script is inadvisable. home-manager explicitly supports changing the pkgs
arg, you should be doing this:
# home.nix
let
sources = import ./npins;
pkgs = import sources.nixpkgs {};
in
{
_module.args = {
inherit pkgs;
};
}
Secondly, using the activation script to remove a binary from $PATH
isn’t very clean. It means that that deletion happens after nix finishes evaluating, as part of a big bash script. It’s unfortunate when you have to rely on this, because it means that home-manager cannot abort before the switch if you’ve made a mistake, and you potentially end up with a partial activation (consider this foreshadowing).
It’d be better to build a custom nix package with buildEnv
or symlinkJoin
and remove the nix-channel
in the postBuild
script of that, then set nix.package
to that.
Consider your error message:
line 340: out: unbound variable
This snippet is almost certainly also the source of the different behavior you see. Presumably $out
isn’t set in the activation environment of whatever version of home-manager you’re using. I believe it should not be set in fact, I’m curious which versions of home-manager would have it in there - it seems like a bug that your configuration doesn’t always fail.
Perhaps it does always fail and the fact that there is no change between generations just means the activation script isn’t run every other time? Or maybe using nix-shell
ends up with a spuriously set $out
, which results in a silently ignored failure to delete a file. You could confirm the latter by running echo $out
in your nix-shell, or by using unset $out
before running home-manager
in there.
And finally, nix.nixPath does exist - you link to it yourself in that comment. Presumably you’re using an ancient home-manager module set since you haven’t been able to update since trying to delete nix-channel
. Even if it didn’t, nix.settings.nix-path
is likely nicer.