nixpkgs/nixos/modules/system/boot
obadz 3d16af70bf nixos/stage-1: add mechanism which lustrates all impurities from / (#17784)
lustrate /ˈlʌstreɪt/ verb.
  purify by expiatory sacrifice, ceremonial washing, or some other
  ritual action.

- sudo touch /etc/NIXOS_LUSTRATE
  ⇒ on next reboot, during stage 1, everything but /nix and /boot
  is moved to /old-root
- echo "etc/passwd" | sudo tee -a /etc/NIXOS_LUSTRATE
  ⇒ on next reboot, during stage 1, everything but /nix and /boot
  is moved to /old-root; except /etc/passwd is copied back.

Useful for installing NixOS in place on another distro. For instance:

$ nix-env -iE '_: with import <nixpkgs/nixos> { configuration = {}; }; with config.system.build; [ nixos-generate-config manual.manpages ]'
$ sudo mkdir /etc/nixos
$ sudo `which nixos-generate-config`

… edit the configuration files in /etc/nixos using man configuration.nix
  if needed

  maybe add: users.extraUsers.root.initialHashedPassword = "" ?

… Build the entire NixOS system and link it to the system profile:
$ nix-env -p /nix/var/nix/profiles/system -f '<nixpkgs/nixos>' -A system --set

… If you were using a single user install:
$ sudo chown -R 0.0 /nix

… NixOS is about to take over
$ sudo touch /etc/NIXOS
$ sudo touch /etc/NIXOS_LUSTRATE

… Let's keep the configuration files we just created
$ echo etc/nixos | sudo tee -a /etc/NIXOS_LUSTRATE

$ sudo mv -v /boot /boot.bak &&
  sudo /nix/var/nix/profiles/system/bin/switch-to-configuration boot
$ sudo reboot

… NixOS boots, Stage 1 moves all the old distro stuff in /old-root.
2016-08-22 01:15:13 +01:00
..
loader Deprecate --install-grub in favor of --install-bootloader for nixos-rebuild. 2016-08-16 07:51:58 -04:00
coredump.nix systemd-coredump: Add systemd service and fix sysctl pattern. 2016-07-10 18:07:37 +10:00
emergency-mode.nix
initrd-network.nix initrd-network: call postCommands only if network is up 2016-02-03 16:35:21 +03:00
initrd-ssh.nix nixos stage-1: unconditionally mount /dev/pts 2016-07-12 22:22:28 +03:00
kernel.nix Revert "Merge branch 'modprobe-fix' of git://github.com/abbradar/nixpkgs" 2016-08-15 19:05:52 -04:00
kexec.nix
luksroot.nix nixos/luksroot: Reference correct output of openssl 2016-08-04 23:12:39 +03:00
modprobe.nix Revert "Merge branch 'modprobe-fix' of git://github.com/abbradar/nixpkgs" 2016-08-15 19:05:52 -04:00
networkd.nix networkd: add DHCPServer config section 2015-12-23 06:04:39 +01:00
pbkdf2-sha512.c
plymouth.nix plymouth service: stop splash screen before a failure prompt 2016-07-18 13:45:37 +03:00
readonly-mountpoint.c
resolved.nix modules.resolved: Enhance by upstream options (#15897) 2016-06-26 22:58:04 +02:00
shutdown.nix
stage-1-init.sh nixos/stage-1: add mechanism which lustrates all impurities from / (#17784) 2016-08-22 01:15:13 +01:00
stage-1.nix nixos/stage-1: add mechanism which lustrates all impurities from / (#17784) 2016-08-22 01:15:13 +01:00
stage-2-init.sh Revert "Merge branch 'modprobe-fix' of git://github.com/abbradar/nixpkgs" 2016-08-15 19:05:52 -04:00
stage-2.nix Make stage-1/2 logging unconditional, and drop log level to "debug" 2016-02-23 11:56:09 +01:00
systemd-lib.nix systemd: make ctrl-alt-del target configurable. (#16911) 2016-07-19 09:42:53 +02:00
systemd-unit-options.nix makeSearchPathOutputs: refactor to makeSearchPathOutput 2016-04-25 13:24:39 +03:00
systemd.nix systemd: make ctrl-alt-del target configurable. (#16911) 2016-07-19 09:42:53 +02:00
timesyncd.nix Don't include networkd units unless enabled 2015-04-19 22:06:45 +02:00
tmp.nix