3

Often I'm configuring a new service and having to run nixos-rebuild switch for the changes to take effect.

For example setting up a configuration for a webserver.

However the nixos-rebuild switch takes quite a few seconds to run. Is there a quicker alternative to rebuild just a subset of my Nixos configuration? I did notice a --fast parameter - however this does not seem to make much of any difference.

2 Answers 2

0

nixos-rebuild test - doesn't spend time in updating grub. Run nixos-rebuild switch or nixos-rebuild boot when configured to your heart's content

3
  • 1
    Is it possible to do nixos-rebuild without network access? Say all I want to do is a config change that shouldn't require any new packages.
    – Philippe
    Mar 11, 2020 at 8:51
  • I'm not certain but I believe you can clone the main nixpkgs repository from Github, and then whenever you do a nixos-rebuild you can point it at your local nixpkgs instead of the remote. Explained in the manual here: nixos.org/manual/nixos/stable/index.html#sec-custom-packages
    – bgibson
    Sep 25, 2021 at 22:11
  • @Philippe I believe recent versions have something of a no-internet switch (or is it coming with nix 2.4?) but I never got it working :}
    – 0fnt
    Oct 26, 2021 at 21:12
0

If you only want to evaluate configuration.nix without building (e.g. to syntax-check or see if you are using module options correctly), you can use: $ nix-instantiate '<nixpkgs/nixos>' -A system

Taken from: https://nixos.wiki/wiki/Cheatsheet

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .