2022-04-24 20:47:28 +02:00
|
|
|
{ lib, systemdUtils, pkgs }:
|
2022-03-19 09:02:39 +01:00
|
|
|
|
2024-03-28 05:56:52 +01:00
|
|
|
let
|
|
|
|
inherit (systemdUtils.lib)
|
|
|
|
automountConfig
|
|
|
|
makeUnit
|
|
|
|
mountConfig
|
|
|
|
stage1ServiceConfig
|
|
|
|
stage2ServiceConfig
|
|
|
|
unitConfig
|
|
|
|
;
|
|
|
|
|
|
|
|
inherit (systemdUtils.unitOptions)
|
|
|
|
concreteUnitOptions
|
|
|
|
stage1AutomountOptions
|
|
|
|
stage1CommonUnitOptions
|
|
|
|
stage1MountOptions
|
|
|
|
stage1PathOptions
|
|
|
|
stage1ServiceOptions
|
|
|
|
stage1SliceOptions
|
|
|
|
stage1SocketOptions
|
|
|
|
stage1TimerOptions
|
|
|
|
stage2AutomountOptions
|
|
|
|
stage2CommonUnitOptions
|
|
|
|
stage2MountOptions
|
|
|
|
stage2PathOptions
|
|
|
|
stage2ServiceOptions
|
|
|
|
stage2SliceOptions
|
|
|
|
stage2SocketOptions
|
|
|
|
stage2TimerOptions
|
|
|
|
;
|
|
|
|
|
|
|
|
inherit (lib)
|
|
|
|
mkDefault
|
|
|
|
mkDerivedConfig
|
|
|
|
mkEnableOption
|
|
|
|
mkIf
|
|
|
|
mkOption
|
|
|
|
;
|
|
|
|
|
|
|
|
inherit (lib.types)
|
|
|
|
attrsOf
|
|
|
|
lines
|
|
|
|
listOf
|
|
|
|
nullOr
|
|
|
|
path
|
|
|
|
submodule
|
|
|
|
;
|
|
|
|
in
|
2022-03-19 09:02:39 +01:00
|
|
|
|
|
|
|
rec {
|
2024-03-28 05:56:52 +01:00
|
|
|
units = attrsOf (submodule ({ name, config, ... }: {
|
|
|
|
options = concreteUnitOptions;
|
|
|
|
config = { unit = mkDefault (makeUnit name config); };
|
|
|
|
}));
|
2022-03-19 09:02:39 +01:00
|
|
|
|
2024-03-28 05:56:52 +01:00
|
|
|
services = attrsOf (submodule [ stage2ServiceOptions unitConfig stage2ServiceConfig ]);
|
|
|
|
initrdServices = attrsOf (submodule [ stage1ServiceOptions unitConfig stage1ServiceConfig ]);
|
2022-03-19 09:02:39 +01:00
|
|
|
|
2024-03-28 05:56:52 +01:00
|
|
|
targets = attrsOf (submodule [ stage2CommonUnitOptions unitConfig ]);
|
|
|
|
initrdTargets = attrsOf (submodule [ stage1CommonUnitOptions unitConfig ]);
|
2022-03-19 09:02:39 +01:00
|
|
|
|
2024-03-28 05:56:52 +01:00
|
|
|
sockets = attrsOf (submodule [ stage2SocketOptions unitConfig ]);
|
|
|
|
initrdSockets = attrsOf (submodule [ stage1SocketOptions unitConfig ]);
|
2022-03-19 09:02:39 +01:00
|
|
|
|
2024-03-28 05:56:52 +01:00
|
|
|
timers = attrsOf (submodule [ stage2TimerOptions unitConfig ]);
|
|
|
|
initrdTimers = attrsOf (submodule [ stage1TimerOptions unitConfig ]);
|
2022-03-19 09:02:39 +01:00
|
|
|
|
2024-03-28 05:56:52 +01:00
|
|
|
paths = attrsOf (submodule [ stage2PathOptions unitConfig ]);
|
|
|
|
initrdPaths = attrsOf (submodule [ stage1PathOptions unitConfig ]);
|
2022-03-19 09:02:39 +01:00
|
|
|
|
2024-03-28 05:56:52 +01:00
|
|
|
slices = attrsOf (submodule [ stage2SliceOptions unitConfig ]);
|
|
|
|
initrdSlices = attrsOf (submodule [ stage1SliceOptions unitConfig ]);
|
2022-03-19 09:02:39 +01:00
|
|
|
|
2024-03-28 05:56:52 +01:00
|
|
|
mounts = listOf (submodule [ stage2MountOptions unitConfig mountConfig ]);
|
|
|
|
initrdMounts = listOf (submodule [ stage1MountOptions unitConfig mountConfig ]);
|
2022-03-19 09:02:39 +01:00
|
|
|
|
2024-03-28 05:56:52 +01:00
|
|
|
automounts = listOf (submodule [ stage2AutomountOptions unitConfig automountConfig ]);
|
|
|
|
initrdAutomounts = attrsOf (submodule [ stage1AutomountOptions unitConfig automountConfig ]);
|
2022-04-24 20:47:28 +02:00
|
|
|
|
2024-03-28 05:56:52 +01:00
|
|
|
initrdContents = attrsOf (submodule ({ config, options, name, ... }: {
|
2022-04-24 20:47:28 +02:00
|
|
|
options = {
|
2024-04-02 01:58:23 +02:00
|
|
|
enable = (mkEnableOption "copying of this file and symlinking it") // { default = true; };
|
2022-04-24 20:47:28 +02:00
|
|
|
|
|
|
|
target = mkOption {
|
2024-03-28 05:56:52 +01:00
|
|
|
type = path;
|
2024-04-02 01:58:23 +02:00
|
|
|
description = ''
|
2022-04-24 20:47:28 +02:00
|
|
|
Path of the symlink.
|
|
|
|
'';
|
|
|
|
default = name;
|
|
|
|
};
|
|
|
|
|
|
|
|
text = mkOption {
|
|
|
|
default = null;
|
2024-03-28 05:56:52 +01:00
|
|
|
type = nullOr lines;
|
2024-04-02 01:58:23 +02:00
|
|
|
description = "Text of the file.";
|
2022-04-24 20:47:28 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
source = mkOption {
|
2024-03-28 05:56:52 +01:00
|
|
|
type = path;
|
2024-04-02 01:58:23 +02:00
|
|
|
description = "Path of the source file.";
|
2022-04-24 20:47:28 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
source = mkIf (config.text != null) (
|
|
|
|
let name' = "initrd-" + baseNameOf name;
|
|
|
|
in mkDerivedConfig options.text (pkgs.writeText name')
|
|
|
|
);
|
|
|
|
};
|
|
|
|
}));
|
2022-03-19 09:02:39 +01:00
|
|
|
}
|