modules(pihole-container): add option for enabling user lingering (not wired)

This commit is contained in:
Christopher Bacher 2022-10-22 15:47:37 +02:00
parent c8e603fd29
commit 9238520b65

View file

@ -2,6 +2,7 @@
inherit (util) collectAttrFragments accessValueOfFragment toEnvValue; inherit (util) collectAttrFragments accessValueOfFragment toEnvValue;
cfg = config.services.pihole; cfg = config.services.pihole;
hostUserCfg = config.users.users.${cfg.hostConfig.user};
systemTimeZone = config.time.timeZone; systemTimeZone = config.time.timeZone;
defaultPiholeVolumesDir = "${config.users.users.${cfg.hostConfig.user}.home}/pihole-volumes"; defaultPiholeVolumesDir = "${config.users.users.${cfg.hostConfig.user}.home}/pihole-volumes";
@ -58,6 +59,18 @@ in rec {
''; '';
}; };
enableLingeringForUser = mkOption {
type = with types; oneOf [ bool (enum [ "suppressWarning" ]) ];
description = ''
If true lingering (see `loginctl enable-linger`) is enabled for the host user running pihole.
This is necessary as otherwise starting the pihole container will fail if there is no active session for the host user.
If false a warning is printed during the build to remind you of the issue.
Set to "suppressWarning" if the issue is solved otherwise or does not apply.
'';
default = false;
};
containerName = mkOption { containerName = mkOption {
type = types.str; type = types.str;
description = '' description = ''
@ -292,10 +305,8 @@ in rec {
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = let assertions = [
hostUserCfg = config.users.users.${cfg.hostConfig.user}; { assertion = length hostUserCfg.subUidRanges > 0 && length hostUserCfg.subGidRanges > 0;
in [
{ assertion = hostUserCfg ? "subUidRanges" && hostUserCfg ? "subGidRanges";
message = '' message = ''
The host user most have configured subUidRanges & subGidRanges as pihole is running in a rootless podman container. The host user most have configured subUidRanges & subGidRanges as pihole is running in a rootless podman container.
''; '';