I read a bit about NixOS and tried it these days, because I got the impression that it would let me configure a Linux with just one file.
When I used it, I installed a bunch of packages with nix-env
, so they didn't end up in the configuration.nix
, but I could simply uninstall them later and add them to the configuration.nix
by hand. I there something like npm i -g <package>
that would install this globally so it would end up in the configuration.nix
and could simply be copied to another machine.
Also, I installed stuff like zsh
and atom
and they have an entirely different approach to configuration and customization (bashscript, javascript, less, etc).
Is there a way for Nix/NixOS to track the package-specific config too?
Does it already happen and I don't see it? Like the nix expression of the package knows where the package will store its config etc.
I mean, it's nice that I can add these packages to the main config and when using it at another PC I get the same software installed, but I still see myself writing rather much configs for the installed packages too.
This configuration file is normally located at /etc/nixos/configuration. nix (although another location may be specified using the environment variable NIX_PATH ); after the configuration file is modified, the new configuration is then made active by running nixos-rebuild switch .
This is a source deployment model. For most users, building from source is not very pleasant as it takes far too long. However, Nix can automatically skip building from source and instead use a binary cache, a web server that provides pre-built binaries.
NixOS is a lightweight package manager that allows users to install, uninstall and manage packages with and without root access.
If you want packages installed through configuration.nix
, then the easiest way to accomplish that is to add them to the environment.systemPackages
attribute. Packages listed in there will be available automatically to all users on the machine. As far as I know, there is no shell command available to automate the maintenance of that attribute, though. The only way to manage that list is by editing configuration.nix
and manually adding the packages you'd like to have installed.
Nix does not manage package-specific configuration files. As you probably know, NixOS provides such a mechanism for files in /etc
, but a similar mechanism to manage config files in $HOME
etc. does not exist. The PR https://github.com/NixOS/nixpkgs/pull/9250 on Github contains a concrete proposal to add this capability to Nix, but it hasn't been merged yet because it requires some changes that are controversial.
Nix does not currently offer ways of managing user specific configuration or language specific package managers. AFAICT that's because it is a very complex and opinionated territory compared to generating configs for sshd etc.
There are however Nix-based projects providing solution to at least some parts of your question. For managing user configuration (zsh etc.), have a look at home manager.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With