mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-11-19 14:18:17 +01:00
feat(nixpak): sandbox Foliate and Krita (#494)
Assisted-by: DeepSeek Harness (deepseek-flash)
This commit is contained in:
1 parent
090a7b622b
commit
3e6d89b3c4
10 files changed
+227
-2
No files matched your search
@@ -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.
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
})
|
||||
];
|
||||
}
|
||||
@@ -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;
|
||||
})
|
||||
];
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
@@ -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:
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# GUI apps
|
||||
# e-book viewer(.epub/.mobi/...)
|
||||
# do not support .pdf
|
||||
foliate
|
||||
nixpaks.foliate
|
||||
|
||||
# remote desktop(rdp connect)
|
||||
remmina
|
||||
|
||||
Reference in new issue
Block a user