commit
b4b663efc8
|
@ -116,19 +116,14 @@ in {
|
||||||
description = "Ensure NixOS-configured CUPS printers";
|
description = "Ensure NixOS-configured CUPS printers";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
requires = [ cupsUnit ];
|
requires = [ cupsUnit ];
|
||||||
# in contrast to cups.socket, for cups.service, this is actually not enough,
|
|
||||||
# as the cups service reports its activation before clients can actually interact with it.
|
|
||||||
# Because of this, commands like `lpinfo -v` will report a bad file descriptor
|
|
||||||
# due to the missing UNIX socket without sufficient sleep time.
|
|
||||||
after = [ cupsUnit ];
|
after = [ cupsUnit ];
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
# sleep 10 is required to wait until cups.service is actually initialized and has created its UNIX socket file
|
script = concatMapStringsSep "\n" ensurePrinter cfg.ensurePrinters
|
||||||
script = (optionalString (!config.services.printing.startWhenNeeded) "sleep 10\n")
|
|
||||||
+ (concatMapStringsSep "\n" ensurePrinter cfg.ensurePrinters)
|
|
||||||
+ optionalString (cfg.ensureDefaultPrinter != null) (ensureDefaultPrinter cfg.ensureDefaultPrinter);
|
+ optionalString (cfg.ensureDefaultPrinter != null) (ensureDefaultPrinter cfg.ensureDefaultPrinter);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -53,18 +53,10 @@ in {
|
||||||
|
|
||||||
start_all()
|
start_all()
|
||||||
|
|
||||||
with subtest("Make sure that cups is up on both sides"):
|
with subtest("Make sure that cups is up on both sides and printers are set up"):
|
||||||
serviceServer.wait_for_unit("cups.service")
|
serviceServer.wait_for_unit("cups.service")
|
||||||
serviceClient.wait_for_unit("cups.service")
|
serviceClient.wait_for_unit("cups.service")
|
||||||
|
socketActivatedClient.wait_for_unit("ensure-printers.service")
|
||||||
with subtest(
|
|
||||||
"Wait until cups is fully initialized and ensure-printers has "
|
|
||||||
"executed with 10s delay"
|
|
||||||
):
|
|
||||||
serviceClient.sleep(20)
|
|
||||||
socketActivatedClient.wait_until_succeeds(
|
|
||||||
"systemctl show ensure-printers | grep -q -E 'code=exited ; status=0'"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_printing(client, server):
|
def test_printing(client, server):
|
||||||
|
|
|
@ -28,16 +28,15 @@ stdenv.mkDerivation rec {
|
||||||
pname = "cups";
|
pname = "cups";
|
||||||
|
|
||||||
# After 2.2.6, CUPS requires headers only available in macOS 10.12+
|
# After 2.2.6, CUPS requires headers only available in macOS 10.12+
|
||||||
version = if stdenv.isDarwin then "2.2.6" else "2.3.3";
|
version = if stdenv.isDarwin then "2.2.6" else "2.3.3op2";
|
||||||
|
|
||||||
passthru = { inherit version; };
|
src = fetchurl (if stdenv.isDarwin then {
|
||||||
|
|
||||||
src = fetchurl {
|
|
||||||
url = "https://github.com/apple/cups/releases/download/v${version}/cups-${version}-source.tar.gz";
|
url = "https://github.com/apple/cups/releases/download/v${version}/cups-${version}-source.tar.gz";
|
||||||
sha256 = if version == "2.2.6"
|
sha256 = "16qn41b84xz6khrr2pa2wdwlqxr29rrrkjfi618gbgdkq9w5ff20";
|
||||||
then "16qn41b84xz6khrr2pa2wdwlqxr29rrrkjfi618gbgdkq9w5ff20"
|
} else {
|
||||||
else "1vpk0b2vq830f8fvf9z8qjsm5k141i7pi8djbinpnr78pi4dj7r6";
|
url = "https://github.com/OpenPrinting/cups/releases/download/v${version}/cups-${version}-source.tar.gz";
|
||||||
};
|
sha256 = "1pwndz4gwkm7311wkhhzlw2diy7wbck7yy026jbaxh3rprdmgcyy";
|
||||||
|
});
|
||||||
|
|
||||||
outputs = [ "out" "lib" "dev" "man" ];
|
outputs = [ "out" "lib" "dev" "man" ];
|
||||||
|
|
||||||
|
@ -49,10 +48,8 @@ stdenv.mkDerivation rec {
|
||||||
nativeBuildInputs = [ pkg-config removeReferencesTo ];
|
nativeBuildInputs = [ pkg-config removeReferencesTo ];
|
||||||
|
|
||||||
buildInputs = [ zlib libjpeg libpng libtiff libusb1 gnutls libpaper ]
|
buildInputs = [ zlib libjpeg libpng libtiff libusb1 gnutls libpaper ]
|
||||||
++ optionals stdenv.isLinux [ avahi pam dbus ]
|
++ optionals stdenv.isLinux [ avahi pam dbus acl ]
|
||||||
++ optional enableSystemd systemd
|
++ optional enableSystemd systemd
|
||||||
# Separate from above only to not modify order, to avoid mass rebuilds; merge this with the above at next big change.
|
|
||||||
++ optionals stdenv.isLinux [ acl ]
|
|
||||||
++ optionals stdenv.isDarwin (with darwin; [
|
++ optionals stdenv.isDarwin (with darwin; [
|
||||||
configd apple_sdk.frameworks.ApplicationServices
|
configd apple_sdk.frameworks.ApplicationServices
|
||||||
]);
|
]);
|
||||||
|
@ -129,18 +126,8 @@ stdenv.mkDerivation rec {
|
||||||
sed -e "/^cups_serverbin=/s|$lib|$out|" \
|
sed -e "/^cups_serverbin=/s|$lib|$out|" \
|
||||||
-i "$dev/bin/cups-config"
|
-i "$dev/bin/cups-config"
|
||||||
|
|
||||||
# Rename systemd files provided by CUPS
|
|
||||||
for f in "$out"/lib/systemd/system/*; do
|
for f in "$out"/lib/systemd/system/*; do
|
||||||
substituteInPlace "$f" \
|
substituteInPlace "$f" --replace "$lib/$libexec" "$out/$libexec"
|
||||||
--replace "$lib/$libexec" "$out/$libexec" \
|
|
||||||
--replace "org.cups.cupsd" "cups" \
|
|
||||||
--replace "org.cups." ""
|
|
||||||
|
|
||||||
if [[ "$f" =~ .*cupsd\..* ]]; then
|
|
||||||
mv "$f" "''${f/org\.cups\.cupsd/cups}"
|
|
||||||
else
|
|
||||||
mv "$f" "''${f/org\.cups\./}"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
'' + optionalString stdenv.isLinux ''
|
'' + optionalString stdenv.isLinux ''
|
||||||
# Use xdg-open when on Linux
|
# Use xdg-open when on Linux
|
||||||
|
@ -149,9 +136,9 @@ stdenv.mkDerivation rec {
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
homepage = "https://cups.org/";
|
homepage = "https://openprinting.github.io/cups/";
|
||||||
description = "A standards-based printing system for UNIX";
|
description = "A standards-based printing system for UNIX";
|
||||||
license = licenses.gpl2; # actually LGPL for the library and GPL for the rest
|
license = licenses.asl20;
|
||||||
maintainers = with maintainers; [ matthewbauer ];
|
maintainers = with maintainers; [ matthewbauer ];
|
||||||
platforms = platforms.unix;
|
platforms = platforms.unix;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue