nixos/taskserver: Handle declarative conf via JSON
We now no longer have the stupid --service-helper option, which silences messages about already existing organisations, users or groups. Instead of that option, we now have a new subcommand called "process-json", which accepts a JSON file directly from the specified NixOS module options and creates/deletes the users accordingly. Note that this still has a two issues left to solve in this area: * Deletion is not supported yet. * If a user is created imperatively, the next run of process-json will delete it once deletion is supported. So we need to implement deletion and a way to mark organisations, users and groups as "imperatively managed". Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
@@ -142,8 +142,6 @@ let
|
||||
propagatedBuildInputs = [ pkgs.pythonPackages.click ];
|
||||
};
|
||||
|
||||
ctlcmd = "${nixos-taskserver}/bin/nixos-taskserver --service-helper";
|
||||
|
||||
withMeta = meta: defs: mkMerge [ defs { inherit meta; } ];
|
||||
|
||||
in {
|
||||
@@ -432,20 +430,10 @@ in {
|
||||
|
||||
environment.TASKDDATA = cfg.dataDir;
|
||||
|
||||
preStart = ''
|
||||
${concatStrings (mapAttrsToList (orgName: attrs: ''
|
||||
${ctlcmd} add-org ${mkShellStr orgName}
|
||||
|
||||
${concatMapStrings (user: ''
|
||||
echo Creating ${user} >&2
|
||||
${ctlcmd} add-user ${mkShellStr orgName} ${mkShellStr user}
|
||||
'') attrs.users}
|
||||
|
||||
${concatMapStrings (group: ''
|
||||
${ctlcmd} add-group ${mkShellStr orgName} ${mkShellStr user}
|
||||
'') attrs.groups}
|
||||
'') cfg.organisations)}
|
||||
'';
|
||||
preStart = let
|
||||
jsonOrgs = builtins.toJSON cfg.organisations;
|
||||
jsonFile = pkgs.writeText "orgs.json" jsonOrgs;
|
||||
in "${nixos-taskserver}/bin/nixos-taskserver process-json '${jsonFile}'";
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = "@${taskd} taskd server";
|
||||
|
||||
Reference in New Issue
Block a user