diff --git a/modules/common/services/default.nix b/modules/common/services/default.nix index 73795c0ac2..37b098357c 100644 --- a/modules/common/services/default.nix +++ b/modules/common/services/default.nix @@ -10,5 +10,6 @@ ./pdfopen.nix ./namespaces.nix ./yubikey.nix + ./printer.nix ]; } diff --git a/modules/common/services/printer.nix b/modules/common/services/printer.nix new file mode 100644 index 0000000000..667c83a92f --- /dev/null +++ b/modules/common/services/printer.nix @@ -0,0 +1,54 @@ +# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors +# SPDX-License-Identifier: Apache-2.0 +{ config, lib, ... }: +let + cfg = config.ghaf.services.printer; + inherit (lib) mkIf mkEnableOption; +in +{ + options.ghaf.services.printer = { + enable = mkEnableOption "Printer configuration for app-vms"; + }; + config = mkIf cfg.enable { + + services.printing.enable = true; + services.avahi = { + enable = true; + nssmdns4 = true; + reflector = true; + }; + environment.etc."chromium/bookmarks.html".text = + '' + + + + Bookmarks +

Bookmarks

+

+

Bookmarks bar

+

+ '' + + "

CUPS" + + '' +

+

+ ''; + programs.chromium.initialPrefs = { + "import_bookmarks" = false; + "distribution" = { + "import_bookmarks" = false; + "import_bookmarks_from_file" = "/etc/chromium/bookmarks.html"; + "bookmark_bar" = { + "show_on_all_tabs" = true; + }; + }; + }; + }; +} diff --git a/modules/microvm/virtualization/microvm/netvm.nix b/modules/microvm/virtualization/microvm/netvm.nix index b22ace7009..9c88f970fc 100644 --- a/modules/microvm/virtualization/microvm/netvm.nix +++ b/modules/microvm/virtualization/microvm/netvm.nix @@ -85,6 +85,11 @@ let firewall.allowedTCPPorts = [ 53 ]; firewall.allowedUDPPorts = [ 53 ]; }; + services.avahi = { + enable = true; + nssmdns4 = true; + reflector = true; + }; services.openssh = config.ghaf.security.sshKeys.sshAuthorizedKeysCommand; diff --git a/modules/reference/appvms/business.nix b/modules/reference/appvms/business.nix index 89fccc3e09..6c0a16dfb7 100644 --- a/modules/reference/appvms/business.nix +++ b/modules/reference/appvms/business.nix @@ -99,6 +99,9 @@ in # Set default PDF XDG handler xdg.mime.defaultApplications."application/pdf" = "ghaf-pdf.desktop"; + # Enable printer service + ghaf.services.printer.enable = true; + # TODO: Add a way to configure the gpclient # also check the openconnect cli options https://discourse.nixos.org/t/globalprotect-vpn/24014/5 services.globalprotect = { diff --git a/modules/reference/appvms/chromium.nix b/modules/reference/appvms/chromium.nix index 3f0f0125ec..8cad12de9e 100644 --- a/modules/reference/appvms/chromium.nix +++ b/modules/reference/appvms/chromium.nix @@ -89,6 +89,9 @@ in # Set default PDF XDG handler xdg.mime.defaultApplications."application/pdf" = "ghaf-pdf.desktop"; + + # Enable printer service + ghaf.services.printer.enable = true; } ]; borderColor = "#630505"; diff --git a/overlays/custom-packages/cups/default.nix b/overlays/custom-packages/cups/default.nix new file mode 100644 index 0000000000..497064f468 --- /dev/null +++ b/overlays/custom-packages/cups/default.nix @@ -0,0 +1,14 @@ +# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors +# SPDX-License-Identifier: Apache-2.0 +{ final, prev }: +prev.cups.overrideAttrs ( + _final: _prev: { + # Due to the incorrect printer URI bug: https://github.com/OpenPrinting/cups/issues/998 + src = final.fetchFromGitHub { + owner = "OpenPrinting"; + repo = "cups"; + rev = "313c388dbc023bbcb75d1efed800d0cfc992a6cc"; + hash = "sha256-weu12hlrYUYY90pe0dJ6CiLtm8ynrLA9nT4j7iRwA+Q="; + }; + } +) diff --git a/overlays/custom-packages/default.nix b/overlays/custom-packages/default.nix index 82ef7845d8..2d4f7d1844 100644 --- a/overlays/custom-packages/default.nix +++ b/overlays/custom-packages/default.nix @@ -19,4 +19,5 @@ mitmweb-ui = final.callPackage ../../packages/mitmweb-ui { }; gtklock = import ./gtklock { inherit prev; }; hardware-scan = final.callPackage ../../packages/hardware-scan { }; + cups = import ./cups { inherit final prev; }; })