Revert dynamic user. And restart on failure

This commit is contained in:
Zuckerberg 2023-12-02 17:35:31 -07:00
parent 2a51a33f9b
commit 723eacbecd

View File

@ -13,11 +13,11 @@ in
Directory of images that the server will serve Directory of images that the server will serve
''; '';
}; };
imgDirGroup = lib.mkOption { group = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "picture-frame-server";
description = '' description = ''
The group the server will run as a member of. The group the server should run as
So the server can have read access to `imgDir`.
''; '';
}; };
port = lib.mkOption { port = lib.mkOption {
@ -31,16 +31,20 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
nixpkgs.overlays = [ overlay ]; nixpkgs.overlays = [ overlay ];
users.users.${cfg.user} = {
isSystemUser = true;
group = cfg.group;
};
users.groups.${cfg.group} = { };
systemd.services.picture-frame-server = { systemd.services.picture-frame-server = {
enable = true; enable = true;
after = [ "network.target" ]; after = [ "network.target" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
serviceConfig = { serviceConfig = {
ExecStart = "${pkgs.picture-frame.server}/bin/server ${toString cfg.port} ${cfg.imgDir}"; ExecStart = "${pkgs.picture-frame.server}/bin/server ${toString cfg.port} ${cfg.imgDir}";
DynamicUser = true; User = cfg.user;
PrivateTmp = true; Group = cfg.group;
User = "picture-frame-server"; Restart = "on-failure";
SupplementaryGroups = [ cfg.imgDirGroup ];
}; };
}; };
}; };