clean up 'scope' decl
This commit is contained in:
parent
453d780695
commit
cb72b47661
28 changed files with 261 additions and 195 deletions
132
graphical/webapps.nix
Normal file
132
graphical/webapps.nix
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
browser = lib.getExe config.apps.browser;
|
||||
webAppLauncher = pkgs.writeShellScript "web-app-launcher" ''
|
||||
browser="${browser}"
|
||||
|
||||
browser_exec=""
|
||||
for path in ~/.local ~/.nix-profile /usr; do
|
||||
if [ -f "$path/share/applications/$browser.desktop" ]; then
|
||||
browser_exec=$(sed -n 's/^Exec=\([^ ]*\).*/\1/p' "$path/share/applications/$browser.desktop" 2>/dev/null | head -1)
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$browser_exec" ]; then
|
||||
browser_exec="${browser}"
|
||||
fi
|
||||
|
||||
url="$1"
|
||||
app_name="''${2:-$(basename "$0")}"
|
||||
shift 2
|
||||
|
||||
exec setsid "$browser_exec" \
|
||||
--app="$url" \
|
||||
--user-data-dir="$HOME/.local/share/web-apps/$app_name" \
|
||||
--no-first-run \
|
||||
--no-default-browser-check \
|
||||
--disable-background-timer-throttling \
|
||||
--disable-backgrounding-occluded-windows \
|
||||
--disable-renderer-backgrounding \
|
||||
--enable-quic \
|
||||
--quic-version=h3-29 \
|
||||
--enable-features=UseOzonePlatform,WaylandWindowDecorations,WaylandPerWindowScaling,WaylandTextInputV3,WebRTCPipeWireCapturer \
|
||||
--disable-features=WebRtcAllowInputVolumeAdjustment \
|
||||
--ozone-platform=wayland \
|
||||
--gtk-version=4 \
|
||||
--enable-experimental-web-platform-features \
|
||||
"$@"
|
||||
'';
|
||||
|
||||
# Create web app package
|
||||
createWebApp =
|
||||
{
|
||||
name,
|
||||
url,
|
||||
icon,
|
||||
description ? "",
|
||||
categories ? [
|
||||
"Network"
|
||||
"Chat"
|
||||
"InstantMessaging"
|
||||
],
|
||||
}:
|
||||
let
|
||||
pkgName = "${lib.replaceStrings [ " " ] [ "-" ] (lib.toLower name)}-web-app";
|
||||
in
|
||||
{
|
||||
name = pkgName;
|
||||
value = pkgs.stdenv.mkDerivation {
|
||||
pname = pkgName;
|
||||
version = "1.0";
|
||||
dontUnpack = true;
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkgs.copyDesktopItems
|
||||
pkgs.makeWrapper
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
makeWrapper ${webAppLauncher} $out/bin/${pkgName} \
|
||||
--add-flags "${url}" \
|
||||
--add-flags "${pkgName}"
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
desktopItems = [
|
||||
(pkgs.makeDesktopItem {
|
||||
inherit icon categories;
|
||||
name = pkgName;
|
||||
exec = "${pkgName} %U";
|
||||
desktopName = name;
|
||||
comment = description;
|
||||
startupNotify = true;
|
||||
startupWMClass = pkgName;
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
apps = builtins.listToAttrs (
|
||||
map createWebApp [
|
||||
{
|
||||
name = "Cinny";
|
||||
url = "https://chat.lobotomise.me";
|
||||
icon = "cinny";
|
||||
description = "Cinny, a Matrix client";
|
||||
}
|
||||
{
|
||||
name = "Discord";
|
||||
url = "https://discord.com/app";
|
||||
icon = "discord";
|
||||
description = "Discord Web";
|
||||
}
|
||||
{
|
||||
name = "FB Messenger";
|
||||
url = "https://m.me";
|
||||
icon = "facebook";
|
||||
description = "Facebook Messenger";
|
||||
}
|
||||
]
|
||||
);
|
||||
in
|
||||
{
|
||||
config = {
|
||||
environment.systemPackages = builtins.attrValues apps;
|
||||
|
||||
xdg.mime.defaultApplications = {
|
||||
"x-scheme-handler/matrix" = "cinny-web-app.desktop";
|
||||
};
|
||||
|
||||
environment.etc."web-apps-setup".text = ''
|
||||
mkdir -p /home/*/.local/share/web-apps
|
||||
'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue