2022-04-24 14:47:28 -04:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
systemdUtils,
|
|
|
|
pkgs,
|
|
|
|
}:
|
2022-03-19 04:02:39 -04:00
|
|
|
|
2024-03-27 21:56:52 -07:00
|
|
|
let
|
|
|
|
inherit (systemdUtils.lib)
|
|
|
|
automountConfig
|
|
|
|
makeUnit
|
|
|
|
mountConfig
|
2024-03-21 14:52:12 +01:00
|
|
|
pathConfig
|
|
|
|
sliceConfig
|
|
|
|
socketConfig
|
2024-03-27 21:56:52 -07:00
|
|
|
stage1ServiceConfig
|
|
|
|
stage2ServiceConfig
|
2024-03-21 14:52:12 +01:00
|
|
|
targetConfig
|
|
|
|
timerConfig
|
2024-03-27 21:56:52 -07:00
|
|
|
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
|
2024-06-26 20:22:42 -04:00
|
|
|
coercedTo
|
2024-06-27 04:21:11 -04:00
|
|
|
enum
|
2024-03-27 21:56:52 -07:00
|
|
|
lines
|
|
|
|
listOf
|
|
|
|
nullOr
|
2024-06-26 20:22:42 -04:00
|
|
|
oneOf
|
|
|
|
package
|
2024-03-27 21:56:52 -07:00
|
|
|
path
|
2024-06-27 04:21:11 -04:00
|
|
|
singleLineStr
|
2024-03-27 21:56:52 -07:00
|
|
|
submodule
|
|
|
|
;
|
2024-06-26 20:22:42 -04:00
|
|
|
|
|
|
|
initrdStorePathModule =
|
|
|
|
{ config, ... }:
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
enable = (mkEnableOption "copying of this file and symlinking it") // {
|
|
|
|
default = true;
|
|
|
|
};
|
2024-06-27 04:21:11 -04:00
|
|
|
|
|
|
|
target = mkOption {
|
|
|
|
type = nullOr path;
|
|
|
|
description = ''
|
|
|
|
Path of the symlink.
|
|
|
|
'';
|
2024-06-26 20:22:42 -04:00
|
|
|
default = null;
|
2024-06-27 04:21:11 -04:00
|
|
|
};
|
|
|
|
|
2024-06-26 20:22:42 -04:00
|
|
|
source = mkOption {
|
|
|
|
type = path;
|
|
|
|
description = "Path of the source file.";
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
|
|
|
|
2024-06-27 04:21:11 -04:00
|
|
|
dlopen = {
|
2024-06-26 20:22:42 -04:00
|
|
|
usePriority = mkOption {
|
2024-12-10 20:26:33 +01:00
|
|
|
type = enum [
|
2024-06-27 04:21:11 -04:00
|
|
|
"required"
|
|
|
|
"recommended"
|
|
|
|
"suggested"
|
2024-12-10 20:26:33 +01:00
|
|
|
];
|
2024-06-27 04:21:11 -04:00
|
|
|
default = "recommended";
|
|
|
|
description = ''
|
|
|
|
Priority of dlopen ELF notes to include. "required" is
|
|
|
|
minimal, "recommended" includes "required", and
|
|
|
|
"suggested" includes "recommended".
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2024-06-27 04:21:11 -04:00
|
|
|
See: https://systemd.io/ELF_DLOPEN_METADATA/
|
2024-12-10 20:26:33 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-06-27 04:21:11 -04:00
|
|
|
features = mkOption {
|
|
|
|
type = listOf singleLineStr;
|
|
|
|
default = [ ];
|
|
|
|
description = ''
|
|
|
|
Features to enable via dlopen ELF notes. These will be in
|
|
|
|
addition to anything included via 'usePriority',
|
|
|
|
regardless of their priority.
|
|
|
|
'';
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
2024-06-27 04:21:11 -04:00
|
|
|
};
|
|
|
|
};
|
2024-06-26 20:22:42 -04:00
|
|
|
};
|
|
|
|
|
2024-03-27 21:56:52 -07:00
|
|
|
in
|
2022-03-19 04:02:39 -04:00
|
|
|
|
2024-03-21 14:52:12 +01:00
|
|
|
{
|
2024-03-27 21:56:52 -07:00
|
|
|
units = attrsOf (
|
|
|
|
submodule (
|
|
|
|
{ name, config, ... }:
|
|
|
|
{
|
|
|
|
options = concreteUnitOptions;
|
2024-03-21 14:52:12 +01:00
|
|
|
config = {
|
|
|
|
name = mkDefault name;
|
|
|
|
unit = mkDefault (makeUnit name config);
|
|
|
|
};
|
2024-03-27 21:56:52 -07:00
|
|
|
}
|
2024-12-10 20:26:33 +01:00
|
|
|
)
|
2024-03-27 21:56:52 -07:00
|
|
|
);
|
2022-03-19 04:02:39 -04:00
|
|
|
|
2024-03-27 21:56:52 -07:00
|
|
|
services = attrsOf (submodule [
|
|
|
|
stage2ServiceOptions
|
|
|
|
unitConfig
|
|
|
|
stage2ServiceConfig
|
|
|
|
]);
|
|
|
|
initrdServices = attrsOf (submodule [
|
|
|
|
stage1ServiceOptions
|
|
|
|
unitConfig
|
|
|
|
stage1ServiceConfig
|
|
|
|
]);
|
2022-03-19 04:02:39 -04:00
|
|
|
|
2024-03-21 14:52:12 +01:00
|
|
|
targets = attrsOf (submodule [
|
|
|
|
stage2CommonUnitOptions
|
|
|
|
unitConfig
|
|
|
|
targetConfig
|
|
|
|
]);
|
|
|
|
initrdTargets = attrsOf (submodule [
|
|
|
|
stage1CommonUnitOptions
|
|
|
|
unitConfig
|
|
|
|
targetConfig
|
|
|
|
]);
|
2022-03-19 04:02:39 -04:00
|
|
|
|
2024-03-21 14:52:12 +01:00
|
|
|
sockets = attrsOf (submodule [
|
|
|
|
stage2SocketOptions
|
|
|
|
unitConfig
|
|
|
|
socketConfig
|
|
|
|
]);
|
|
|
|
initrdSockets = attrsOf (submodule [
|
|
|
|
stage1SocketOptions
|
|
|
|
unitConfig
|
|
|
|
socketConfig
|
2024-12-10 20:26:33 +01:00
|
|
|
]);
|
2022-03-19 04:02:39 -04:00
|
|
|
|
2024-03-21 14:52:12 +01:00
|
|
|
timers = attrsOf (submodule [
|
|
|
|
stage2TimerOptions
|
|
|
|
unitConfig
|
|
|
|
timerConfig
|
|
|
|
]);
|
|
|
|
initrdTimers = attrsOf (submodule [
|
|
|
|
stage1TimerOptions
|
|
|
|
unitConfig
|
|
|
|
timerConfig
|
|
|
|
]);
|
2022-03-19 04:02:39 -04:00
|
|
|
|
2024-03-21 14:52:12 +01:00
|
|
|
paths = attrsOf (submodule [
|
|
|
|
stage2PathOptions
|
|
|
|
unitConfig
|
|
|
|
pathConfig
|
|
|
|
]);
|
|
|
|
initrdPaths = attrsOf (submodule [
|
|
|
|
stage1PathOptions
|
|
|
|
unitConfig
|
|
|
|
pathConfig
|
|
|
|
]);
|
2022-03-19 04:02:39 -04:00
|
|
|
|
2024-03-21 14:52:12 +01:00
|
|
|
slices = attrsOf (submodule [
|
|
|
|
stage2SliceOptions
|
|
|
|
unitConfig
|
|
|
|
sliceConfig
|
|
|
|
]);
|
|
|
|
initrdSlices = attrsOf (submodule [
|
|
|
|
stage1SliceOptions
|
|
|
|
unitConfig
|
|
|
|
sliceConfig
|
|
|
|
]);
|
2022-03-19 04:02:39 -04:00
|
|
|
|
2024-03-27 21:56:52 -07:00
|
|
|
mounts = listOf (submodule [
|
|
|
|
stage2MountOptions
|
|
|
|
unitConfig
|
|
|
|
mountConfig
|
|
|
|
]);
|
|
|
|
initrdMounts = listOf (submodule [
|
|
|
|
stage1MountOptions
|
|
|
|
unitConfig
|
|
|
|
mountConfig
|
|
|
|
]);
|
2022-03-19 04:02:39 -04:00
|
|
|
|
2024-03-27 21:56:52 -07:00
|
|
|
automounts = listOf (submodule [
|
|
|
|
stage2AutomountOptions
|
|
|
|
unitConfig
|
|
|
|
automountConfig
|
|
|
|
]);
|
|
|
|
initrdAutomounts = attrsOf (submodule [
|
|
|
|
stage1AutomountOptions
|
|
|
|
unitConfig
|
|
|
|
automountConfig
|
|
|
|
]);
|
2022-04-24 14:47:28 -04:00
|
|
|
|
2024-06-26 20:22:42 -04:00
|
|
|
initrdStorePath = listOf (
|
|
|
|
coercedTo (oneOf [
|
|
|
|
singleLineStr
|
|
|
|
package
|
|
|
|
]) (source: { inherit source; }) (submodule initrdStorePathModule)
|
|
|
|
);
|
|
|
|
|
2024-03-27 21:56:52 -07:00
|
|
|
initrdContents = attrsOf (
|
|
|
|
submodule (
|
|
|
|
{
|
|
|
|
config,
|
|
|
|
options,
|
|
|
|
name,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
{
|
2024-06-26 20:22:42 -04:00
|
|
|
imports = [ initrdStorePathModule ];
|
2022-04-24 14:47:28 -04:00
|
|
|
options = {
|
|
|
|
text = mkOption {
|
|
|
|
default = null;
|
2024-03-27 21:56:52 -07:00
|
|
|
type = nullOr lines;
|
2024-04-01 16:58:23 -07:00
|
|
|
description = "Text of the file.";
|
2022-04-24 14:47:28 -04:00
|
|
|
};
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
2022-04-24 14:47:28 -04:00
|
|
|
|
|
|
|
config = {
|
2024-06-26 20:22:42 -04:00
|
|
|
target = mkDefault name;
|
2022-04-24 14:47:28 -04:00
|
|
|
source = mkIf (config.text != null) (
|
|
|
|
let
|
|
|
|
name' = "initrd-" + baseNameOf name;
|
|
|
|
in
|
|
|
|
mkDerivedConfig options.text (pkgs.writeText name')
|
|
|
|
);
|
|
|
|
};
|
|
|
|
}
|
2024-12-10 20:26:33 +01:00
|
|
|
)
|
2022-04-24 14:47:28 -04:00
|
|
|
);
|
2022-03-19 04:02:39 -04:00
|
|
|
}
|