-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds systemd services configuration through hjem, under `users.<username>.systemd.services`.
- Loading branch information
Showing
2 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
lib, | ||
pkgs, | ||
systemConfig, | ||
config, | ||
... | ||
}: let | ||
inherit (lib.attrsets) nameValuePair mapAttrs'; | ||
inherit (lib.options) mkOption; | ||
|
||
utils = import "${pkgs.path}/nixos/lib/utils.nix" { | ||
inherit lib pkgs; | ||
config = systemConfig; | ||
}; | ||
|
||
inherit (utils) systemdUtils; | ||
inherit (systemdUtils.lib) generateUnits serviceToUnit; | ||
|
||
cfg = config.systemd; | ||
in { | ||
options.systemd = { | ||
services = mkOption { | ||
default = {}; | ||
type = systemdUtils.types.services; | ||
description = "Definition of systemd per-user service units."; | ||
}; | ||
units = mkOption { | ||
description = "Definition of systemd per-user units."; | ||
default = {}; | ||
type = systemdUtils.types.units; | ||
}; | ||
}; | ||
|
||
config = { | ||
systemd.units = mapAttrs' (n: v: nameValuePair "${n}.service" (serviceToUnit v)) cfg.services; | ||
files.".config/systemd/user".source = generateUnits { | ||
type = "user"; | ||
inherit (cfg) units; | ||
upstreamUnits = []; # this is already done in the NixOS module | ||
upstreamWants = []; # same here | ||
packages = []; # unnecessary, we're using `generateUnits` at user level (no need for hooks or units for now) | ||
inherit (systemConfig.systemd) package; | ||
}; | ||
}; | ||
} |