nixos/domoticz: use DynamicUser and StateDirectory
This commit is contained in:
parent
c768364652
commit
4a3fe8d306
|
@ -14,31 +14,6 @@ in {
|
||||||
services.domoticz = {
|
services.domoticz = {
|
||||||
enable = mkEnableOption pkgDesc;
|
enable = mkEnableOption pkgDesc;
|
||||||
|
|
||||||
user = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "domoticz";
|
|
||||||
description = "domoticz user";
|
|
||||||
};
|
|
||||||
|
|
||||||
group = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "domoticz";
|
|
||||||
description = "domoticz group";
|
|
||||||
};
|
|
||||||
|
|
||||||
extraGroups = mkOption {
|
|
||||||
type = types.listOf types.str;
|
|
||||||
default = [ ];
|
|
||||||
description = "Extra groups to add to domoticz user";
|
|
||||||
};
|
|
||||||
|
|
||||||
stateDir = mkOption {
|
|
||||||
type = types.path;
|
|
||||||
default = "/var/lib/domoticz/";
|
|
||||||
description = "The state directory for domoticz";
|
|
||||||
example = "/home/bob/.domoticz/";
|
|
||||||
};
|
|
||||||
|
|
||||||
bind = mkOption {
|
bind = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "0.0.0.0";
|
default = "0.0.0.0";
|
||||||
|
@ -57,29 +32,16 @@ in {
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
users.users."domoticz" = {
|
|
||||||
name = cfg.user;
|
|
||||||
group = cfg.group;
|
|
||||||
extraGroups = cfg.extraGroups;
|
|
||||||
home = cfg.stateDir;
|
|
||||||
createHome = true;
|
|
||||||
description = pkgDesc;
|
|
||||||
};
|
|
||||||
|
|
||||||
users.groups."domoticz" = {
|
|
||||||
name = cfg.group;
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.services."domoticz" = {
|
systemd.services."domoticz" = {
|
||||||
description = pkgDesc;
|
description = pkgDesc;
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network-online.target" ];
|
after = [ "network-online.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
User = cfg.user;
|
DynamicUser = true;
|
||||||
Group = cfg.group;
|
StateDirectory = "domoticz";
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.domoticz}/bin/domoticz -noupdates -www ${toString cfg.port} -wwwbind ${cfg.bind} -sslwww 0 -userdata ${cfg.stateDir} -approot ${pkgs.domoticz}/share/domoticz/ -pidfile /var/run/domoticz.pid
|
${pkgs.domoticz}/bin/domoticz -noupdates -www ${toString cfg.port} -wwwbind ${cfg.bind} -sslwww 0 -userdata /var/lib/domoticz -approot ${pkgs.domoticz}/share/domoticz/ -pidfile /var/run/domoticz.pid
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue