feat: need a user, group and home to run this
This commit is contained in:
parent
87aa806397
commit
cb363e6558
1 changed files with 34 additions and 1 deletions
35
flake.nix
35
flake.nix
|
@ -52,6 +52,10 @@
|
|||
LDAP_API = cfg.ldap;
|
||||
DISCORD_TIMING_UPDATE = cfg.discord.timing.update;
|
||||
DISCORD_TIMING_FETCH = cfg.discord.timing.fetch;
|
||||
|
||||
# local details
|
||||
HOME = cfg.home;
|
||||
DATABASE = "database.db";
|
||||
};
|
||||
in {
|
||||
options.services."${package_name}" = {
|
||||
|
@ -106,10 +110,38 @@
|
|||
default = "https://api.account.skynet.ie";
|
||||
description = "Location of the ldap api";
|
||||
};
|
||||
|
||||
user = mkOption rec {
|
||||
type = types.str;
|
||||
default = "${package_name}";
|
||||
description = "The user to run the service";
|
||||
};
|
||||
|
||||
home = mkOption rec {
|
||||
type = types.str;
|
||||
default = "/etc/${cfg.prefix}${package_name}";
|
||||
description = "The home for the user";
|
||||
};
|
||||
|
||||
prefix = mkOption rec {
|
||||
type = types.str;
|
||||
default = "skynet_";
|
||||
example = default;
|
||||
description = "The prefix used to name service/folders";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
users.groups."${cfg.user}" = { };
|
||||
|
||||
users.users."${cfg.user}" = {
|
||||
createHome = true;
|
||||
isSystemUser = true;
|
||||
home = "${cfg.home}";
|
||||
group = "${cfg.user}";
|
||||
};
|
||||
|
||||
systemd.services = {
|
||||
# main service
|
||||
"${package_name}" = {
|
||||
|
@ -120,7 +152,8 @@
|
|||
environment = environment_config;
|
||||
|
||||
serviceConfig = {
|
||||
DynamicUser = "yes";
|
||||
User = "${cfg.user}";
|
||||
Group = "${cfg.user}";
|
||||
Restart = "always";
|
||||
ExecStart = "${self.defaultPackage."${system}"}/bin/${package_name}";
|
||||
# can have multiple env files
|
||||
|
|
Loading…
Reference in a new issue