flake(linger): add linger-flaker to allow the pihole-flake to manage user lingering

Systemd's user lingering feature seems to be necessary to run rootless podman if the executing user is not logged in.
See https://github.com/NixOS/nixpkgs/issues/138423
This commit is contained in:
Christopher Bacher 2022-10-28 18:51:18 +02:00
parent 5fb27f33b3
commit 428baed6cf
2 changed files with 14 additions and 3 deletions

View file

@ -1,4 +1,4 @@
{ piholeFlake, util }: { config, pkgs, lib, ... }: with lib; with builtins; let
{ piholeFlake, lingerFlake, util }: { config, pkgs, lib, ... }: with lib; with builtins; let
inherit (util) collectAttrFragments accessValueOfFragment toEnvValue;
cfg = config.services.pihole;
@ -320,6 +320,11 @@ in rec {
Set it to "suppressWarning" if you manage lingering in a different way.
'');
services.linger = mkIf (cfg.hostConfig.enableLingeringForUser == true) {
enable = true;
users = [ cfg.hostConfig.user ];
};
systemd.services."pihole-rootless-container" = {
wantedBy = [ "multi-user.target" ];
after = [ "network-online.target" ];