diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index dd6519ff9361e..78915a8c1db30 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -827,8 +827,10 @@ in { predictable-interface-names = handleTest ./predictable-interface-names.nix {}; pretalx = runTest ./web-apps/pretalx.nix; pretix = runTest ./web-apps/pretix.nix; - printing-socket = handleTest ./printing.nix { socket = true; }; - printing-service = handleTest ./printing.nix { socket = false; }; + printing-socket = handleTest ./printing.nix { socket = true; listenTcp = true; }; + printing-service = handleTest ./printing.nix { socket = false; listenTcp = true; }; + printing-socket-notcp = handleTest ./printing.nix { socket = true; listenTcp = false; }; + printing-service-notcp = handleTest ./printing.nix { socket = false; listenTcp = false; }; private-gpt = handleTest ./private-gpt.nix {}; privatebin = runTest ./privatebin.nix; privoxy = handleTest ./privoxy.nix {}; diff --git a/nixos/tests/printing.nix b/nixos/tests/printing.nix index b413996c67db8..5f719a5d97c10 100644 --- a/nixos/tests/printing.nix +++ b/nixos/tests/printing.nix @@ -3,12 +3,17 @@ import ./make-test-python.nix ( { pkgs , socket ? true # whether to use socket activation +, listenTcp ? true # whether to open port 631 on client , ... }: +let + inherit (pkgs) lib; +in + { name = "printing"; - meta = with pkgs.lib.maintainers; { + meta = with lib.maintainers; { maintainers = [ domenkozar matthewbauer ]; }; @@ -35,9 +40,10 @@ import ./make-test-python.nix ( }]; }; - nodes.client = { ... }: { + nodes.client = { lib, ... }: { services.printing.enable = true; services.printing.startWhenNeeded = socket; + services.printing.listenAddresses = lib.mkIf (!listenTcp) []; # Add printer to the client as well, via IPP. hardware.printers.ensurePrinters = [{ name = "DeskjetRemote"; @@ -54,8 +60,8 @@ import ./make-test-python.nix ( start_all() with subtest("Make sure that cups is up on both sides and printers are set up"): - server.wait_for_unit("cups.${if socket then "socket" else "service"}") - client.wait_for_unit("cups.${if socket then "socket" else "service"}") + server.wait_for_unit("ensure-printers.service") + client.wait_for_unit("ensure-printers.service") assert "scheduler is running" in client.succeed("lpstat -r") @@ -63,7 +69,7 @@ import ./make-test-python.nix ( assert "/var/run/cups/cups.sock" in client.succeed("lpstat -H") with subtest("HTTP server is available too"): - client.succeed("curl --fail http://localhost:631/") + ${lib.optionalString listenTcp ''client.succeed("curl --fail http://localhost:631/")''} client.succeed(f"curl --fail http://{server.name}:631/") server.fail(f"curl --fail --connect-timeout 2 http://{client.name}:631/") diff --git a/pkgs/misc/cups/default.nix b/pkgs/misc/cups/default.nix index 4c9d2de108734..085ecdbed827c 100644 --- a/pkgs/misc/cups/default.nix +++ b/pkgs/misc/cups/default.nix @@ -138,8 +138,11 @@ stdenv.mkDerivation rec { passthru.tests = { inherit (nixosTests) + cups-pdf printing-service printing-socket + printing-service-notcp + printing-socket-notcp ; };