at 24.11-pre 3.3 kB view raw
1{ lib, systemdUtils, pkgs }: 2 3let 4 inherit (systemdUtils.lib) 5 automountConfig 6 makeUnit 7 mountConfig 8 pathConfig 9 sliceConfig 10 socketConfig 11 stage1ServiceConfig 12 stage2ServiceConfig 13 targetConfig 14 timerConfig 15 unitConfig 16 ; 17 18 inherit (systemdUtils.unitOptions) 19 concreteUnitOptions 20 stage1AutomountOptions 21 stage1CommonUnitOptions 22 stage1MountOptions 23 stage1PathOptions 24 stage1ServiceOptions 25 stage1SliceOptions 26 stage1SocketOptions 27 stage1TimerOptions 28 stage2AutomountOptions 29 stage2CommonUnitOptions 30 stage2MountOptions 31 stage2PathOptions 32 stage2ServiceOptions 33 stage2SliceOptions 34 stage2SocketOptions 35 stage2TimerOptions 36 ; 37 38 inherit (lib) 39 mkDefault 40 mkDerivedConfig 41 mkEnableOption 42 mkIf 43 mkOption 44 ; 45 46 inherit (lib.types) 47 attrsOf 48 lines 49 listOf 50 nullOr 51 path 52 submodule 53 ; 54in 55 56{ 57 units = attrsOf (submodule ({ name, config, ... }: { 58 options = concreteUnitOptions; 59 config = { 60 name = mkDefault name; 61 unit = mkDefault (makeUnit name config); 62 }; 63 })); 64 65 services = attrsOf (submodule [ stage2ServiceOptions unitConfig stage2ServiceConfig ]); 66 initrdServices = attrsOf (submodule [ stage1ServiceOptions unitConfig stage1ServiceConfig ]); 67 68 targets = attrsOf (submodule [ stage2CommonUnitOptions unitConfig targetConfig ]); 69 initrdTargets = attrsOf (submodule [ stage1CommonUnitOptions unitConfig targetConfig ]); 70 71 sockets = attrsOf (submodule [ stage2SocketOptions unitConfig socketConfig]); 72 initrdSockets = attrsOf (submodule [ stage1SocketOptions unitConfig socketConfig ]); 73 74 timers = attrsOf (submodule [ stage2TimerOptions unitConfig timerConfig ]); 75 initrdTimers = attrsOf (submodule [ stage1TimerOptions unitConfig timerConfig ]); 76 77 paths = attrsOf (submodule [ stage2PathOptions unitConfig pathConfig ]); 78 initrdPaths = attrsOf (submodule [ stage1PathOptions unitConfig pathConfig ]); 79 80 slices = attrsOf (submodule [ stage2SliceOptions unitConfig sliceConfig ]); 81 initrdSlices = attrsOf (submodule [ stage1SliceOptions unitConfig sliceConfig ]); 82 83 mounts = listOf (submodule [ stage2MountOptions unitConfig mountConfig ]); 84 initrdMounts = listOf (submodule [ stage1MountOptions unitConfig mountConfig ]); 85 86 automounts = listOf (submodule [ stage2AutomountOptions unitConfig automountConfig ]); 87 initrdAutomounts = attrsOf (submodule [ stage1AutomountOptions unitConfig automountConfig ]); 88 89 initrdContents = attrsOf (submodule ({ config, options, name, ... }: { 90 options = { 91 enable = (mkEnableOption "copying of this file and symlinking it") // { default = true; }; 92 93 target = mkOption { 94 type = path; 95 description = '' 96 Path of the symlink. 97 ''; 98 default = name; 99 }; 100 101 text = mkOption { 102 default = null; 103 type = nullOr lines; 104 description = "Text of the file."; 105 }; 106 107 source = mkOption { 108 type = path; 109 description = "Path of the source file."; 110 }; 111 }; 112 113 config = { 114 source = mkIf (config.text != null) ( 115 let name' = "initrd-" + baseNameOf name; 116 in mkDerivedConfig options.text (pkgs.writeText name') 117 ); 118 }; 119 })); 120}