Search code examples
nixnixos

What are different among various dot nix files?


I am new to nixos, this is my understanding about configurations

Configuration files created by installer

  • /etc/nixos/configuration.nix :: The central point of system description used by nixos-rebuild
  • /etc/nixos/hardware-configuration.nix :: to be include in above configuration.nix

Configuration files for packages

  • <package>.nix on nixpkgs github :: configuration for each module (options are searchable on nixos package page)

These are what I do not fully understand

  • defatult.nix (any where in filesystem) :: for nix-shell like .bashrc
  • ~/.nixpkgs/config.nix :: nix-env overrided configuration for each users
  • ~/.config/<various>.nix :: ?? no idea

Am I understand it right?

Where can I find more information on these configuration files?


Solution

  • You don't call all of these files configuration files. E.g. the <package>.nix files are rather called derivations. What all these files share is the language in which they are written.

    /etc/nixos/configuration.nix is indeed where you configure your system and ~/.nixpkgs/config.nix where you configure nix-env.

    default.nix doesn't mean anything in particular except that this is the default file that it selected by the commands nix-build and nix-shell when you give them a directory as argument instead of a specific file. Note e.g. that the nixpkgs collection (on GitHub like you noticed already) contains a lot of such default.nix files.

    To understand all of this better I advise you to read Nix-pills (that's a long series but it's worth it) and of course the NixOS, Nix and nixpkgs manuals.