Give intake packages to the user as well

This commit is contained in:
Tim Van Baak 2023-06-21 03:59:58 +00:00
parent c5778513e2
commit f9611d598a
1 changed files with 18 additions and 7 deletions

View File

@ -29,6 +29,12 @@ in {
"allocated equal to the number of users with enabled intake services."; "allocated equal to the number of users with enabled intake services.";
}; };
extraPackages = mkOption {
type = types.listOf types.package;
default = [];
description = "Extra packages available to all enabled users and their intake services.";
};
users = mkOption { users = mkOption {
description = "User intake service definitions."; description = "User intake service definitions.";
default = {}; default = {};
@ -36,10 +42,10 @@ in {
options = { options = {
enable = mkEnableOption "intake, a personal feed aggregator."; enable = mkEnableOption "intake, a personal feed aggregator.";
packages = mkOption { extraPackages = mkOption {
type = types.listOf types.package; type = types.listOf types.package;
default = []; default = [];
description = "Additional packages available to the intake service."; description = "Extra packages available to this user and their intake service.";
}; };
}; };
}); });
@ -71,7 +77,7 @@ in {
# Apply the overlay so intake is included inpkgs. # Apply the overlay so intake is included inpkgs.
nixpkgs.overlays = [ flake.overlays.default ]; nixpkgs.overlays = [ flake.overlays.default ];
# Define a user group for access to the htpasswd file. # Define a user group for access to the htpasswd file. nginx needs to be able to read it.
users.groups.intake.members = mkIf (enabledUsers != {}) (enabledUserNames ++ [ "nginx" ]); users.groups.intake.members = mkIf (enabledUsers != {}) (enabledUserNames ++ [ "nginx" ]);
# Define an activation script that ensures that the htpasswd file exists. # Define an activation script that ensures that the htpasswd file exists.
@ -88,11 +94,16 @@ in {
${pkgs.coreutils}/bin/chmod 660 ${intakePwd} ${pkgs.coreutils}/bin/chmod 660 ${intakePwd}
''; '';
# Give the htpasswd wrapper to every intake user # Give every intake user the htpasswd wrapper, the shared packages, and the user-specific packages.
users.users = users.users =
let let
addWrapperToUser = userName: { ${userName}.packages = [ htpasswdWrapper ]; }; addPackagesToUser = userName: {
in mkMerge (map addWrapperToUser enabledUserNames); ${userName}.packages =
[ htpasswdWrapper intake ]
++ intakeCfg.extraPackages
++ intakeCfg.users.${userName}.extraPackages;
};
in mkMerge (map addPackagesToUser enabledUserNames);
# Define a user service for each configured user # Define a user service for each configured user
systemd.services = systemd.services =
@ -105,7 +116,7 @@ in {
"intake@${userName}" = { "intake@${userName}" = {
description = "Intake service for user ${userName}"; description = "Intake service for user ${userName}";
script = "${runScript userName}"; script = "${runScript userName}";
path = userCfg.packages; path = intakeCfg.extraPackages ++ userCfg.extraPackages;
serviceConfig = { serviceConfig = {
User = userName; User = userName;
Type = "simple"; Type = "simple";