servo: relocate ext device to /mnt/impermanence/ext and fixup deps

This commit is contained in:
2023-01-04 12:12:30 +00:00
parent 2ba6116f10
commit 3db388b105
4 changed files with 15 additions and 9 deletions

View File

@@ -27,7 +27,7 @@
}; };
# slow, external storage (for archiving, etc) # slow, external storage (for archiving, etc)
fileSystems."/nix/persist/ext" = { fileSystems."/mnt/impermanence/ext" = {
device = "/dev/disk/by-uuid/aa272cff-0fcc-498e-a4cb-0d95fb60631b"; device = "/dev/disk/by-uuid/aa272cff-0fcc-498e-a4cb-0d95fb60631b";
fsType = "btrfs"; fsType = "btrfs";
options = [ options = [
@@ -37,9 +37,10 @@
}; };
sane.impermanence.stores."ext" = { sane.impermanence.stores."ext" = {
mountpt = "/nix/persist/ext/persist"; mountpt = "/mnt/impermanence/ext/persist";
storeDescription = "external HDD storage"; storeDescription = "external HDD storage";
}; };
sane.fs."/mnt/impermanence/ext".mount = {};
sane.impermanence.dirs.sys.plaintext = [ sane.impermanence.dirs.sys.plaintext = [
# TODO: this is overly broad; only need media and share directories to be persisted # TODO: this is overly broad; only need media and share directories to be persisted

View File

@@ -195,6 +195,13 @@ let
underlying = cfg."${device}"; underlying = cfg."${device}";
isBind = opt.mount.bind != null; isBind = opt.mount.bind != null;
ifBind = lib.mkIf isBind; 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 { in {
fileSystems."${path}" = { fileSystems."${path}" = {
device = ifBind opt.mount.bind; device = ifBind opt.mount.bind;
@@ -206,13 +213,8 @@ let
"nofail" "nofail"
# x-systemd options documented here: # x-systemd options documented here:
# - <https://www.freedesktop.org/software/systemd/man/systemd.mount.html> # - <https://www.freedesktop.org/software/systemd/man/systemd.mount.html>
# 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.before=${unit}") opt.wantedBeforeBy)
++ (builtins.map (unit: "x-systemd.wanted-by=${unit}") (opt.wantedBy ++ opt.wantedBeforeBy)); ++ (builtins.map (unit: "x-systemd.wanted-by=${unit}") (opt.wantedBy ++ opt.wantedBeforeBy));
noCheck = ifBind true; noCheck = ifBind true;

View File

@@ -6,4 +6,6 @@ in lib.mkIf cfg.enable {
sane.impermanence.stores."plaintext" = { sane.impermanence.stores."plaintext" = {
mountpt = "/nix/persist"; mountpt = "/nix/persist";
}; };
# TODO: needed?
# sane.fs."/nix".mount = {};
} }

View File

@@ -37,8 +37,9 @@ lib.mkIf config.sane.impermanence.enable
noCheck = true; noCheck = true;
}; };
# let sane.fs know about the endpoints # let sane.fs know about the mount
sane.fs."/home/colin/private".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 = {}; sane.fs."/nix/persist/home/colin/private".dir = {};
# TODO: could add this *specifically* to the .mount file for the encrypted fs? # TODO: could add this *specifically* to the .mount file for the encrypted fs?