Jump to content

Cheatsheet: Difference between revisions

m (Replace backticks with proper formatting)
 
(One intermediate revision by the same user not shown)
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 --file '<nixpkgs/nixos>'
Welcome to Nix 2.18.2. Type :? for help.
Loading installable ''...
Added 6 variables.
nix-repl> config.environment.shells  # for example
[ "/run/current-system/sw/bin/zsh" ... ]
# Equivalently, if starting from an existing REPL:
nix-repl> :l <nixpkgs/nixos>
Added 6 variables.
nix-repl> config.environment.shells
</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