Jump to content

Cheatsheet: Difference between revisions

1,157 bytes added ,  22 March 2021
no edit summary
imported>Dschrempf
m (Bolden todo items)
imported>Dramforever
No edit summary
Line 374: Line 374:


This creates the `.drv` file that `nixos-rebuild build` would build.
This creates the `.drv` file that `nixos-rebuild build` would build.
=== Manually switching a NixOS system to a certain version of system closure ===
(''Or:'' What <code>nixos-rebuild</code> does under the hoods.)
Step 1: Do this for the equivalent of <code>nixos-rebuild boot</code> or <code>nixos-rebuild switch</code>, i.e. if you want the changes to persist after reboot:
If you have the store path, run this, replacing <code>$systemClosure</code> with store path to your system closure:
<syntaxHighlight lang="console">
$ nix-env --profile /nix/var/nix/profiles/system --set $systemClosure
</syntaxHighlight>
Or, if it was a previous generation, you can run this instead, replacing <code>$generation</code> with the desired generation number:
<syntaxHighlight lang="console">
$ nix-env --profile /nix/var/nix/profiles/system --switch-generation $generation
</syntaxHighlight>
Step 2: Do this for all changes:
Run this, replacing <code>$systemClosure</code> with store path to your system closure, and <code>$action</code> with the action (one of <code>boot</code>, <code>switch</code>, <code>test</code>):
<syntaxHighlight lang="console">
$ $systemClosure/bin/switch-to-configuration $action
</syntaxHighlight>


=== Building a service as a VM (for testing) ===
=== Building a service as a VM (for testing) ===
Anonymous user