servo: slim dependencies so that local-fs.target can be reached even if my media drives are inaccessible
this means some services which need access (like sftpgo) fail to start if the drive is unavailable
This commit is contained in:
@@ -30,20 +30,30 @@
|
||||
};
|
||||
|
||||
fileSystems."/mnt/pool" = {
|
||||
device = "/dev/disk/by-partuuid/14a7d00a-be53-2b4e-96f9-7e2c964674ec";
|
||||
# all btrfs devices of the same RAID volume use the same UUID.
|
||||
device = "UUID=40fc6e1d-ba41-44de-bbf3-1aa02c3441df";
|
||||
fsType = "btrfs";
|
||||
options = [
|
||||
# "compress=zstd" #< not much point in compressing... mostly videos and music; media.
|
||||
"defaults"
|
||||
# "device=/dev/disk/by-partuuid/14a7d00a-be53-2b4e-96f9-7e2c964674ec"
|
||||
# `device=...` only needed if `btrfs scan` hasn't yet been run
|
||||
# see: <https://askubuntu.com/a/484374>
|
||||
# i don't know what guarantees NixOS/systemd make about that, so specifying all devices for now
|
||||
"device=/dev/disk/by-partuuid/14a7d00a-be53-2b4e-96f9-7e2c964674ec"
|
||||
"device=/dev/disk/by-partuuid/6b86cc10-c3cc-ec4d-b20d-b6688f0959a6"
|
||||
"device=/dev/disk/by-partuuid/7fd85cac-b6f3-8248-af4e-68e703d11020"
|
||||
"device=/dev/disk/by-partuuid/ef0e5c7b-fccf-f444-bac4-534424326159"
|
||||
"nofail"
|
||||
"x-systemd.before=local-fs.target"
|
||||
"x-systemd.device-bound=false" #< don't unmount when `device` disappears
|
||||
"x-systemd.device-timeout=60s"
|
||||
"x-systemd.mount-timeout=60s"
|
||||
];
|
||||
};
|
||||
|
||||
# TODO: move this elsewhere and automate the ACLs!
|
||||
# FIRST TIME SETUP FOR MEDIA DIRECTORY:
|
||||
# - set the group stick bit: `sudo find /var/media -type d -exec chmod g+s {} +`
|
||||
# - set the group sticky bit: `sudo find /var/media -type d -exec chmod g+s {} +`
|
||||
# - this ensures new files/dirs inherit the group of their parent dir (instead of the user who creates them)
|
||||
# - ensure everything under /var/media is mounted with `-o acl`, to support acls
|
||||
# - ensure all files are rwx by group: `setfacl --recursive --modify d:g::rwx /var/media`
|
||||
@@ -66,7 +76,6 @@
|
||||
sane.fs."/var/media/Books/Books".dir = {};
|
||||
sane.fs."/var/media/Books/Visual".dir = {};
|
||||
sane.fs."/var/media/collections".dir = {};
|
||||
# sane.fs."/var/media/datasets".dir = {};
|
||||
sane.fs."/var/media/freeleech".dir = {};
|
||||
sane.fs."/var/media/Music".dir = {};
|
||||
sane.fs."/var/media/Pictures".dir = {};
|
||||
@@ -75,13 +84,6 @@
|
||||
sane.fs."/var/media/Videos/Shows".dir = {};
|
||||
sane.fs."/var/media/Videos/Talks".dir = {};
|
||||
|
||||
# this is file.text instead of symlink.text so that it may be read over a remote mount (where consumers might not have any /nix/store/.../README.md path)
|
||||
sane.fs."/var/lib/uninsane/datasets/README.md".file.text = ''
|
||||
this directory may seem redundant with ../media/datasets. it isn't.
|
||||
this directory exists on SSD, allowing for speedy access to specific datasets when necessary.
|
||||
the contents should be a subset of what's in ../media/datasets.
|
||||
'';
|
||||
|
||||
systemd.services.dedupe-media = {
|
||||
description = "transparently de-duplicate /var/media entries by using block-level hardlinks";
|
||||
script = ''
|
||||
|
@@ -10,7 +10,7 @@
|
||||
fileSystems."/var/export/media" = {
|
||||
# everything in here could be considered publicly readable (based on the viewer's legal jurisdiction)
|
||||
device = "/var/media";
|
||||
options = [ "rbind" ];
|
||||
options = [ "rbind" "nofail" ];
|
||||
};
|
||||
# fileSystems."/var/export/playground" = {
|
||||
# device = config.fileSystems."/mnt/persist/ext".device;
|
||||
|
@@ -158,14 +158,15 @@ in
|
||||
];
|
||||
|
||||
systemd.services.sftpgo = {
|
||||
after = [ "network-online.target" ];
|
||||
after = [ "network-online.target" ]; #< so that it reliably binds to all interfaces/netns's?
|
||||
wants = [ "network-online.target" ];
|
||||
serviceConfig = {
|
||||
ReadWritePaths = [ "/var/export" ];
|
||||
|
||||
Restart = "always";
|
||||
RestartSec = "20s";
|
||||
UMask = lib.mkForce "0002";
|
||||
};
|
||||
unitConfig.RequiresMountsFor = [
|
||||
"/var/export/media"
|
||||
"/var/export/playground"
|
||||
];
|
||||
serviceConfig.ReadWritePaths = [ "/var/export" ];
|
||||
serviceConfig.Restart = "always";
|
||||
serviceConfig.RestartSec = "20s";
|
||||
serviceConfig.UMask = lib.mkForce "0002";
|
||||
};
|
||||
}
|
||||
|
@@ -139,20 +139,26 @@ let
|
||||
options = [
|
||||
"bind"
|
||||
# noauto: removes implicit `WantedBy=local-fs.target`
|
||||
# nofail: removes implicit `Before=local-fs.target`
|
||||
# because e.g. private data may not be available before local-fs
|
||||
# nofail: removes implicit `Before=local-fs.target` and turns `RequiredBy=local-fs.target` into `WantedBy=local-fs.target`.
|
||||
# note that some services will try to write under the mountpoint without declaring `RequiresMountsFor=` on us.
|
||||
# systemd-tmpfiles.service is one such example.
|
||||
# so, we *prefer* to be ordered before `local-fs.target` (since everything pulls that in),
|
||||
# but we generally don't want to *fail* `local-fs.target`, since that breaks everything, even `ssh`
|
||||
# "noauto"
|
||||
"nofail"
|
||||
# x-systemd options documented here:
|
||||
# - <https://www.freedesktop.org/software/systemd/man/systemd.mount.html>
|
||||
"x-systemd.before=local-fs.target"
|
||||
];
|
||||
noCheck = true;
|
||||
};
|
||||
# specify `systemd.mounts` because otherwise systemd doesn't seem to pick up my `x-systemd` fs options?
|
||||
systemd.mounts = [{
|
||||
where = path;
|
||||
what = if fsEntry.device != null then fsEntry.device else "";
|
||||
type = fsEntry.fsType;
|
||||
options = lib.concatStringsSep "," fsEntry.options;
|
||||
before = [ "local-fs.target" ];
|
||||
}];
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user