nixos/systemd/userdbd: add method to enable service

This is recommended to enable in conjunction with systemd-homed.
This commit is contained in:
Leorize 2022-12-07 18:31:05 -06:00
parent 7ea3d4395d
commit 0cc87ab901
4 changed files with 52 additions and 0 deletions

View File

@ -1275,6 +1275,7 @@
./system/boot/systemd/shutdown.nix ./system/boot/systemd/shutdown.nix
./system/boot/systemd/tmpfiles.nix ./system/boot/systemd/tmpfiles.nix
./system/boot/systemd/user.nix ./system/boot/systemd/user.nix
./system/boot/systemd/userdbd.nix
./system/boot/timesyncd.nix ./system/boot/timesyncd.nix
./system/boot/tmp.nix ./system/boot/tmp.nix
./system/boot/uvesafb.nix ./system/boot/uvesafb.nix

View File

@ -0,0 +1,18 @@
{ config, lib, ... }:
let
cfg = config.services.userdbd;
in
{
options.services.userdbd.enable = lib.mkEnableOption (lib.mdDoc ''
Enables the systemd JSON user/group record lookup service
'');
config = lib.mkIf cfg.enable {
systemd.additionalUpstreamSystemUnits = [
"systemd-userdbd.socket"
"systemd-userdbd.service"
];
systemd.sockets.systemd-userdbd.wantedBy = [ "sockets.target" ];
};
}

View File

@ -636,6 +636,7 @@ in {
systemd-shutdown = handleTest ./systemd-shutdown.nix {}; systemd-shutdown = handleTest ./systemd-shutdown.nix {};
systemd-timesyncd = handleTest ./systemd-timesyncd.nix {}; systemd-timesyncd = handleTest ./systemd-timesyncd.nix {};
systemd-misc = handleTest ./systemd-misc.nix {}; systemd-misc = handleTest ./systemd-misc.nix {};
systemd-userdbd = handleTest ./systemd-userdbd.nix {};
tandoor-recipes = handleTest ./tandoor-recipes.nix {}; tandoor-recipes = handleTest ./tandoor-recipes.nix {};
taskserver = handleTest ./taskserver.nix {}; taskserver = handleTest ./taskserver.nix {};
tayga = handleTest ./tayga.nix {}; tayga = handleTest ./tayga.nix {};

View File

@ -0,0 +1,32 @@
import ./make-test-python.nix ({ pkgs, lib, ... }: {
name = "systemd-userdbd";
nodes.machine = { config, pkgs, ... }: {
services.userdbd.enable = true;
users.users.test-user-nss = {
isNormalUser = true;
};
environment.etc."userdb/test-user-dropin.user".text = builtins.toJSON {
userName = "test-user-dropin";
};
environment.systemPackages = with pkgs; [ libvarlink ];
};
testScript = ''
import json
from shlex import quote
def getUserRecord(name):
Interface = "unix:/run/systemd/userdb/io.systemd.Multiplexer/io.systemd.UserDatabase"
payload = json.dumps({
"service": "io.systemd.Multiplexer",
"userName": name
})
return json.loads(machine.succeed(f"varlink call {Interface}.GetUserRecord {quote(payload)}"))
machine.wait_for_unit("systemd-userdbd.socket")
getUserRecord("test-user-nss")
getUserRecord("test-user-dropin")
'';
})