diff --git a/hardening/README.md b/hardening/README.md index 91a81564..3090704e 100644 --- a/hardening/README.md +++ b/hardening/README.md @@ -30,6 +30,8 @@ explicitly; other files use the document portal. Every app also has private writ | Telegram | Isolated | Personal files, private app state | Media, notifications, tray, MPRIS, idle, accessibility, Ayatana indicators | | Zoom | Isolated | `~/.zoom`, `zoomus.conf`, `zoom.conf`, Downloads, `Documents/Zoom`, private app state | Media, X11/XWayland, FHS, SNI tray, idle, `/dev/video0-1`, read-only `/sys/class/drm` | | WeChat | Isolated | Documents, Downloads, app-scoped `wechat` data, private app state | Media, Wayland, X11 fallback, SNI tray, file chooser portal | +| Foliate | None | app-scoped state | File chooser, OpenURI, notifications, IME, accessibility | +| Krita | None | app-scoped state | File chooser, OpenURI, print, inhibit, notifications, IME, accessibility | All browsers get read-only NSS certificates, printing, native notifications and accessibility. diff --git a/hardening/nixpaks/default.nix b/hardening/nixpaks/default.nix index c9c99bca..6871e888 100644 --- a/hardening/nixpaks/default.nix +++ b/hardening/nixpaks/default.nix @@ -2,6 +2,7 @@ pkgs, pkgs-master, pkgs-patched, + pkgs-stable, nixpak, ... }: @@ -26,6 +27,8 @@ in chromium = wrapper super ./chromium.nix; brave-origin = wrapper super ./brave-origin.nix; microsoft-edge = wrapper super ./microsoft-edge.nix; + foliate = wrapper super ./foliate.nix; + krita = wrapper pkgs-stable ./krita.nix; zoom = wrapper super ./zoom.nix; wechat = wrapper pkgs-patched ./wechat.nix; }; diff --git a/hardening/nixpaks/foliate.nix b/hardening/nixpaks/foliate.nix new file mode 100644 index 00000000..f4313f9d --- /dev/null +++ b/hardening/nixpaks/foliate.nix @@ -0,0 +1,62 @@ +{ + lib, + foliate, + mkNixPak, + buildEnv, + makeDesktopItem, + runCommandLocal, + ... +}: +let + appId = "com.github.johnfactotum.Foliate"; + wrapped = mkNixPak { + config = { + imports = [ ./modules/file-viewer-policy.nix ]; + app = { + package = foliate; + binPath = "bin/foliate"; + }; + flatpak = { inherit appId; }; + }; + }; + exe = lib.getExe wrapped.config.script; + assets = runCommandLocal "foliate-desktop-assets" { } '' + mkdir -p $out/share + ln -s ${foliate}/share/icons $out/share/icons + ''; +in +buildEnv { + inherit (wrapped.config.script) name passthru; + meta = wrapped.config.script.meta // { + mainProgram = "foliate"; + }; + paths = [ + wrapped.config.script + assets + (makeDesktopItem { + name = "com.github.johnfactotum.Foliate"; + desktopName = "Foliate"; + genericName = "E-Book Viewer"; + comment = "Read e-books in style"; + exec = "${exe} %U"; + icon = "com.github.johnfactotum.Foliate"; + terminal = false; + startupNotify = true; + startupWMClass = "com.github.johnfactotum.Foliate"; + categories = [ + "Office" + "Viewer" + ]; + mimeTypes = [ + "application/epub+zip" + "application/x-mobipocket-ebook" + "application/vnd.amazon.mobi8-ebook" + "application/x-fictionbook+xml" + "application/x-zip-compressed-fb2" + "application/vnd.comicbook+zip" + "x-scheme-handler/opds" + ]; + extraConfig.X-Flatpak = appId; + }) + ]; +} diff --git a/hardening/nixpaks/krita.nix b/hardening/nixpaks/krita.nix new file mode 100644 index 00000000..bacf9e32 --- /dev/null +++ b/hardening/nixpaks/krita.nix @@ -0,0 +1,71 @@ +{ + lib, + krita, + mkNixPak, + buildEnv, + makeDesktopItem, + runCommandLocal, + ... +}: +let + appId = "org.kde.krita"; + wrapped = mkNixPak { + config = { + imports = [ ./modules/file-viewer-policy.nix ]; + app = { + package = krita; + binPath = "bin/krita"; + }; + flatpak = { inherit appId; }; + # Qt defaults to xcb when DISPLAY is present in the parent environment; + # niri has no X server, so select Wayland explicitly. + bubblewrap.env.QT_QPA_PLATFORM = "wayland"; + # Krita saves edits in place, so the common user directories are writable. + fileViewer.writableUserDirs = true; + # Printing and sleep inhibition are explicit Krita capabilities. + portalGroups = { + print = true; + inhibit = true; + }; + }; + }; + exe = lib.getExe wrapped.config.script; + assets = runCommandLocal "krita-desktop-assets" { } '' + mkdir -p $out/share + ln -s ${krita}/share/icons $out/share/icons + ''; +in +buildEnv { + inherit (wrapped.config.script) name passthru; + meta = wrapped.config.script.meta // { + mainProgram = "krita"; + }; + paths = [ + wrapped.config.script + assets + (makeDesktopItem { + name = "org.kde.krita"; + desktopName = "Krita"; + genericName = "Digital Painting"; + comment = "Digital painting and illustration"; + exec = "${exe} %F"; + icon = "krita"; + terminal = false; + startupNotify = true; + startupWMClass = "krita"; + categories = [ + "Qt" + "KDE" + "Graphics" + "2DGraphics" + "RasterGraphics" + ]; + mimeTypes = [ + "application/x-krita" + "image/openraster" + "application/x-krita-paintoppreset" + ]; + extraConfig.X-Flatpak = appId; + }) + ]; +} diff --git a/hardening/nixpaks/modules/file-viewer-policy.nix b/hardening/nixpaks/modules/file-viewer-policy.nix new file mode 100644 index 00000000..904e9e73 --- /dev/null +++ b/hardening/nixpaks/modules/file-viewer-policy.nix @@ -0,0 +1,40 @@ +# Shared minimal policy for local file viewers. No network, audio or devices; +# files selected through the desktop portal, plus common user document folders +# for direct file-manager launches. +{ + config, + lib, + sloth, + ... +}: +let + cfg = config.fileViewer; + userDirs = [ + sloth.xdgDocumentsDir + sloth.xdgDownloadDir + sloth.xdgPicturesDir + ]; +in +{ + imports = [ ./desktop-base.nix ]; + options.fileViewer.writableUserDirs = lib.mkEnableOption '' + writing to Documents, Downloads and Pictures for apps that save edits + ''; + config = { + portalGroups = { + fileChooser = true; + openUri = true; + notifications = true; + inputMethod = true; + }; + desktopIntegration = { + notifications = true; + accessibility = true; + }; + bubblewrap = { + sockets.pulse = lib.mkForce false; + bind.ro = lib.mkIf (!cfg.writableUserDirs) userDirs; + bind.rw = lib.mkIf cfg.writableUserDirs userDirs; + }; + }; +} diff --git a/hardening/tests/policy/foliate.nix b/hardening/tests/policy/foliate.nix new file mode 100644 index 00000000..1e03e27d --- /dev/null +++ b/hardening/tests/policy/foliate.nix @@ -0,0 +1,21 @@ +{ + load, + mkAppPolicy, + ... +}: +let + app = load "foliate"; +in +mkAppPolicy "foliate" { + network = "none"; + media = false; + x11 = false; + notifications = true; + extraChecks = { + fileChooser = app.portalGroups.fileChooser; + openUri = app.portalGroups.openUri; + inputMethod = app.portalGroups.inputMethod; + accessibility = app.desktopIntegration.accessibility; + writableUserDirs = app.fileViewer.writableUserDirs == false; + }; +} diff --git a/hardening/tests/policy/krita.nix b/hardening/tests/policy/krita.nix new file mode 100644 index 00000000..e0aa5f04 --- /dev/null +++ b/hardening/tests/policy/krita.nix @@ -0,0 +1,24 @@ +{ + load, + mkAppPolicy, + ... +}: +let + app = load "krita"; +in +mkAppPolicy "krita" { + network = "none"; + media = false; + x11 = false; + notifications = true; + extraChecks = { + fileChooser = app.portalGroups.fileChooser; + openUri = app.portalGroups.openUri; + inputMethod = app.portalGroups.inputMethod; + print = app.portalGroups.print; + inhibit = app.portalGroups.inhibit; + accessibility = app.desktopIntegration.accessibility; + qtWayland = app.bubblewrap.env.QT_QPA_PLATFORM == "wayland"; + writableUserDirs = app.fileViewer.writableUserDirs == true; + }; +} diff --git a/hardening/tests/runtime-validation.md b/hardening/tests/runtime-validation.md index b332fc3c..6dc07fbd 100644 --- a/hardening/tests/runtime-validation.md +++ b/hardening/tests/runtime-validation.md @@ -22,6 +22,8 @@ Nixpak wrappers are accepted in three layers: | Zoom | Pass | Interactive pass | | QQ / Telegram | Pass | Interactive startup/tray pass | | WeChat (native nixpak) | Pass | Interactive Wayland validation pending | +| Foliate | Pass | Interactive validation pending | +| Krita | Pass | Interactive validation pending | Intentional exceptions: diff --git a/home/linux/gui/base/creative.nix b/home/linux/gui/base/creative.nix index 4b275a40..d8c40aa1 100644 --- a/home/linux/gui/base/creative.nix +++ b/home/linux/gui/base/creative.nix @@ -20,7 +20,7 @@ in { home.packages = with pkgs-stable; [ # creative - krita # digital painting + pkgs.nixpaks.krita # digital painting musescore # music notation pkgs-master.orca-slicer # 3d printer slicer app bambu-studio # bambu 3d printer slicer app diff --git a/home/linux/gui/base/misc.nix b/home/linux/gui/base/misc.nix index 211b7de0..82b598b6 100644 --- a/home/linux/gui/base/misc.nix +++ b/home/linux/gui/base/misc.nix @@ -7,7 +7,7 @@ # GUI apps # e-book viewer(.epub/.mobi/...) # do not support .pdf - foliate + nixpaks.foliate # remote desktop(rdp connect) remmina