From 6240431d3649b77e2f1e46b06f3b8fe2c21c0bf5 Mon Sep 17 00:00:00 2001 From: Madeleine Sydney Date: Sat, 28 Dec 2024 16:28:03 -0700 Subject: [PATCH] Move from ZFS to btrfs --- .dir-locals.el | 32 ++++++--- hosts/nixos-testbed/configuration.nix | 16 ++--- hosts/nixos-testbed/disko-config.nix | 99 +++++++++++---------------- 3 files changed, 69 insertions(+), 78 deletions(-) diff --git a/.dir-locals.el b/.dir-locals.el index b26fb42..a873df4 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -1,11 +1,23 @@ ((nil - . ((eval . (defun dots/install-to-vm (clean-first?) - (interactive "P") - (let ((dest "/ssh:root@192.168.122.116:/nixos") - (root (project-root (project-current)))) - (progn - (when clean-first? - (delete-directory dest t)) - (org-babel-tangle-file (file-name-concat root "README.org")) - (copy-file root dest) - (message "Finished installing to VM!")))))))) + . ((eval + . (defun dots/install-to-vm (clean-first?) + (interactive "P") + (let ((dest-directory "/ssh:root@192.168.122.116:/nixos") + (root (project-root (project-current))) + (ignored-paths '(".jj" ".git" ".gitignore" ".dir-locals.el"))) + (progn + ;; (message "Tangling...") + ;; (org-babel-tangle-file (file-name-concat root "README.org")) + (when clean-first? + (delete-directory dest t)) + (make-directory dest-directory t) + (let ((files-to-install + (--> (directory-files root) + (-filter (lambda (x) (not (memq x ignored-paths))) it)))) + (dolist (file-src files-to-install) + (let ((file-dest-directory + (file-name-concat dest-directory + (file-name-directory file-src)))) + (make-directory file-dest-directory t) + (copy-file file file-dest-directory)))) + (message "Finished installing to VM!")))))))) diff --git a/hosts/nixos-testbed/configuration.nix b/hosts/nixos-testbed/configuration.nix index d16bcba..261068a 100644 --- a/hosts/nixos-testbed/configuration.nix +++ b/hosts/nixos-testbed/configuration.nix @@ -7,11 +7,11 @@ sydnix = { impermanence = { - enable = true; + enable = false; directories = [ - # Warning: Neither /var/lib/nixos nor any of its parents are persisted. + # "Warning: Neither /var/lib/nixos nor any of its parents are persisted. # This means all users/groups without specified uids/gids will have them - # reassigned on reboot. + # reassigned on reboot." "/var/lib/nixos" "/etc/ssh" ]; @@ -30,11 +30,11 @@ enable = true; systemd.enable = true; - systemd.initrdBin = with pkgs; [ - zfs - coreutils - babashka - ]; + # systemd.initrdBin = with pkgs; [ + # zfs + # coreutils + # babashka + # ]; }; loader = { diff --git a/hosts/nixos-testbed/disko-config.nix b/hosts/nixos-testbed/disko-config.nix index aea3a38..47d0cda 100644 --- a/hosts/nixos-testbed/disko-config.nix +++ b/hosts/nixos-testbed/disko-config.nix @@ -1,18 +1,18 @@ -# sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode disko /nixos/hosts/nixos-testbed/disko-config.nix -# time sudo nixos-install --flake /nixos#nixos-testbed +# sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode disko /persist/dots/hosts/nixos-testbed/disko-config.nix +# time sudo nixos-install --flake /persist/dots#nixos-testbed { lib, ... }: { # imports = [ disko.nixosModules.disko ]; - boot.zfs.extraPools = [ "rpool" ]; - boot.zfs.devNodes = "/dev/disk/by-path"; - boot.initrd.supportedFilesystems = [ "zfs" ]; - boot.supportedFilesystems = [ "zfs" ]; + boot.initrd.supportedFilesystems.btrfs = true; + boot.supportedFilesystems.btrfs = true; + + fileSystems."/persist".neededForBoot = true; disko.devices = { disk = { - broot = { + bootroot = { type = "disk"; - device = "/dev/vda"; + device = "/dev/sda"; content = { type = "gpt"; partitions = { @@ -29,63 +29,42 @@ root = { size = "100%"; content = { - type = "zfs"; - pool = "rpool"; + type = "btrfs"; + + mountpoint = "/partition-root"; + swap.swapfile.size = "4G"; + + # Override existing partitions. + extraArgs = [ "-f" ]; + + # Subvolumes must set a mountpoint in order to be mounted, + # *unless their parent is mounted*. + subvolumes = { + # Subvolume names do not necessarily correspond to + # mountpoints, despite the structural resemblance to a file + # path. + "/rootfs" = { + mountpoint = "/"; + }; + "/nix" = { + mountpoint = "/nix"; + }; + "/persist" = { + mountpoint = "/persist"; + }; + "/persist/home" = { + mountpoint = "/persist/home"; + }; + "/swap" = { + mountpoint = "/.swapvol"; + swap.swapfile.size = "4G"; + }; + }; }; }; }; }; }; }; - zpool = { - rpool = { - type = "zpool"; - datasets = - let dataset = options: - let default = { - type = "zfs_fs"; - mountOptions = [ "noauto" ]; - options = { - "com.sun:auto-snapshot" = "false"; - }; - }; - in lib.recursiveUpdate default options; - in - { - "local" = dataset {}; - "darlings" = dataset {}; - "local/root" = dataset { - mountpoint = "/"; - postCreateHook = '' - zfs list -t snapshot -H -o name \ - | grep -E '^rpool/local/root@blank$' \ - || zfs snapshot rpool/local/root@blank - ''; - }; - "local/nix" = dataset { mountpoint = "/nix"; }; - "local/home" = dataset { - mountpoint = "/home"; - postCreateHook = '' - zfs list -t snapshot -H -o name \ - | grep -E '^rpool/local/home@blank$' \ - || zfs snapshot rpool/local/home@blank - ''; - }; - "darlings/persist" = dataset { mountpoint = "/persist"; }; - "darlings/home" = dataset { - mountpoint = "/persist/home"; - }; - "reserved" = dataset { - options = { - canmount = "off"; - mountpoint = "none"; - reservation = "5GiB"; - }; - }; - }; - }; - }; }; - - fileSystems."/persist".neededForBoot = true; }