User Tools

Site Tools


manuals:distributions:nixos:impermanence

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
manuals:distributions:nixos:impermanence [2024/10/21 07:44] aithermanuals:distributions:nixos:impermanence [2026/07/12 20:30] (current) – Annotate vpsAdmin navigation paths and update interface labels aither
Line 1: Line 1:
 +<page>manuals:distributions:nixos:impermanence</page>
 ====== NixOS Impermanence ====== ====== NixOS Impermanence ======
- 
-<note warning> 
-This is a work in progress, impermanence is available only on staging (node1.stg) 
-</note> 
  
 This page describes usage of [[https://github.com/nix-community/impermanence|NixOS Impermanence]] module This page describes usage of [[https://github.com/nix-community/impermanence|NixOS Impermanence]] module
Line 16: Line 13:
  
 ===== Using OS template ===== ===== Using OS template =====
-vpsAdmin contains OS templates where the impermanence module is preconfigured. +vpsAdmin contains OS templates where impermanence is preconfigured. When creating a new VPS, 
-When creating a new VPS, choose the appropriate template (impermanence is in its name). +choose the appropriate template (impermanence is in its name). The new VPS will have ''/nix'' 
-The new VPS will have ''/nix'' separated in a subdataset. The root dataset will be mounted +separated in a subdataset. The root dataset will be mounted to ''/persistent'' and initial 
-to ''/persistent'' and initial impermanence configuration will be deployed. +flake-based NixOS configuration will be deployed to ''/etc/nixos'', see ''/etc/nixos/flake.nix'' 
-See ''/etc/nixos/configuration.nix''Copy of the impermanence module is stored at +and ''/etc/nixos/configuration.nix''The template also writes ''/etc/nixos/flake.lock'', so 
-''/etc/nixos/impermanence'', you might want to update it to the latest versione.g. by cloning +versions of vpsAdminOS''nixpkgs'' and impermanence are pinned together.
-the git repository to the same path:+
  
-<code>+Impermanence is included as a flake input. To update it, update the flake lock and rebuild 
 +the system: 
 + 
 +<code bash>
 cd /etc/nixos cd /etc/nixos
-rm -rf impermanence +nix flake lock --update-input impermanence 
-git clone https://github.com/nix-community/impermanence+nixos-rebuild switch --flake /etc/nixos#vps
 </code> </code>
  
Line 42: Line 41:
  
 ==== 2. Start the VPS in rescue mode ==== ==== 2. Start the VPS in rescue mode ====
-In VPS details, use form **Boot VPS from template (rescue mode)**. It's best+In VPS details, use form <vpsadmin-nav id="vps.boot-rescue.open">**Boot VPS from template (rescue mode)**</vpsadmin-nav>. It's best
 to choose a different distribution than NixOS, so that there's no ''/nix'' directory. to choose a different distribution than NixOS, so that there's no ''/nix'' directory.
 Use e.g. Alpine or Debian. Use e.g. Alpine or Debian.
Line 64: Line 63:
 every start. We must mount our persistent storage to ''/persistent''. This can be either every start. We must mount our persistent storage to ''/persistent''. This can be either
 the root dataset, or you can create another subdataset for that purpose. We'll use the root the root dataset, or you can create another subdataset for that purpose. We'll use the root
-dataset. In VPS details, click on **Mount** link of the first listed dataset+dataset. In VPS details, click on <vpsadmin-nav id="datasets.mount.open">**Mount**</vpsadmin-nav> link of the first listed dataset
 (its name is the VPS ID) and mount it to ''/persistent''. (its name is the VPS ID) and mount it to ''/persistent''.
  
Line 70: Line 69:
 Now restart the VPS, you will leave the rescue mode. Now restart the VPS, you will leave the rescue mode.
  
-==== 7. Edit your configuration and add the impermanence module ==== +==== 7. Edit your flake configuration and add impermanence ==== 
-Clone the impermanence module repository into ''/etc/nixos''This requires git, if you +vpsAdminOS templates enable flakes by default. Create ''/etc/nixos/flake.nix'' and 
-don't have it in your system, you can use e.g. ''nix-shell -p git''.+keep your local settings in ''/etc/nixos/configuration.nix''. The example below follows the 
 +stable ''nixpkgs'' branch used by vpsAdminOS. If you're using another stable release, use the 
 +matching ''nixos-YY.MM'' branchIf you're using NixOS unstable, replace 
 +''github:NixOS/nixpkgs/nixos-25.11'' with ''github:NixOS/nixpkgs/nixos-unstable'' and 
 +replace the stable container module line in the example with 
 +''vpsadminos.nixosModules.containerUnstable''.
  
-<code bash> +<file nix /etc/nixos/flake.nix> 
-cd /etc/nixos +
-git clone https://github.com/nix-community/impermanence.git +  inputs = { 
-</code>+    vpsadminos.url = "github:vpsfreecz/vpsadminos"; 
 +    nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; 
 +    impermanence.url = "github:nix-community/impermanence"; 
 +  };
  
-Extend your configuration and add the impermanence module:+  outputs = { nixpkgs, vpsadminos, impermanence, ... }: 
 +    let 
 +      containerModule = "container_${builtins.replaceStrings [ "." ] [ "_" ] nixpkgs.lib.trivial.release}"; 
 +    in 
 +    { 
 +      nixosConfigurations.vps = nixpkgs.lib.nixosSystem { 
 +        system = "x86_64-linux"; 
 +        modules = [ 
 +          vpsadminos.nixosModules.${containerModule} 
 +          impermanence.nixosModules.impermanence 
 +          ./configuration.nix 
 +        ]; 
 +      }; 
 +    }; 
 +
 +</file> 
 + 
 +Then extend your configuration and add the persistence settings:
  
 <file nix /etc/nixos/configuration.nix> <file nix /etc/nixos/configuration.nix>
-config, ... }:+{ ... }:
 { {
-  imports = [ 
-    ./impermanence/nixos.nix 
-  ]; 
- 
   environment.persistence."/persistent" = {   environment.persistence."/persistent" = {
     hideMounts = true;     hideMounts = true;
Line 97: Line 117:
     files = [     files = [
       "/etc/machine-id"       "/etc/machine-id"
-      "/etc/shadow" 
     ];     ];
   };   };
 } }
 </file> </file>
 +
 +Ensure flakes are enabled, for example:
 +
 +<code nix>
 +nix.settings.experimental-features = [
 +  "nix-command"
 +  "flakes"
 +];
 +</code>
  
 Note that ''/persistent'' must match the dataset mountpoint, but you can choose an arbitrary name Note that ''/persistent'' must match the dataset mountpoint, but you can choose an arbitrary name
Line 110: Line 138:
  
 <code bash> <code bash>
-nixos-rebuild boot+nixos-rebuild boot --flake /etc/nixos#vps
 </code> </code>
  
Line 130: Line 158:
 ''/'' is based in a temporary dataset, ''11327'' is used for ''/persistent'' and ''11327/nix'' ''/'' is based in a temporary dataset, ''11327'' is used for ''/persistent'' and ''11327/nix''
 contains the Nix store. contains the Nix store.
- 
manuals/distributions/nixos/impermanence.1729496665.txt.gz · Last modified: by aither