How to configure a Nix environment, outside of NixOS?

This file is indeed specific to NixOS and it is created automatically when installing NixOS. That said, there are workarounds.

  • One of them is described in https://nixos.org/nixpkgs/manual/#sec-declarative-package-management in the Nixpkgs manual. (Added in this PR.)

    Please note that the overlays mechanism came along since then, and according to Chapter 12. Overlays: "Overlays are similar to other methods for customizing Nixpkgs, in particular the packageOverrides attribute described in Section 6.5, “Modify packages via packageOverrides”. Indeed, packageOverrides acts as an overlay with only the super argument. It is therefore appropriate for basic use, but overlays are more powerful and easier to distribute."

  • It seems that there was also a work-in-progress for a user-side declarative configuration but it hasn't been updated in a while: https://github.com/NixOS/nixpkgs/pull/9250

  • See also the Declarative package management for normal users discussion on the NixOS Discourse.


I manage my dotfiles on Ubuntu using Nix. I run this script which is just a wrapper around this installer.

The installer versions the dotfiles into a Nix package, and uses GNU stow to link them back to your home directory.

It is probably a bit complex for most people, but I use it to manage dotfiles between NixOS, Ubuntu and OSX.

Tags:

Nix