-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update XDG handlers to use GIVC instead of SSH
Signed-off-by: Yuri Nesterov <[email protected]>
- Loading branch information
Showing
14 changed files
with
250 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
modules/microvm/virtualization/microvm/common/xdghandlers.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
{ | ||
lib, | ||
config, | ||
pkgs, | ||
... | ||
}: | ||
let | ||
cfg = config.ghaf.xdghandlers; | ||
xdgOpenPdf = pkgs.writeShellApplication { | ||
name = "xdgopenpdf"; | ||
runtimeInputs = [ | ||
pkgs.coreutils | ||
]; | ||
# TODO: fix the url hack once GIVC supports file path arguments | ||
text = '' | ||
#!${pkgs.runtimeShell} | ||
file="$1" | ||
if [[ "$file" == http://example.com?p=* ]]; then | ||
file="''${file:21}" | ||
file=$(echo -n "$file" | base64 --decode) | ||
fi | ||
echo "XDG open PDF: $file" | ||
${config.ghaf.givc.appPrefix}/run-waypipe ${config.ghaf.givc.appPrefix}/zathura "$file" | ||
rm "$file" | ||
''; | ||
}; | ||
xdgOpenImage = pkgs.writeShellApplication { | ||
name = "xdgopenimage"; | ||
runtimeInputs = [ | ||
pkgs.coreutils | ||
]; | ||
# TODO: fix the url hack once GIVC supports file path arguments | ||
text = '' | ||
#!${pkgs.runtimeShell} | ||
file="$1" | ||
if [[ "$file" == http://example.com?p=* ]]; then | ||
file="''${file:21}" | ||
file=$(echo -n "$file" | base64 --decode) | ||
fi | ||
echo "XDG open image: $file" | ||
${config.ghaf.givc.appPrefix}/run-waypipe ${config.ghaf.givc.appPrefix}/pqiv -i "$file" | ||
rm "$file" | ||
''; | ||
}; | ||
in | ||
{ | ||
options.ghaf.xdghandlers = { | ||
enable = lib.mkEnableOption "XDG Handlers"; | ||
}; | ||
|
||
config = lib.mkIf cfg.enable { | ||
|
||
environment.systemPackages = [ | ||
pkgs.zathura | ||
pkgs.pqiv | ||
]; | ||
|
||
ghaf.givc.appvm.applications = [ | ||
{ | ||
name = "xdg-pdf"; | ||
command = "${xdgOpenPdf}/bin/xdgopenpdf"; | ||
args = [ "url" ]; | ||
} | ||
{ | ||
name = "xdg-image"; | ||
command = "${xdgOpenImage}/bin/xdgopenimage"; | ||
args = [ "url" ]; | ||
} | ||
]; | ||
|
||
microvm.shares = [ | ||
{ | ||
tag = "xdgshare-pdf"; | ||
proto = "virtiofs"; | ||
securityModel = "passthrough"; | ||
source = "/storagevm/shared/shares/xdg/pdf"; | ||
mountPoint = "/run/xdg/pdf"; | ||
} | ||
{ | ||
tag = "xdgshare-image"; | ||
proto = "virtiofs"; | ||
securityModel = "passthrough"; | ||
source = "/storagevm/shared/shares/xdg/image"; | ||
mountPoint = "/run/xdg/image"; | ||
} | ||
]; | ||
|
||
fileSystems = { | ||
"/run/xdg/pdf".options = [ | ||
"rw" | ||
"nodev" | ||
"nosuid" | ||
"noexec" | ||
]; | ||
"/run/xdg/image".options = [ | ||
"rw" | ||
"nodev" | ||
"nosuid" | ||
"noexec" | ||
]; | ||
}; | ||
|
||
systemd.tmpfiles.rules = [ | ||
"d /run/xdg/pdf 0700 ${toString config.ghaf.users.loginUser.uid}" | ||
"d /run/xdg/image 0700 ${toString config.ghaf.users.loginUser.uid}" | ||
]; | ||
}; | ||
} |
Oops, something went wrong.