1
Fork 0
satellite/modules/home-manager/firefox/default.nix

88 lines
2.5 KiB
Nix
Raw Normal View History

# Allows installing web apps as desktop apps
{ 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
{
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
app = lib.mkOption {
2023-05-28 05:24:36 +02:00
default = { };
description = "Attr set of firefox web apps to install as desktop apps";
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
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
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
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-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;
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";
exec = "firefox --name=${app.displayName} --no-remote -P \"${app.name}\" \"${app.url}\"";
icon = app.icon;
};
in
{
programs.firefox.profiles = lib.mapAttrs (_: mkProfile) cfg.app;
xdg.desktopEntries = lib.mapAttrs (_: mkDesktopEntry) cfg.app;
2023-01-15 23:04:11 +01:00
};
}