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 = {
2022-12-27 15:37:27 +01:00
preMountCommands = lib.mkOption { description = "Commands to be run as root every time before mounting this filesystem, but after all its dependents were mounted (TODO: or does this run just once per boot?). This does not order itself before or after `systemd-fsck@\${utils.escapeSystemdPath device}.service` ."; type = lib.types.lines; default = ""; };
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
}; } ]);
}; };
config = let
in ({
2022-12-27 15:37:27 +01:00
# The implementation is derived from the "mkfs-${device'}" service in nixpkgs.
systemd.services = lib.wip.mapMergeUnique (_: { mountPoint, device, preMountCommands, depends, ... }: if (preMountCommands != "") 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;
2022-12-27 15:37:27 +01:00
mountPoint' = utils.escapeSystemdPath mountPoint;
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
device' = utils.escapeSystemdPath device;
2022-12-27 15:37:27 +01:00
in { "pre-mount-${mountPoint'}" = {
description = "Prepare mounting ${device} at ${mountPoint}";
wantedBy = [ "${mountPoint'}.mount" ]; before = [ "${mountPoint'}.mount" ];
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-12-27 15:37:27 +01:00
unitConfig.RequiresMountsFor = depends ++ [ (builtins.dirOf device) (builtins.dirOf mountPoint) ];
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;
});
}