From 3db388b105b4691ee034d63f05789df424f4e4a0 Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 4 Jan 2023 12:12:30 +0000 Subject: [PATCH] servo: relocate `ext` device to /mnt/impermanence/ext and fixup deps --- hosts/servo/fs.nix | 5 +++-- modules/fs/default.nix | 14 ++++++++------ modules/impermanence/stores/plaintext.nix | 2 ++ modules/impermanence/stores/private.nix | 3 ++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/hosts/servo/fs.nix b/hosts/servo/fs.nix index 0b0d5d04..4d7cfa52 100644 --- a/hosts/servo/fs.nix +++ b/hosts/servo/fs.nix @@ -27,7 +27,7 @@ }; # slow, external storage (for archiving, etc) - fileSystems."/nix/persist/ext" = { + fileSystems."/mnt/impermanence/ext" = { device = "/dev/disk/by-uuid/aa272cff-0fcc-498e-a4cb-0d95fb60631b"; fsType = "btrfs"; options = [ @@ -37,9 +37,10 @@ }; sane.impermanence.stores."ext" = { - mountpt = "/nix/persist/ext/persist"; + mountpt = "/mnt/impermanence/ext/persist"; storeDescription = "external HDD storage"; }; + sane.fs."/mnt/impermanence/ext".mount = {}; sane.impermanence.dirs.sys.plaintext = [ # TODO: this is overly broad; only need media and share directories to be persisted diff --git a/modules/fs/default.nix b/modules/fs/default.nix index 4aa869dd..20d1ce98 100644 --- a/modules/fs/default.nix +++ b/modules/fs/default.nix @@ -195,6 +195,13 @@ let underlying = cfg."${device}"; isBind = opt.mount.bind != null; ifBind = lib.mkIf isBind; + # before mounting: + # - create the target directory + # - prepare the source directory -- assuming it's not an external device + # - satisfy any user-specified prerequisites ("depends") + requires = [ opt.generated.unit ] + ++ (if lib.hasPrefix "/dev/disk/" device then [] else [ underlying.unit ]) + ++ opt.mount.depends; in { fileSystems."${path}" = { device = ifBind opt.mount.bind; @@ -206,13 +213,8 @@ let "nofail" # x-systemd options documented here: # - - # we can't mount this until after the underlying path is prepared. - # if the underlying path disappears, this mount will be stopped. - "x-systemd.requires=${underlying.unit}" - # the mount depends on its target directory being prepared - "x-systemd.requires=${opt.generated.unit}" ] - ++ (builtins.map (unit: "x-systemd.requires=${unit}") opt.mount.depends) + ++ (builtins.map (unit: "x-systemd.requires=${unit}") requires) ++ (builtins.map (unit: "x-systemd.before=${unit}") opt.wantedBeforeBy) ++ (builtins.map (unit: "x-systemd.wanted-by=${unit}") (opt.wantedBy ++ opt.wantedBeforeBy)); noCheck = ifBind true; diff --git a/modules/impermanence/stores/plaintext.nix b/modules/impermanence/stores/plaintext.nix index 0be289b2..5a74f6e6 100644 --- a/modules/impermanence/stores/plaintext.nix +++ b/modules/impermanence/stores/plaintext.nix @@ -6,4 +6,6 @@ in lib.mkIf cfg.enable { sane.impermanence.stores."plaintext" = { mountpt = "/nix/persist"; }; + # TODO: needed? + # sane.fs."/nix".mount = {}; } diff --git a/modules/impermanence/stores/private.nix b/modules/impermanence/stores/private.nix index 33213579..cb9d37aa 100644 --- a/modules/impermanence/stores/private.nix +++ b/modules/impermanence/stores/private.nix @@ -37,8 +37,9 @@ lib.mkIf config.sane.impermanence.enable noCheck = true; }; - # let sane.fs know about the endpoints + # let sane.fs know about the mount sane.fs."/home/colin/private".mount = {}; + # it also needs to know that the underlying device is an ordinary folder sane.fs."/nix/persist/home/colin/private".dir = {}; # TODO: could add this *specifically* to the .mount file for the encrypted fs?