I use NixOS, but I use /etc/nixos/configuration.nix
to describe my system; I keep it fairly minimal and prefer not to install "user" software by editing configuration.nix.
So what I do instead is use my ~/.nixpkgs/config.nix
(which I believe you also have an equivalent of even in a non-NixOS nix install? I've never actually used nix separately).
The basic structure I use is this:
{
packageOverrides = nixpkgs: with nixpkgs; rec {
mine = with pkgs; buildEnv {
name = "mine";
paths = [
# your packages here
];
};
};
}
buildEnv
is a convenience function from nix that makes an "environment" package out of a bunch of others; installing the package mine
depends on (and so installs) all of the things listed in paths
, and also makes sure they get included in PATH
and things like that.
Then I just use nix-env -riA nixos.mine
to deploy changes I've made to my environment description (or to rebuild my environment following channel updates). The -r
tells it to remove everything else other than mine
from the new generation of my profile, which means I can (ab?)use nix-env -i some-package
as a way of "temporarily" installing some-package
, and if I don't decide I like it enough to actually record it in my config.nix it'll just get removed anyway next time I deploy.