From 01851cab86c19dd26a2055e865646425d79eaec8 Mon Sep 17 00:00:00 2001 From: Gerg-L Date: Sun, 12 Mar 2023 02:21:01 +0000 Subject: [PATCH] changed zfs mountpoints more, setup self cleaning fs root --- modules/shell.nix | 11 ++++------- systems/gerg-desktop/default.nix | 1 + systems/gerg-desktop/disko.nix | 13 +++++-------- systems/gerg-desktop/erase-your-darlings.nix | 18 ++++++++++++++++++ 4 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 systems/gerg-desktop/erase-your-darlings.nix diff --git a/modules/shell.nix b/modules/shell.nix index 6b95ec2..a77e22d 100644 --- a/modules/shell.nix +++ b/modules/shell.nix @@ -1,8 +1,4 @@ -{fetch-rs, ...}: { - pkgs, - config, - ... -}: rec { +{fetch-rs, ...}: {pkgs, ...}: rec { #put: #source /run/current-system/sw/share/nix-direnv/direnvrc #in ~/.direnvrc @@ -33,8 +29,8 @@ pastebin = "curl -F 'clbin=<-' https://clbin.com"; #nix stuff nix-update = "nix flake update /etc/nixos/"; - nix-switch = "nixos-rebuild switch --flake /etc/nixos/#${config.networking.hostName} --use-remote-sudo"; - nix-boot = "nixos-rebuild boot --flake /etc/nixos/#${config.networking.hostName} --use-remote-sudo"; + nix-switch = "nixos-rebuild switch --use-remote-sudo"; + nix-boot = "nixos-rebuild boot --use-remote-sudo"; nix-clean = "nix-collect-garbage -d"; 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)\""; @@ -62,6 +58,7 @@ execWheelOnly = true; extraConfig = '' Defaults env_keep += "${builtins.concatStringsSep " " (builtins.attrNames environment.variables)}" + Defaults lecture = never ''; }; diff --git a/systems/gerg-desktop/default.nix b/systems/gerg-desktop/default.nix index 4fff656..3385f43 100644 --- a/systems/gerg-desktop/default.nix +++ b/systems/gerg-desktop/default.nix @@ -12,6 +12,7 @@ inputs: { (import ./spicetify.nix inputs) (import ./zfs.nix inputs) (import ./containers inputs) + (import ./erase-your-darlings.nix inputs) ]; disko.devices = import ./disko.nix; diff --git a/systems/gerg-desktop/disko.nix b/systems/gerg-desktop/disko.nix index 08579d3..f1b0363 100644 --- a/systems/gerg-desktop/disko.nix +++ b/systems/gerg-desktop/disko.nix @@ -132,7 +132,6 @@ _: { normalization = "formD"; relatime = "on"; xattr = "sa"; - canmount = "off"; encryption = "on"; keyformat = "passphrase"; keylocation = "prompt"; @@ -141,32 +140,30 @@ _: { ashift = "12"; autotrim = "on"; }; + datasets = { "root" = { zfs_type = "filesystem"; options.mountpoint = "legacy"; mountpoint = "/"; }; - "root/nix" = { + "nix" = { zfs_type = "filesystem"; options.mountpoint = "legacy"; mountpoint = "/nix"; }; - "root/var" = { + "var" = { zfs_type = "filesystem"; - options.mountpoint = "legacy"; mountpoint = "/var"; }; - "root/persist" = { + "persist" = { zfs_type = "filesystem"; - options.mountpoint = "legacy"; mountpoint = "/persist"; }; - "root/home" = { + "home" = { zfs_type = "filesystem"; - options.mountpoint = "legacy"; mountpoint = "/home"; }; diff --git a/systems/gerg-desktop/erase-your-darlings.nix b/systems/gerg-desktop/erase-your-darlings.nix new file mode 100644 index 0000000..5007634 --- /dev/null +++ b/systems/gerg-desktop/erase-your-darlings.nix @@ -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 + ''; +}