summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorJörg Thalheim <Mic92@users.noreply.github.com>2021-07-18 07:53:32 +0100
committerGitHub <noreply@github.com>2021-07-18 07:53:32 +0100
commit0839cf1d45bc216bd83eef75296aa3b8835c8135 (patch)
tree15f074fa29b8386d52e75e12dd83a337f9ad0c50 /nixos
parentff4f2b6b85c9446001d6a410549223afe141f101 (diff)
parentac7b8724b59974c0d74f2feacc4a2a787a5cf122 (diff)
downloadnixpkgs-0839cf1d45bc216bd83eef75296aa3b8835c8135.tar
nixpkgs-0839cf1d45bc216bd83eef75296aa3b8835c8135.tar.gz
nixpkgs-0839cf1d45bc216bd83eef75296aa3b8835c8135.tar.bz2
nixpkgs-0839cf1d45bc216bd83eef75296aa3b8835c8135.tar.lz
nixpkgs-0839cf1d45bc216bd83eef75296aa3b8835c8135.tar.xz
nixpkgs-0839cf1d45bc216bd83eef75296aa3b8835c8135.tar.zst
nixpkgs-0839cf1d45bc216bd83eef75296aa3b8835c8135.zip
Merge pull request #106721 from Mic92/nix-serve
nixos/nix-serve: don't run as nogroup
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/misc/ids.nix2
-rw-r--r--nixos/modules/services/networking/nix-serve.nix8
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/nix-serve.nix22
4 files changed, 26 insertions, 7 deletions
diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix
index 2cbbbc522e1..858c7ee53db 100644
--- a/nixos/modules/misc/ids.nix
+++ b/nixos/modules/misc/ids.nix
@@ -229,7 +229,7 @@ in
       grafana = 196;
       skydns = 197;
       # ripple-rest = 198; # unused, removed 2017-08-12
-      nix-serve = 199;
+      # nix-serve = 199; # unused, removed 2020-12-12
       tvheadend = 200;
       uwsgi = 201;
       gitit = 202;
diff --git a/nixos/modules/services/networking/nix-serve.nix b/nixos/modules/services/networking/nix-serve.nix
index b17f35c769b..7fc145f2303 100644
--- a/nixos/modules/services/networking/nix-serve.nix
+++ b/nixos/modules/services/networking/nix-serve.nix
@@ -69,13 +69,9 @@ in
         ExecStart = "${pkgs.nix-serve}/bin/nix-serve " +
           "--listen ${cfg.bindAddress}:${toString cfg.port} ${cfg.extraParams}";
         User = "nix-serve";
-        Group = "nogroup";
+        Group = "nix-serve";
+        DynamicUser = true;
       };
     };
-
-    users.users.nix-serve = {
-      description = "Nix-serve user";
-      uid = config.ids.uids.nix-serve;
-    };
   };
 }
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index ef721dabb58..fd502a473b1 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -296,6 +296,7 @@ in
   nginx-sandbox = handleTestOn ["x86_64-linux"] ./nginx-sandbox.nix {};
   nginx-sso = handleTest ./nginx-sso.nix {};
   nginx-variants = handleTest ./nginx-variants.nix {};
+  nix-serve = handleTest ./nix-ssh-serve.nix {};
   nix-ssh-serve = handleTest ./nix-ssh-serve.nix {};
   nixos-generate-config = handleTest ./nixos-generate-config.nix {};
   nomad = handleTest ./nomad.nix {};
diff --git a/nixos/tests/nix-serve.nix b/nixos/tests/nix-serve.nix
new file mode 100644
index 00000000000..ab82f4be43e
--- /dev/null
+++ b/nixos/tests/nix-serve.nix
@@ -0,0 +1,22 @@
+import ./make-test-python.nix ({ pkgs, ... }:
+{
+  name = "nix-serve";
+  machine = { pkgs, ... }: {
+    services.nix-serve.enable = true;
+    environment.systemPackages = [
+      pkgs.hello
+    ];
+  };
+  testScript = let
+    pkgHash = builtins.head (
+      builtins.match "${builtins.storeDir}/([^-]+).+" (toString pkgs.hello)
+    );
+  in ''
+    start_all()
+    machine.wait_for_unit("nix-serve.service")
+    machine.wait_for_open_port(5000)
+    machine.succeed(
+        "curl --fail -g http://0.0.0.0:5000/nar/${pkgHash}.nar -o /tmp/hello.nar"
+    )
+  '';
+})