changed zfs mountpoints more, setup self cleaning fs root

This commit is contained in:
Gerg-L 2023-03-12 02:21:01 +00:00
parent 2cf332631b
commit 01851cab86
4 changed files with 28 additions and 15 deletions

View file

@ -1,8 +1,4 @@
{fetch-rs, ...}: { {fetch-rs, ...}: {pkgs, ...}: rec {
pkgs,
config,
...
}: rec {
#put: #put:
#source /run/current-system/sw/share/nix-direnv/direnvrc #source /run/current-system/sw/share/nix-direnv/direnvrc
#in ~/.direnvrc #in ~/.direnvrc
@ -33,8 +29,8 @@
pastebin = "curl -F 'clbin=<-' https://clbin.com"; pastebin = "curl -F 'clbin=<-' https://clbin.com";
#nix stuff #nix stuff
nix-update = "nix flake update /etc/nixos/"; nix-update = "nix flake update /etc/nixos/";
nix-switch = "nixos-rebuild switch --flake /etc/nixos/#${config.networking.hostName} --use-remote-sudo"; nix-switch = "nixos-rebuild switch --use-remote-sudo";
nix-boot = "nixos-rebuild boot --flake /etc/nixos/#${config.networking.hostName} --use-remote-sudo"; nix-boot = "nixos-rebuild boot --use-remote-sudo";
nix-clean = "nix-collect-garbage -d"; nix-clean = "nix-collect-garbage -d";
nix-gc-force = "rm /nix/var/nix/gcroots/auto/*"; nix-gc-force = "rm /nix/var/nix/gcroots/auto/*";
nix-gc-check = "nix-store --gc --print-roots | egrep -v \"^(/nix/var|/run/\w+-system|\{memory|/proc)\""; nix-gc-check = "nix-store --gc --print-roots | egrep -v \"^(/nix/var|/run/\w+-system|\{memory|/proc)\"";
@ -62,6 +58,7 @@
execWheelOnly = true; execWheelOnly = true;
extraConfig = '' extraConfig = ''
Defaults env_keep += "${builtins.concatStringsSep " " (builtins.attrNames environment.variables)}" Defaults env_keep += "${builtins.concatStringsSep " " (builtins.attrNames environment.variables)}"
Defaults lecture = never
''; '';
}; };

View file

@ -12,6 +12,7 @@ inputs: {
(import ./spicetify.nix inputs) (import ./spicetify.nix inputs)
(import ./zfs.nix inputs) (import ./zfs.nix inputs)
(import ./containers inputs) (import ./containers inputs)
(import ./erase-your-darlings.nix inputs)
]; ];
disko.devices = import ./disko.nix; disko.devices = import ./disko.nix;

View file

@ -132,7 +132,6 @@ _: {
normalization = "formD"; normalization = "formD";
relatime = "on"; relatime = "on";
xattr = "sa"; xattr = "sa";
canmount = "off";
encryption = "on"; encryption = "on";
keyformat = "passphrase"; keyformat = "passphrase";
keylocation = "prompt"; keylocation = "prompt";
@ -141,32 +140,30 @@ _: {
ashift = "12"; ashift = "12";
autotrim = "on"; autotrim = "on";
}; };
datasets = { datasets = {
"root" = { "root" = {
zfs_type = "filesystem"; zfs_type = "filesystem";
options.mountpoint = "legacy"; options.mountpoint = "legacy";
mountpoint = "/"; mountpoint = "/";
}; };
"root/nix" = { "nix" = {
zfs_type = "filesystem"; zfs_type = "filesystem";
options.mountpoint = "legacy"; options.mountpoint = "legacy";
mountpoint = "/nix"; mountpoint = "/nix";
}; };
"root/var" = { "var" = {
zfs_type = "filesystem"; zfs_type = "filesystem";
options.mountpoint = "legacy"; options.mountpoint = "legacy";
mountpoint = "/var"; mountpoint = "/var";
}; };
"root/persist" = { "persist" = {
zfs_type = "filesystem"; zfs_type = "filesystem";
options.mountpoint = "legacy"; options.mountpoint = "legacy";
mountpoint = "/persist"; mountpoint = "/persist";
}; };
"root/home" = { "home" = {
zfs_type = "filesystem"; zfs_type = "filesystem";
options.mountpoint = "legacy"; options.mountpoint = "legacy";
mountpoint = "/home"; mountpoint = "/home";
}; };

View file

@ -0,0 +1,18 @@
_: {lib, ...}: {
systemd.tmpfiles.rules = [
"d /mnt - - - - -"
"L+ /etc/ssh/ssh_host_ed25519_key - - - - /persist/ssh/ssh_host_ed25519_key"
"L+ /etc/ssh/ssh_host_ed25519_key.pub - - - - /persist/ssh/ssh_host_ed25519_key.pub"
"L+ /etc/nixos - - - - /persist/nixos"
];
boot.initrd.postDeviceCommands = lib.mkAfter ''
zfs snapshot destroy rpool/root@prev
zfs snapshot destroy rpool/var@prev
zfs snapshot create rpool/root@prev
zfs snapshot create rpool/var@prev
zfs rollback -r rpool/root@empty
zfs rollback -r rpool/var@empty
'';
}