improve installation, add support for:
ZFS, encryption (keys, keystore, LUKS), bootFS, ephemeral root (tmpfs, ZFS, F2FS, ...), testing in qemu, options & debugging, ... and many small things
2022-05-31 03:41:28 +02:00
|
|
|
/*
|
|
|
|
|
|
|
|
# FS Nixpkgs "Patches"
|
|
|
|
|
|
|
|
Filesystem related "patches" of options in nixpkgs, i.e. additions of options that are *not* prefixed.
|
|
|
|
|
|
|
|
|
|
|
|
## Implementation
|
|
|
|
|
|
|
|
```nix
|
|
|
|
#*/# end of MarkDown, beginning of NixOS module:
|
2022-06-28 05:00:48 +02:00
|
|
|
dirname: inputs: specialArgs@{ config, pkgs, lib, utils, ... }: let inherit (inputs.self) lib; in let
|
improve installation, add support for:
ZFS, encryption (keys, keystore, LUKS), bootFS, ephemeral root (tmpfs, ZFS, F2FS, ...), testing in qemu, options & debugging, ... and many small things
2022-05-31 03:41:28 +02:00
|
|
|
in {
|
|
|
|
|
|
|
|
options = {
|
|
|
|
fileSystems = lib.mkOption { type = lib.types.attrsOf (lib.types.submodule [ { options = {
|
|
|
|
preMountCommands = lib.mkOption { description = ""; type = lib.types.nullOr lib.types.str; default = null; };
|
|
|
|
}; } ]);
|
|
|
|
}; };
|
|
|
|
|
|
|
|
config = let
|
|
|
|
in ({
|
|
|
|
|
2022-06-04 20:54:09 +02:00
|
|
|
systemd.services = lib.wip.mapMerge (target: { device, preMountCommands, depends, ... }: if (preMountCommands != null) then let
|
improve installation, add support for:
ZFS, encryption (keys, keystore, LUKS), bootFS, ephemeral root (tmpfs, ZFS, F2FS, ...), testing in qemu, options & debugging, ... and many small things
2022-05-31 03:41:28 +02:00
|
|
|
isDevice = lib.wip.startsWith "/dev/" device;
|
|
|
|
target' = utils.escapeSystemdPath target;
|
|
|
|
device' = utils.escapeSystemdPath device;
|
|
|
|
in { "pre-mount-${target'}" = {
|
|
|
|
description = "Prepare mounting (to) ${target}";
|
2022-06-04 20:54:09 +02:00
|
|
|
wantedBy = [ "${target'}.mount" ]; before = [ "${target'}.mount" ]
|
|
|
|
++ (lib.optional isDevice "systemd-fsck@${device'}.service"); # TODO: Does this exist for every device? Does depending on it instantiate the template?
|
improve installation, add support for:
ZFS, encryption (keys, keystore, LUKS), bootFS, ephemeral root (tmpfs, ZFS, F2FS, ...), testing in qemu, options & debugging, ... and many small things
2022-05-31 03:41:28 +02:00
|
|
|
requires = lib.optional isDevice "${device'}.device"; after = lib.optional isDevice "${device'}.device";
|
2022-06-04 20:54:09 +02:00
|
|
|
unitConfig.RequiresMountsFor = depends ++ [ (builtins.dirOf device) (builtins.dirOf target) ];
|
improve installation, add support for:
ZFS, encryption (keys, keystore, LUKS), bootFS, ephemeral root (tmpfs, ZFS, F2FS, ...), testing in qemu, options & debugging, ... and many small things
2022-05-31 03:41:28 +02:00
|
|
|
unitConfig.DefaultDependencies = false;
|
|
|
|
serviceConfig.Type = "oneshot"; script = preMountCommands;
|
|
|
|
}; } else { }) config.fileSystems;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|