Jump to content

Cheatsheet: Difference between revisions

no edit summary
m (Replace backticks with proper formatting)
No edit summary
Line 90: Line 90:


This creates the <code>.drv</code> file that <code>nixos-rebuild build</code> would build.
This creates the <code>.drv</code> file that <code>nixos-rebuild build</code> would build.
=== Explore a NixOS configuration in the REPL ===
If you want to see what ''value'' a NixOS option takes without building, as opposed to merely checking that all options work, you can run:
<syntaxHighlight lang="console">
$ nix repl
nix-repl> :a import <nixpkgs/nixos> { }
Added 6 variables.
nix-repl> config.environment.shells  # for example
</syntaxHighlight>
This can be helpful if your configuration is spread across multiple modules, or if you import modules from external sources, or if NixOS has defaults and you want to know whether a default is being used or extended in your configuration, or a variety of other cases in which you might want the computer to tell you what the end result of all your Nixing is going to be before you switch to it.
You can do this with configuration files other than the one installed in <code>/etc/nixos</code>, too:
<pre>
nix-repl> :a import <nixpkgs/nixos> { configuration = /path/to/config.nix; }
</pre>


=== Manually switching a NixOS system to a certain version of system closure ===
=== Manually switching a NixOS system to a certain version of system closure ===
6

edits