mirror of
https://github.com/nix-community/home-manager
synced 2024-12-25 03:09:47 +01:00
systemd: add enable
option
This commit is contained in:
parent
1c43dcfac4
commit
fa8c16e245
1 changed files with 13 additions and 3 deletions
|
@ -5,8 +5,8 @@ let
|
||||||
cfg = config.systemd.user;
|
cfg = config.systemd.user;
|
||||||
|
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
any attrValues getAttr hm isBool literalExpression mkIf mkMerge mkOption
|
any attrValues getAttr hm isBool literalExpression mkIf mkMerge
|
||||||
types;
|
mkEnableOption mkOption types;
|
||||||
|
|
||||||
settingsFormat = pkgs.formats.ini { listsAsDuplicateKeys = true; };
|
settingsFormat = pkgs.formats.ini { listsAsDuplicateKeys = true; };
|
||||||
|
|
||||||
|
@ -105,6 +105,11 @@ in {
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
systemd.user = {
|
systemd.user = {
|
||||||
|
enable = mkEnableOption "the user systemd service manager" // {
|
||||||
|
default = pkgs.stdenv.isLinux;
|
||||||
|
defaultText = literalExpression "pkgs.stdenv.isLinux";
|
||||||
|
};
|
||||||
|
|
||||||
systemctlPath = mkOption {
|
systemctlPath = mkOption {
|
||||||
default = "${pkgs.systemd}/bin/systemctl";
|
default = "${pkgs.systemd}/bin/systemctl";
|
||||||
defaultText = literalExpression ''"''${pkgs.systemd}/bin/systemctl"'';
|
defaultText = literalExpression ''"''${pkgs.systemd}/bin/systemctl"'';
|
||||||
|
@ -286,7 +291,12 @@ in {
|
||||||
# If we run under a Linux system we assume that systemd is
|
# If we run under a Linux system we assume that systemd is
|
||||||
# available, in particular we assume that systemctl is in PATH.
|
# available, in particular we assume that systemctl is in PATH.
|
||||||
# Do not install any user services if username is root.
|
# Do not install any user services if username is root.
|
||||||
config = mkIf (pkgs.stdenv.isLinux && config.home.username != "root") {
|
config = mkIf (cfg.enable && config.home.username != "root") {
|
||||||
|
assertions = [{
|
||||||
|
assertion = pkgs.stdenv.isLinux;
|
||||||
|
message = "This module is only available on Linux.";
|
||||||
|
}];
|
||||||
|
|
||||||
xdg.configFile = mkMerge [
|
xdg.configFile = mkMerge [
|
||||||
(lib.listToAttrs ((buildServices "service" cfg.services)
|
(lib.listToAttrs ((buildServices "service" cfg.services)
|
||||||
++ (buildServices "slice" cfg.slices)
|
++ (buildServices "slice" cfg.slices)
|
||||||
|
|
Loading…
Reference in a new issue