sane.programs: allow per-program config (and port web-browser to use that)

This commit is contained in:
2023-05-08 09:49:58 +00:00
parent d220aadc2d
commit f89f136041
4 changed files with 66 additions and 45 deletions

View File

@@ -20,7 +20,7 @@
neededForUsers = true; neededForUsers = true;
}; };
sane.web-browser = { sane.programs.web-browser.config = {
# compromise impermanence for the sake of usability # compromise impermanence for the sake of usability
persistCache = "private"; persistCache = "private";
persistData = "private"; persistData = "private";

View File

@@ -1,7 +1,7 @@
{ config, sane-lib, ...}: { config, sane-lib, ...}:
let let
www = config.sane.web-browser.browser.desktop; www = config.sane.programs.web-browser.config.browser.desktop;
pdf = "org.gnome.Evince.desktop"; pdf = "org.gnome.Evince.desktop";
md = "obsidian.desktop"; md = "obsidian.desktop";
thumb = "org.gnome.gThumb.desktop"; thumb = "org.gnome.gThumb.desktop";

View File

@@ -9,7 +9,7 @@
{ config, lib, pkgs, sane-lib, ...}: { config, lib, pkgs, sane-lib, ...}:
with lib; with lib;
let let
cfg = config.sane.web-browser; cfg = config.sane.programs.web-browser.config;
# allow easy switching between firefox and librewolf with `defaultSettings`, below # allow easy switching between firefox and librewolf with `defaultSettings`, below
librewolfSettings = { librewolfSettings = {
browser = pkgs.librewolf-unwrapped; browser = pkgs.librewolf-unwrapped;
@@ -100,24 +100,24 @@ let
}; };
}; };
}; };
in
{ configOpts = {
options = { options = {
sane.web-browser.browser = mkOption { browser = mkOption {
default = defaultSettings; default = defaultSettings;
type = types.attrs; type = types.anything;
}; };
sane.web-browser.persistData = mkOption { persistData = mkOption {
description = "optional store name to which persist browsing data (like history)"; description = "optional store name to which persist browsing data (like history)";
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
}; };
sane.web-browser.persistCache = mkOption { persistCache = mkOption {
description = "optional store name to which persist browser cache"; description = "optional store name to which persist browser cache";
type = types.nullOr types.str; type = types.nullOr types.str;
default = "cryptClearOnBoot"; default = "cryptClearOnBoot";
}; };
sane.web-browser.addons = mkOption { addons = mkOption {
type = types.attrsOf addonOpts; type = types.attrsOf addonOpts;
default = { default = {
# get names from: # get names from:
@@ -145,8 +145,16 @@ in
}; };
}; };
}; };
};
in
{
config = mkMerge [ config = mkMerge [
({
sane.programs.web-browser.configOption = mkOption {
type = types.submodule configOpts;
default = {};
};
})
({ ({
sane.programs.web-browser = { sane.programs.web-browser = {
inherit package; inherit package;

View File

@@ -104,6 +104,19 @@ let
the secret will have same owner as the user under which the program is enabled. the secret will have same owner as the user under which the program is enabled.
''; '';
}; };
configOption = mkOption {
type = types.raw;
default = mkOption {
type = types.submodule {};
default = {};
};
description = ''
declare any other options the program may be configured with.
you probably want this to be a submodule.
the option *definitions* can be set with `sane.programs."foo".config = ...`.
'';
};
config = config.configOption;
}; };
config = { config = {