mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
nixos/systemd/userdbd: add method to enable service
This is recommended to enable in conjunction with systemd-homed.
This commit is contained in:
parent
7ea3d4395d
commit
0cc87ab901
@ -1275,6 +1275,7 @@
|
||||
./system/boot/systemd/shutdown.nix
|
||||
./system/boot/systemd/tmpfiles.nix
|
||||
./system/boot/systemd/user.nix
|
||||
./system/boot/systemd/userdbd.nix
|
||||
./system/boot/timesyncd.nix
|
||||
./system/boot/tmp.nix
|
||||
./system/boot/uvesafb.nix
|
||||
|
18
nixos/modules/system/boot/systemd/userdbd.nix
Normal file
18
nixos/modules/system/boot/systemd/userdbd.nix
Normal 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" ];
|
||||
};
|
||||
}
|
@ -636,6 +636,7 @@ in {
|
||||
systemd-shutdown = handleTest ./systemd-shutdown.nix {};
|
||||
systemd-timesyncd = handleTest ./systemd-timesyncd.nix {};
|
||||
systemd-misc = handleTest ./systemd-misc.nix {};
|
||||
systemd-userdbd = handleTest ./systemd-userdbd.nix {};
|
||||
tandoor-recipes = handleTest ./tandoor-recipes.nix {};
|
||||
taskserver = handleTest ./taskserver.nix {};
|
||||
tayga = handleTest ./tayga.nix {};
|
||||
|
32
nixos/tests/systemd-userdbd.nix
Normal file
32
nixos/tests/systemd-userdbd.nix
Normal 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")
|
||||
'';
|
||||
})
|
Loading…
Reference in New Issue
Block a user