This is one way of managing your user profile declaratively.
Alternatives include:
- an attrset-based
nix-env
-based environment, installed usingnix-env -ir
rather thannix-env --set
. LnL has an overlay which shows a way of doing this. - home-manager, which provides NixOS-like config for your
$HOME
Note that this is incompatible with regular imperative use of nix-env
, e.g. nix-env -iA nixpkgs.hello
. It has the advantage of allowing the installation of multiple outputs of the same package much better than nix-env
's builtin profile builder does.
I personally currently use home-manager.
- buildEnv ✔️
- buildEnv takes responsibility for the entire user profile, meaning that nix's builtin env builder cannot modify it
- attrset ❌
- the attrset approach leaves building the profile up to
nix-env
, which allows adding packages ad-hoc (though they will be removed on the next profile build) usingnix-env -i
- the attrset approach leaves building the profile up to
- home-manager ❌
- home-manager installs a single
buildEnv
into the user profile, remaining compatible with imperative/impurenix-env
- home-manager installs a single
- buildEnv ❌
- attrset ❌
- home-manager ✔️
- buildEnv ❌
- attrset ❌
- home-manager ✔️
- buildEnv ✔️
- attrset ❌
- home-manager ❓
Thanks, this is nice! It doesn't look like
with xfce;
is needed - that was confusing me, since I didn't want to install xfce.So to elaborate, to use this:
0. Put this file in
~/default.nix
- the instructions say you can put it where you want with whatever name you want but I'm not sure I trust that. The nix-env docs don't explain how just~
is sufficient either.icewm
throughfirefox
with the packages you wantnix-env -f ~ --set
update-profile
After running the above script
nix-env
disappeared from my profile... may want to be careful doing this.Also https://unix.stackexchange.com/questions/332272/name-collision-in-input-nix-expressions-with-nix-env-f recommends against using
nix-env -f ~
.