Merge pull request #148201 from Artturin/nixservesecret

nix-serve: fix NIX_SECRET_KEY_FILE

Changed files
+16 -9
nixos
modules
services
networking
tests
pkgs
tools
package-management
nix-serve
+9 -5
nixos/modules/services/networking/nix-serve.nix
···
nix-store --generate-binary-cache-key key-name secret-key-file public-key-file
```
-
Make sure user `nix-serve` has read access to the private key file.
-
For more details see <citerefentry><refentrytitle>nix-store</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
'';
};
···
path = [ config.nix.package.out pkgs.bzip2.bin ];
environment.NIX_REMOTE = "daemon";
-
environment.NIX_SECRET_KEY_FILE = cfg.secretKeyFile;
+
+
script = ''
+
${lib.optionalString (cfg.secretKeyFile != null) ''
+
export NIX_SECRET_KEY_FILE="$CREDENTIALS_DIRECTORY/NIX_SECRET_KEY_FILE"
+
''}
+
exec ${pkgs.nix-serve}/bin/nix-serve --listen ${cfg.bindAddress}:${toString cfg.port} ${cfg.extraParams}
+
'';
serviceConfig = {
Restart = "always";
RestartSec = "5s";
-
ExecStart = "${pkgs.nix-serve}/bin/nix-serve " +
-
"--listen ${cfg.bindAddress}:${toString cfg.port} ${cfg.extraParams}";
User = "nix-serve";
Group = "nix-serve";
DynamicUser = true;
+
LoadCredential = lib.optionalString (cfg.secretKeyFile != null)
+
"NIX_SECRET_KEY_FILE:${cfg.secretKeyFile}";
};
};
};
+2 -2
nixos/tests/all-tests.nix
···
nginx-sso = handleTest ./nginx-sso.nix {};
nginx-variants = handleTest ./nginx-variants.nix {};
nitter = handleTest ./nitter.nix {};
-
nix-serve = handleTest ./nix-ssh-serve.nix {};
-
nix-ssh-serve = handleTest ./nix-ssh-serve.nix {};
+
nix-serve = handleTest ./nix-serve.nix {};
+
nix-serve-ssh = handleTest ./nix-serve-ssh.nix {};
nixops = handleTest ./nixops/default.nix {};
nixos-generate-config = handleTest ./nixos-generate-config.nix {};
node-red = handleTest ./node-red.nix {};
+1 -1
nixos/tests/nix-ssh-serve.nix nixos/tests/nix-serve-ssh.nix
···
client.fail("diff /root/other-store$(cat mach-id-path) /etc/machine-id")
# Currently due to shared store this is a noop :(
-
client.succeed("nix copy --to ssh-ng://nix-ssh@server $(cat mach-id-path)")
+
client.succeed("nix copy --experimental-features 'nix-command' --to ssh-ng://nix-ssh@server $(cat mach-id-path)")
client.succeed(
"nix-store --realise $(cat mach-id-path) --store /root/other-store --substituters ssh-ng://nix-ssh@server"
)
+4 -1
pkgs/tools/package-management/nix-serve/default.nix
···
--add-flags $out/libexec/nix-serve/nix-serve.psgi
'';
-
passthru.tests.nix-serve = nixosTests.nix-serve;
+
passthru.tests = {
+
nix-serve = nixosTests.nix-serve;
+
nix-serve-ssh = nixosTests.nix-serve-ssh;
+
};
meta = {
homepage = "https://github.com/edolstra/nix-serve";