impermanence
This commit is contained in:
parent
9205ec2d23
commit
1795a4a275
4 changed files with 60 additions and 0 deletions
|
|
@ -12,6 +12,10 @@
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=latest";
|
nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=latest";
|
||||||
|
impermanence = {
|
||||||
|
url = "github:nix-community/impermanence";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
lix-module.url = "git+https://git.lix.systems/lix-project/nixos-module?ref=release-2.93";
|
lix-module.url = "git+https://git.lix.systems/lix-project/nixos-module?ref=release-2.93";
|
||||||
lix-module.inputs.nixpkgs.follows = "nixpkgs";
|
lix-module.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
lanzaboote.url = "github:nix-community/lanzaboote";
|
lanzaboote.url = "github:nix-community/lanzaboote";
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
inputs.lix-module.nixosModules.lixFromNixpkgs
|
inputs.lix-module.nixosModules.lixFromNixpkgs
|
||||||
inputs.nix-index-database.nixosModules.nix-index
|
inputs.nix-index-database.nixosModules.nix-index
|
||||||
inputs.nix-flatpak.nixosModules.nix-flatpak
|
inputs.nix-flatpak.nixosModules.nix-flatpak
|
||||||
|
inputs.impermanence.nixosModules.impermanence
|
||||||
../system/flatpak.nix
|
../system/flatpak.nix
|
||||||
../system/base.nix
|
../system/base.nix
|
||||||
../system/packages.nix
|
../system/packages.nix
|
||||||
|
|
@ -13,6 +14,7 @@
|
||||||
../system/home-manager-skel.nix
|
../system/home-manager-skel.nix
|
||||||
../system/fonts.nix
|
../system/fonts.nix
|
||||||
../system/printer.nix
|
../system/printer.nix
|
||||||
|
../system/impermanence.nix
|
||||||
../desktop/desktop-entries.nix
|
../desktop/desktop-entries.nix
|
||||||
../desktop/file-manager.nix
|
../desktop/file-manager.nix
|
||||||
../desktop/gnome-minimal.nix
|
../desktop/gnome-minimal.nix
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
content = {
|
content = {
|
||||||
type = "btrfs";
|
type = "btrfs";
|
||||||
extraArgs = [ "-f" ];
|
extraArgs = [ "-f" ];
|
||||||
|
label = "nixos";
|
||||||
subvolumes = {
|
subvolumes = {
|
||||||
root = {
|
root = {
|
||||||
mountpoint = "/";
|
mountpoint = "/";
|
||||||
|
|
@ -48,6 +49,13 @@
|
||||||
"compress=zstd"
|
"compress=zstd"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
persist = {
|
||||||
|
mountpoint = "/persist";
|
||||||
|
mountOptions = [
|
||||||
|
"compress=zstd"
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
46
modules/system/impermanence.nix
Normal file
46
modules/system/impermanence.nix
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = lib.mkIf (
|
||||||
|
(config.fileSystems ? "/persist")
|
||||||
|
&& (config.fileSystems."/persist".fsType or "" == "btrfs")
|
||||||
|
) {
|
||||||
|
boot.initrd.supportedFilesystems = [ "btrfs" ];
|
||||||
|
|
||||||
|
boot.initrd.postDeviceCommands = lib.mkAfter ''
|
||||||
|
mkdir -p /mnt
|
||||||
|
mount -t btrfs -o subvol=/ /dev/disk/by-label/nixos /mnt
|
||||||
|
|
||||||
|
if [ ! -d /mnt/root-blank ]; then
|
||||||
|
btrfs subvolume snapshot -r /mnt/root /mnt/root-blank
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d /mnt/root ]; then
|
||||||
|
btrfs subvolume delete /mnt/root
|
||||||
|
fi
|
||||||
|
|
||||||
|
btrfs subvolume snapshot /mnt/root-blank /mnt/root
|
||||||
|
umount /mnt
|
||||||
|
'';
|
||||||
|
|
||||||
|
fileSystems."/persist".neededForBoot = true;
|
||||||
|
|
||||||
|
environment.persistence."/persist" = {
|
||||||
|
hideMounts = true;
|
||||||
|
directories = [
|
||||||
|
"/etc/nixos"
|
||||||
|
"/etc/ssh"
|
||||||
|
"/etc/cups"
|
||||||
|
"/var/lib/cups"
|
||||||
|
"/var/lib/libvirt"
|
||||||
|
"/var/lib/secureboot"
|
||||||
|
"/var/lib/tailscale"
|
||||||
|
"/var/lib/systemd"
|
||||||
|
"/var/lib/nixos"
|
||||||
|
];
|
||||||
|
files = [
|
||||||
|
"/etc/machine-id"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue