mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-01 18:44:07 +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
64 lines
1.9 KiB
Nix
64 lines
1.9 KiB
Nix
import ./make-test-python.nix (
|
|
{ pkgs, ... }:
|
|
|
|
let
|
|
echoAll = pkgs.writeScript "echo-all" ''
|
|
#! ${pkgs.runtimeShell}
|
|
for s in "$@"; do
|
|
printf '%s\n' "$s"
|
|
done
|
|
'';
|
|
# deliberately using a local empty file instead of pkgs.emptyFile to have
|
|
# a non-store path in the test
|
|
args = [
|
|
"a%Nything"
|
|
"lang=\${LANG}"
|
|
";"
|
|
"/bin/sh -c date"
|
|
./empty-file
|
|
4.2
|
|
23
|
|
];
|
|
in
|
|
{
|
|
name = "systemd-escaping";
|
|
|
|
nodes.machine =
|
|
{
|
|
pkgs,
|
|
lib,
|
|
utils,
|
|
...
|
|
}:
|
|
{
|
|
systemd.services.echo =
|
|
assert !(builtins.tryEval (utils.escapeSystemdExecArgs [ [ ] ])).success;
|
|
assert !(builtins.tryEval (utils.escapeSystemdExecArgs [ { } ])).success;
|
|
assert !(builtins.tryEval (utils.escapeSystemdExecArgs [ null ])).success;
|
|
assert !(builtins.tryEval (utils.escapeSystemdExecArgs [ false ])).success;
|
|
assert !(builtins.tryEval (utils.escapeSystemdExecArgs [ (_: _) ])).success;
|
|
{
|
|
description = "Echo to the journal";
|
|
serviceConfig.Type = "oneshot";
|
|
serviceConfig.ExecStart = ''
|
|
${echoAll} ${utils.escapeSystemdExecArgs args}
|
|
'';
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
machine.wait_for_unit("multi-user.target")
|
|
machine.succeed("systemctl start echo.service")
|
|
# skip the first 'Starting <service> ...' line
|
|
logs = machine.succeed("journalctl -u echo.service -o cat").splitlines()[1:]
|
|
assert "a%Nything" == logs[0]
|
|
assert "lang=''${LANG}" == logs[1]
|
|
assert ";" == logs[2]
|
|
assert "/bin/sh -c date" == logs[3]
|
|
assert "/nix/store/ij3gw72f4n5z4dz6nnzl1731p9kmjbwr-empty-file" == logs[4]
|
|
assert "4.2" in logs[5] # toString produces extra fractional digits!
|
|
assert "23" == logs[6]
|
|
'';
|
|
}
|
|
)
|