hylonix/modules/home-manager/gecko-browser/gecko-lib/prefs.nix

50 lines
938 B
Nix
Raw Normal View History

{
pkgs,
lib,
info,
...
}:
let
type = lib.types.attrsOf (
lib.types.oneOf [
lib.types.int
lib.types.bool
lib.types.str
]
);
in
{
inherit type;
options = {
prefs = lib.mkOption {
inherit type;
default = { };
description = "User preferences.";
};
lockPref = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = "When adding user preferences, determine whether to use lockPref over user_pref";
};
};
postprocess =
{ lockPref, prefs, ... }:
{
prefs =
builtins.concatStringsSep "\n"
<| (x: [ "// Generated by ${info.name} module" ] ++ x)
<| lib.mapAttrsToList (
let
prefFunc = if lockPref then "lockPref" else "user_pref";
in
key: val: ''${prefFunc}("${key}", ${builtins.toJSON val});''
)
<| prefs;
};
}