sane.fs: make bind a required sub-option of mount

This commit is contained in:
2024-09-30 10:09:29 +00:00
parent e52f57f5a2
commit ca85dac4ac

View File

@@ -135,7 +135,7 @@ let
mountEntryFor = path: types.submodule { mountEntryFor = path: types.submodule {
options = { options = {
bind = mkOption { bind = mkOption {
type = types.nullOr types.str; type = types.str;
description = "fs path to bind-mount from"; description = "fs path to bind-mount from";
default = null; default = null;
}; };
@@ -159,22 +159,20 @@ let
# given a mountEntry definition, evaluate its toplevel `config` output. # given a mountEntry definition, evaluate its toplevel `config` output.
mkMountConfig = path: opt: let mkMountConfig = path: opt: let
fsEntry = config.fileSystems."${path}"; fsEntry = config.fileSystems."${path}";
isBind = opt.mount.bind != null;
ifBind = lib.mkIf isBind;
in { in {
fileSystems."${path}" = { fileSystems."${path}" = {
device = ifBind opt.mount.bind; device = opt.mount.bind;
options = (lib.optionals isBind [ "bind" ]) options = [
++ [ "bind"
# noauto: removes implicit `WantedBy=local-fs.target` # noauto: removes implicit `WantedBy=local-fs.target`
# nofail: removes implicit `Before=local-fs.target` # nofail: removes implicit `Before=local-fs.target`
# because e.g. private data may not be available before local-fs # because e.g. private data may not be available before local-fs
# "noauto" # "noauto"
"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>
]; ];
noCheck = ifBind true; noCheck = true;
}; };
systemd.mounts = [{ systemd.mounts = [{
where = path; where = path;