Skip to content

Commit

Permalink
Add printing service in zathura-vm, chromium-vm and bussiness-vm
Browse files Browse the repository at this point in the history
CUPS is enabled in zathura-vm, chromium-vm and bussines-vm
CUPS overlay is applied due to printer webpage bug.
Avahi service reflection is added in net-vm.
CUPS web page is added into default chromium bookmarks.

Signed-off-by: Berk Arslan <[email protected]>
  • Loading branch information
Nerox9 committed Sep 30, 2024
1 parent 1733e08 commit 82affee
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/common/services/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
./namespaces.nix
./yubikey.nix
./bluetooth.nix
./printer.nix
];
}
72 changes: 72 additions & 0 deletions modules/common/services/printer.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# 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
mkOption
types
optionalAttrs
hasAttr
;
in
{
options.ghaf.services.printer = {
enable = mkEnableOption "Printer configuration for app-vms";
name = mkOption {
type = types.string;
description = "App-vm name for storage-vm";
};
};
config = mkIf cfg.enable {

services.printing.enable = true;
services.avahi = {
enable = true;
nssmdns4 = true;
reflector = true;
};
environment.etc."chromium/bookmarks.html".text =
''
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 ADD_DATE="1726234624" LAST_MODIFIED="1726234726" PERSONAL_TOOLBAR_FOLDER="true">Bookmarks bar</H3>
<DL><p>
''
+ "<DT><A HREF=\"http://localhost:631/\" ADD_DATE=\"1726234644\" ICON=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkW"
+ "g2AAABj0lEQVQ4jZWST8tBQRTG589x76SmW8qNlZuNkrg2VpQUFr6HjU/lS4gs2NmxslBSysaGy2TkGjPvYuqm3pVZnZ7nd86p5wwej8folwdRFP3WcLvdft5gjMEYI4S+C2v"
+ "/1+F6vWKMjTHGGEqp1joZZjlKqVIKIUQIMcbA5XKJ4xgAAEAIwRhL+hljSikhhOd51nVdl2az2UwmMxwOW63W6/Vqt9vr9XowGARB0Ov1giBIpVLdbrdSqZzP5+PxCEKI0Wi0"
+ "2Wwmk0mj0SgWi1JK3/cB4H6/c87DMHQcRwjx+XwwxoQQIoTwfb9Wq+VyOa11uVzmnEspC4XCfD5fLBb7/T6fzzebTSklLZVKu90uDMNqtTqdTk+nU7/fX61Wh8Nhu93OZjPOe"
+ "b1ej6JouVw+Hg/c6XSUUs/nEyHkOI7WWmttw8EYp9NpKWUcx5RSQojrumCMAQDP8xBCFrUp2WTf77fjOIwxm7LWGqyhtbapWzU5hb1X4mKMwULfgy2U3M4qiQvfxDf6X7E1+e"
+ "nnIYT+ABKG4uJL4UAgAAAAAElFTkSuQmCC\">Printing</A>"
+ ''
</DL><p>
</DL><p>
'';
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;
};
};
};
ghaf = optionalAttrs (hasAttr "storagevm" config.ghaf) {
storagevm = {
enable = true;
inherit (cfg) name;
directories = [ "/etc/cups/" ];
};
};
};
}
5 changes: 5 additions & 0 deletions modules/microvm/virtualization/microvm/netvm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 6 additions & 0 deletions modules/reference/appvms/business.nix
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ in
# Set default PDF XDG handler
xdg.mime.defaultApplications."application/pdf" = "ghaf-pdf.desktop";

# Enable printer service
ghaf.services.printer = {
enable = true;
name = "${name}";
};

# 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 = {
Expand Down
6 changes: 6 additions & 0 deletions modules/reference/appvms/chromium.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ in

# Set default PDF XDG handler
xdg.mime.defaultApplications."application/pdf" = "ghaf-pdf.desktop";

# Enable printer service
ghaf.services.printer = {
enable = true;
name = "${name}";
};
}
];
borderColor = "#630505";
Expand Down
5 changes: 5 additions & 0 deletions modules/reference/appvms/zathura.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
#this vm should be stateless so nothing stored between boots.
storagevm.enable = lib.mkForce false;
};
# Enable printer service
ghaf.services.printer = {
enable = true;
name = "zathura";
};
}
];
borderColor = "#122263";
Expand Down
14 changes: 14 additions & 0 deletions overlays/custom-packages/cups/default.nix
Original file line number Diff line number Diff line change
@@ -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=";
};
}
)
1 change: 1 addition & 0 deletions overlays/custom-packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
gtklock = import ./gtklock { inherit prev; };
hardware-scan = final.callPackage ../../packages/hardware-scan { };
pulseaudio-ghaf = import ./pulseaudio { inherit prev; };
cups = import ./cups { inherit final prev; };
})

0 comments on commit 82affee

Please sign in to comment.