Impermanence: Difference between revisions

imported>Klaymore
Add troubleshooting section for updating from 21.11
m 404 wayback, also check https://github.com/mt-caret/blog/issues/4
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{warning|When setting up impermanence, make sure that you have declared password for your user to be able to log-in after the deployment as for example the nixos installer declares passwords imperatively.}}
Impermanence in NixOS is where your root directory gets wiped every reboot (such as by mounting a tmpfs to /). Such a setup is possible because NixOS only needs <code>/boot</code> and <code>/nix</code> in order to boot, all other system files are simply links to files in <code>/nix</code>. <code>/boot</code> and <code>/nix</code> still need to be stored on a hard drive or SSD.
Impermanence in NixOS is where your root directory gets wiped every reboot (such as by mounting a tmpfs to /). Such a setup is possible because NixOS only needs <code>/boot</code> and <code>/nix</code> in order to boot, all other system files are simply links to files in <code>/nix</code>. <code>/boot</code> and <code>/nix</code> still need to be stored on a hard drive or SSD.


Example <code>hardwareconfiguration.nix</code> settings:
Example <code>hardware-configuration.nix</code> settings:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
   fileSystems."/" =
   fileSystems."/" =
Line 40: Line 42:
   imports = [ "${impermanence}/nixos.nix" ];
   imports = [ "${impermanence}/nixos.nix" ];


  # this folder is where the files will be stored (don't put it in tmpfs)
   environment.persistence."/nix/persist/system" = {
   environment.persistence."/nix/persist/system" = {  
    hideMounts = true;
     directories = [
     directories = [
      "/etc/nixos"    # bind mounted from /nix/persist/system/etc/nixos to /etc/nixos
      "/etc/NetworkManager"
       "/var/log"
       "/var/log"
       "/var/lib"
       "/var/lib/bluetooth"
      "/var/lib/nixos"
      "/var/lib/systemd/coredump"
      "/etc/NetworkManager/system-connections"
      { directory = "/var/lib/colord"; user = "colord"; group = "colord"; mode = "u=rwx,g=rx,o="; }
     ];
     ];
     files = [
     files = [
#      "/etc/machine-id"
      "/etc/machine-id"
       "/etc/nix/id_rsa"
       { file = "/etc/nix/id_rsa"; parentDirectory = { mode = "u=rwx,g=,o="; }; }
     ];
     ];
   };
   };
}
}
</syntaxhighlight>
</syntaxhighlight>


=== Home Managing ===
=== Home Managing ===
Line 71: Line 73:
{ config, pkgs, ... }:
{ config, pkgs, ... }:
let
let
   home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/release-21.11.tar.gz";
   home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/release-22.05.tar.gz";
   impermanence = builtins.fetchTarball "https://github.com/nix-community/impermanence/archive/master.tar.gz";
   impermanence = builtins.fetchTarball "https://github.com/nix-community/impermanence/archive/master.tar.gz";
in
in
Line 122: Line 124:
       allowOther = true;
       allowOther = true;
       directories = [
       directories = [
         ".config/gtk-3.0"  # fuse mounted to /home/$USERNAME/.config/gtk-3.0
         ".config/gtk-3.0"  # fuse mounted from /nix/dotfiles/Plasma/.config/gtk-3.0
         ".config/gtk-4.0"
         ".config/gtk-4.0"     # to /home/$USERNAME/.config/gtk-3.0
         ".config/KDE"
         ".config/KDE"
         ".config/kde.org"
         ".config/kde.org"
Line 212: Line 214:
=== Troubleshooting ===
=== Troubleshooting ===


==== Updating from 21.11 to 22.05 or Unstable ====
==== builder for '/nix/store/file-name.service.drv' failed to produce output path for output 'out' at '/nix/store/file-name.service' ====
 
This can happen if your NixOS version is later than your Home-Manager version (ex. NixOS 22.05 with Home-Manager 21.11). See https://github.com/nix-community/impermanence/issues/95.
If it says <code>builder for '/nix/store/file-name.service.drv' failed to produce output path for output 'out' at '/nix/store/file-name.service'</code> after updating your channel from 21.11, then it seems to be because that output path already exists in the Nix store. One possible solution is booting into a NixOS live USB, removing your nix store, and then running a <code>nixos-install</code>.




Line 221: Line 222:


[https://grahamc.com/blog/erase-your-darlings https://grahamc.com/blog/erase-your-darlings] - Explaining why you might want to do this. Uses ZFS snapshots instead of tmpfs.
[https://grahamc.com/blog/erase-your-darlings https://grahamc.com/blog/erase-your-darlings] - Explaining why you might want to do this. Uses ZFS snapshots instead of tmpfs.
https://web.archive.org/web/20241007130142/https://mt-caret.github.io/blog/posts/2020-06-29-optin-state.html - Encypted Btrfs Root with Opt-in State on NixOS. Uses Btrfs instead of tmpfs or ZFS.