tech:cheatsheets:linux:nixos
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tech:cheatsheets:linux:nixos [2025/02/21 17:58] – [Infect system using nixos-infect] waldemar | tech:cheatsheets:linux:nixos [2025/05/07 04:55] (current) – [System is not lustrated] waldemar | ||
|---|---|---|---|
| Line 5: | Line 5: | ||
| ==== Infect system using nixos-infect ==== | ==== Infect system using nixos-infect ==== | ||
| + | Ensure you're root when executing the commands ('' | ||
| + | |||
| + | <note important> | ||
| + | If any profile is installed for root (re)move the existing profile at ''/ | ||
| + | </ | ||
| + | |||
| <code bash> | <code bash> | ||
| - | sudo touch / | + | touch / |
| - | curl https:// | + | curl https:// |
| </ | </ | ||
| ==== Apply configuration ==== | ==== Apply configuration ==== | ||
| - | First check-out desired configuration into `/etc/nixos. | + | Check-out your desired configuration into '' |
| <code bash> | <code bash> | ||
| - | # Change owner to primary user if you want to edit it from the primary user | ||
| - | chown -R 1000:1000 /etc/nixos | ||
| git clone < | git clone < | ||
| + | / | ||
| + | -I nixpkgs=$(realpath $HOME/ | ||
| + | -p nixos-install-tools \ | ||
| + | --run ' | ||
| + | > / | ||
| + | | ||
| + | # If your configuration is flake-based | ||
| + | / | ||
| + | -I nixpkgs=$(realpath $HOME/ | ||
| + | -p nixos-rebuild \ | ||
| + | --run ' | ||
| + | |||
| + | # For legacy configurations | ||
| + | / | ||
| + | -I nixpkgs=$(realpath $HOME/ | ||
| + | -p nixos-rebuild \ | ||
| + | --run ' | ||
| </ | </ | ||
| - | Then restart system once so NixOS replaces the currently installed system. | + | Add directories and files you want to keep to ''/ |
| - | Afterwards boot another NixOS system (e.g. from another partition or live CD) to adjust system configuration for example LUKS partitions. | + | |
| - | When second NixOS system is booted mount your system into `/mnt` including additional partitions like boot partition (into their respective directories). Afterwards invoke | + | Also ensure that if your primary partition is an encrypted partition to add relevant configuration to your '' |
| + | |||
| + | ==== Rescue ==== | ||
| + | Should the system not boot you can use another NixOS system (e.g. from another partition or live CD) to adjust system configuration for example LUKS partitions. | ||
| + | |||
| + | When second NixOS system is booted mount your system into '' | ||
| <code bash> | <code bash> | ||
| mount / | mount / | ||
| Line 45: | Line 70: | ||
| # nixos-rebuild boot | # nixos-rebuild boot | ||
| </ | </ | ||
| + | |||
| + | ===== Troubleshooting ===== | ||
| + | ==== System is not lustrated ==== | ||
| + | For some reason a system is not lustrated (NOTE: system must boot via GRUB for lustrate to work aparently). If that happens a boot might fail due to systemd not finding '' | ||
| + | If that happens a manual lustration might help (= move files manually from root into subfolder). | ||
| + | |||
| + | Apparently systemd must also not be enabled in initrd for it work. | ||
tech/cheatsheets/linux/nixos.1740160715.txt.gz · Last modified: by waldemar