mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-25 03:17:13 +00:00
4f0dadbf38
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
80 lines
2.3 KiB
Nix
80 lines
2.3 KiB
Nix
# the ntfy-sh module was switching to DynamicUser=true. this test assures that
|
|
# the migration does not break existing setups.
|
|
#
|
|
# this test works doing a migration and asserting ntfy-sh runs properly. first,
|
|
# ntfy-sh is configured to use a static user and group. then ntfy-sh is
|
|
# started and tested. after that, ntfy-sh is shut down and a systemd drop
|
|
# in configuration file is used to upate the service configuration to use
|
|
# DynamicUser=true. then the ntfy-sh is started again and tested.
|
|
|
|
import ./make-test-python.nix {
|
|
name = "ntfy-sh";
|
|
|
|
nodes.machine =
|
|
{
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
{
|
|
environment.etc."ntfy-sh-dynamic-user.conf".text = ''
|
|
[Service]
|
|
Group=new-ntfy-sh
|
|
User=new-ntfy-sh
|
|
DynamicUser=true
|
|
'';
|
|
|
|
services.ntfy-sh.enable = true;
|
|
services.ntfy-sh.settings.base-url = "http://localhost:2586";
|
|
|
|
systemd.services.ntfy-sh.serviceConfig = {
|
|
DynamicUser = lib.mkForce false;
|
|
ExecStartPre = [
|
|
"${pkgs.coreutils}/bin/id"
|
|
"${pkgs.coreutils}/bin/ls -lahd /var/lib/ntfy-sh/"
|
|
"${pkgs.coreutils}/bin/ls -lah /var/lib/ntfy-sh/"
|
|
];
|
|
Group = lib.mkForce "old-ntfy-sh";
|
|
User = lib.mkForce "old-ntfy-sh";
|
|
};
|
|
|
|
users.users.old-ntfy-sh = {
|
|
isSystemUser = true;
|
|
group = "old-ntfy-sh";
|
|
};
|
|
|
|
users.groups.old-ntfy-sh = { };
|
|
};
|
|
|
|
testScript = ''
|
|
import json
|
|
|
|
msg = "Test notification"
|
|
|
|
def test_ntfysh():
|
|
machine.wait_for_unit("ntfy-sh.service")
|
|
machine.wait_for_open_port(2586)
|
|
|
|
machine.succeed(f"curl -d '{msg}' localhost:2586/test")
|
|
|
|
text = machine.succeed("curl -s localhost:2586/test/json?poll=1")
|
|
for line in text.splitlines():
|
|
notif = json.loads(line)
|
|
assert msg == notif["message"], "Wrong message"
|
|
|
|
machine.succeed("ntfy user list")
|
|
|
|
machine.wait_for_unit("multi-user.target")
|
|
|
|
test_ntfysh()
|
|
|
|
machine.succeed("systemctl stop ntfy-sh.service")
|
|
machine.succeed("mkdir -p /run/systemd/system/ntfy-sh.service.d")
|
|
machine.succeed("cp /etc/ntfy-sh-dynamic-user.conf /run/systemd/system/ntfy-sh.service.d/dynamic-user.conf")
|
|
machine.succeed("systemctl daemon-reload")
|
|
machine.succeed("systemctl start ntfy-sh.service")
|
|
|
|
test_ntfysh()
|
|
'';
|
|
}
|