···33 ...
44}:
55{
66+ # generateUnitFiles creates a derivatioon with systemd units
77+ # using the nixos module structure, but intended for using in
88+ # a sower service along with sowerServicesHook
69 flake.lib.generateUnitFiles =
710 {
811 pkgs,
···5659 # TODO type this
5760 };
58616262+ # copy the options structure out of nixpkgs, or a subset anyway
6363+ # unfortunately this isn't exposed in a consumable way in nixpkgs
5964 systemd = {
6065 package = mkPackageOption pkgs "systemd" { };
6166···169174 };
170175171176 config = {
177177+ # the bare minimum to init the necessary config, and merge all the units together
178178+ # for consumption by generateUnits
172179 systemd = {
173180 package = pkgs.systemd;
174181 defaultUnit = "default.target";
···217224 in
218225 {
219226 config = {
227227+ # build the combined units into a package, and expose
228228+ # then in a module option for consumption
220229 service-units = pkgs.runCommand "service-units" { } ''
221221- cp -R ${system-units} $out
230230+ cp --recursive ${system-units} $out
222231 chmod +w -R $out
232232+ # delete any broken links
223233 find $out -xtype l -delete
234234+ # delete empty directories
224235 find $out -type d -empty -delete
236236+ # remove the upstream targets
225237 for unit in ${builtins.toString upstreamUnits}; do
226238 rm $out/$unit
227239 done
···230242 }
231243 )
232244 {
245245+ # pass on the config from generateUnitFiles
233246 systemd = config;
234247 }
235248 ];
···237250 };
238251239252 in
253253+ # return back the units, aka the package with them
240254 moduler.config.service-units;
241255}