2023-05-18 01:56:19 +02:00
|
|
|
# Allows installing web apps as desktop apps
|
2023-11-11 06:55:14 +01:00
|
|
|
{ lib, config, ... }:
|
2023-03-12 05:24:25 +01:00
|
|
|
let cfg = config.programs.firefox.apps;
|
2023-01-15 23:04:11 +01:00
|
|
|
in
|
|
|
|
{
|
2023-05-18 01:56:19 +02:00
|
|
|
options.programs.firefox.apps = {
|
|
|
|
extensions = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.package;
|
|
|
|
description = "Extensions to install for all apps";
|
|
|
|
default = [ ];
|
|
|
|
};
|
2023-01-15 23:04:11 +01:00
|
|
|
|
2023-05-18 01:56:19 +02:00
|
|
|
app = lib.mkOption {
|
2023-05-28 05:24:36 +02:00
|
|
|
default = { };
|
|
|
|
description = "Attr set of firefox web apps to install as desktop apps";
|
2023-05-18 01:56:19 +02:00
|
|
|
type = lib.types.attrsOf
|
|
|
|
(lib.types.submodule ({ name, ... }: {
|
|
|
|
options = {
|
|
|
|
name = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "The name of the app";
|
|
|
|
default = name;
|
|
|
|
};
|
2023-01-15 23:04:11 +01:00
|
|
|
|
2023-05-18 01:56:19 +02:00
|
|
|
id = lib.mkOption {
|
|
|
|
type = lib.types.int;
|
|
|
|
description = "The id of the firefox profile for the app";
|
|
|
|
example = 3;
|
|
|
|
};
|
2023-01-15 23:04:11 +01:00
|
|
|
|
2023-05-18 01:56:19 +02:00
|
|
|
displayName = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "The name of the app in stuff like menus";
|
|
|
|
default = name;
|
|
|
|
};
|
2023-01-15 23:04:11 +01:00
|
|
|
|
2023-05-18 01:56:19 +02:00
|
|
|
url = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "The url the app should point to";
|
|
|
|
example = "https://example.com";
|
|
|
|
};
|
|
|
|
|
|
|
|
icon = lib.mkOption {
|
|
|
|
type = lib.types.path;
|
|
|
|
description = "The icon to use for the app";
|
|
|
|
};
|
|
|
|
|
|
|
|
extensions = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.package;
|
|
|
|
description = "Extensions to install for this app";
|
|
|
|
default = [ ];
|
|
|
|
};
|
2023-01-15 23:04:11 +01:00
|
|
|
};
|
2023-05-18 01:56:19 +02:00
|
|
|
}));
|
|
|
|
};
|
2023-01-15 23:04:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config =
|
|
|
|
let
|
|
|
|
mkProfile = app: {
|
|
|
|
settings = {
|
|
|
|
# Customize css
|
|
|
|
"toolkit.legacyUserProfileCustomizations.stylesheets" = true;
|
|
|
|
|
|
|
|
# Set language to english
|
|
|
|
"general.useragent.locale" = "en-GB";
|
|
|
|
};
|
|
|
|
|
|
|
|
userChrome = builtins.readFile ./theme.css;
|
2023-05-18 01:56:19 +02:00
|
|
|
extensions = cfg.extensions ++ app.extensions;
|
2023-01-15 23:04:11 +01:00
|
|
|
isDefault = false;
|
|
|
|
id = app.id;
|
|
|
|
};
|
|
|
|
|
|
|
|
mkDesktopEntry = app: {
|
|
|
|
terminal = false;
|
|
|
|
name = app.displayName;
|
|
|
|
type = "Application";
|
2023-11-13 04:03:14 +01:00
|
|
|
exec = "firefox --name=${app.displayName} --no-remote --kiosk -P \"${app.name}\" \"${app.url}\"";
|
2023-01-15 23:04:11 +01:00
|
|
|
icon = app.icon;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
2023-05-18 01:56:19 +02:00
|
|
|
programs.firefox.profiles = lib.mapAttrs (_: mkProfile) cfg.app;
|
|
|
|
xdg.desktopEntries = lib.mapAttrs (_: mkDesktopEntry) cfg.app;
|
2023-01-15 23:04:11 +01:00
|
|
|
};
|
|
|
|
}
|