Two general questions

Hi, I’m new to NixOS but have 20+ years experience with Linux/Unix. I have been playing around with NixOS for a few days now and I’m just starting to get a grasp of it.

For the beginning, I have two major questions.

  1. Say I would enable a service (sshd, smb, etc) in the configuration.nix file, will the configuration also take place there or would those still have to be made externally, e.g. sshd_config?

  2. When I add new packages to the configuration.nix file I need to rebuild and switch in order to build and activate the new environment. And probably also to generate a new grub entry. So I suppose that without rebuilding and switching the changes made to that config file wouldn’t come into effect in the first place.
    But what happens if I install a piece of software just for a single user using the nix-env -iA command? It is available instantly but what would happen if I restart the machine before taking any further steps? Will these changes be lost after the reboot? And if so, how can those be made permanent?

I really like NixOS so far and I’m seriously considering to replace my daily drivers which are running Arch and Fedora at the moment with it in the future after I got a better understanding of it.

Thanks in advance.

This depends on the implementation of the corresponding module, though usually the programs/services config also takes place through nix. Though sometimes you need to do so externally, either because no-one implemented the config through nix yet, or because its not possible easily, eg. as it uses a binary file to store its configuration. In the former case you should be able to use some “primitives” like environment.etc to create the config yourself from within nix.

nix-env is permanent, though you really shouldn’t use it for high-level package management. Beyond the fact that it is imperative it has additional flaws. Instead you should perhaps prefer to use Home Manager or if you have nix-command and flakes enabled as experimental features and really want to use imperative user package management nix profile.


Thanks for your reply. I need to evaluate which settings are actually required on my development machines and see how much of that can be implemented through the nix configuration first. I might come back to the forum if I’m actually facing difficulties with a specific configuration in the future.

Thanks for pointing this out. I will probably go the declarative way and look into the Home Manager NixOS module.