This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| manuals:distributions:nixos:impermanence [2024/10/29 17:03] – aither | manuals:distributions:nixos:impermanence [2026/03/12 11:19] (current) – nix flakes aither | ||
|---|---|---|---|
| Line 13: | Line 13: | ||
| ===== Using OS template ===== | ===== Using OS template ===== | ||
| - | vpsAdmin contains OS templates where the impermanence | + | 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 ''/ |
| - | The new VPS will have ''/ | + | separated in a subdataset. The root dataset will be mounted to ''/ |
| - | to ''/ | + | flake-based NixOS configuration will be deployed |
| - | See ''/ | + | and ''/ |
| - | ''/ | + | versions of vpsAdminOS, '' |
| - | the git repository to the same path: | + | |
| - | < | + | Impermanence is included as a flake input. To update it, update the flake lock and rebuild |
| + | the system: | ||
| + | |||
| + | < | ||
| cd /etc/nixos | cd /etc/nixos | ||
| - | rm -rf impermanence | + | nix flake lock --update-input impermanence |
| - | git clone https:// | + | nixos-rebuild switch --flake |
| </ | </ | ||
| Line 67: | 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 | + | ==== 7. Edit your flake configuration and add impermanence ==== |
| - | Clone the impermanence module repository into ''/ | + | vpsAdminOS templates enable flakes by default. Create |
| - | don't have it in your system, | + | keep your local settings in ''/ |
| + | stable | ||
| + | matching '' | ||
| + | '' | ||
| + | replace the stable container module line in the example with | ||
| + | '' | ||
| - | <code bash> | + | <file nix /etc/nixos/ |
| - | cd / | + | { |
| - | git clone https://github.com/ | + | inputs = { |
| - | </ | + | vpsadminos.url = " |
| + | nixpkgs.url = " | ||
| + | impermanence.url = " | ||
| + | }; | ||
| - | Extend | + | outputs = { nixpkgs, vpsadminos, impermanence, |
| + | let | ||
| + | containerModule = " | ||
| + | in | ||
| + | { | ||
| + | nixosConfigurations.vps = nixpkgs.lib.nixosSystem { | ||
| + | system = " | ||
| + | modules = [ | ||
| + | vpsadminos.nixosModules.${containerModule} | ||
| + | impermanence.nixosModules.impermanence | ||
| + | ./ | ||
| + | ]; | ||
| + | }; | ||
| + | }; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Then extend | ||
| <file nix / | <file nix / | ||
| - | { config, | + | { ... }: |
| { | { | ||
| - | imports = [ | ||
| - | ./ | ||
| - | ]; | ||
| - | |||
| environment.persistence."/ | environment.persistence."/ | ||
| hideMounts = true; | hideMounts = true; | ||
| Line 98: | Line 121: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | Ensure flakes are enabled, for example: | ||
| + | |||
| + | <code nix> | ||
| + | nix.settings.experimental-features = [ | ||
| + | " | ||
| + | " | ||
| + | ]; | ||
| + | </ | ||
| Note that ''/ | Note that ''/ | ||
| Line 106: | Line 138: | ||
| <code bash> | <code bash> | ||
| - | nixos-rebuild boot | + | nixos-rebuild boot --flake / |
| </ | </ | ||
| Line 126: | Line 158: | ||
| ''/'' | ''/'' | ||
| contains the Nix store. | contains the Nix store. | ||
| - | |||