4 ms·
Just wondering, what is the benefit of doing this over nix-env for system-wide applications? For project specific environments, I usually use `shell.nix` (mayb
by pca006132 5y ago
Just wondering, what is the benefit of doing this over nix-env for system-wide applications?
For project specific environments, I usually use `shell.nix` (maybe I should switch to flakes now) together with direnv that runs nix-shell automatically when you enter the directory.
For beginners to Nix, I think they should do the transition gradually, there are so many concepts in Nix that may be unfamiliar to them. I think getting a system to work quickly (maybe in a not so idiomatic way) is more encouraging than asking them to read Nix Pills and understand how packaging works in Nix :)
- chriswarbo 5y ago`nix-env` is an imperative command, whilst writing a .nix file is declarative. In particular, the latter can be managed using git, e.g. here's mine: https://github.com/chriswarbo/dotfiles/blob/41c5c4643845f437fd4e9e93f9b73a312576d0ee/nixpkgs/systemPackages.nix https://github.com/chriswarbo/dotfiles/blob/41c5c4643845f437... That's actually over-complicated, since I used to use nix-darwin and haven't bothered to un-pick it yet.
- rgoulter 5y agoYou could use nix-env to install the file with `nix-env --install --file default.nix` rather than using nix-build + symlinking the result. What are the advantages of just nix-build, and adding the result/bin/ to path? Arguably, `nix-env --install` modifies the underlying profiles which manage symlinks. (nix-build + add to PATH is imperative invocation; but `nix-env --install` is and imperative invocation with a stateful effect). e.g. of "how could that be bad?". I'd managed to get myself into a confusing state with `nix-env --install`. When setting up NixOS, I'd installed firefox as the root user. Months later, in my normal user account, I was confused why such an old firefox was installed (since my profile didn't install firefox). I can't remember exactly, but this also somehow caused problems with fontconfig. -- Probably easily avoidable; but if you don't know what you were doing, you might also try all sorts of install commands and forget.
- pxc 5y ago`which -a` and `realpath` are your best friend when you're dealing with a multiuser package manager! Together, they make it easy to figure out if a package comes from your user profile, the default imperative profile, the system profile, or a transient shell profile