2026-02-22 19:57:42 +00:00
|
|
|
{
|
|
|
|
|
pkgs,
|
|
|
|
|
lib,
|
2026-02-23 22:08:18 +00:00
|
|
|
sLib,
|
2026-02-22 19:57:42 +00:00
|
|
|
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, ... }:
|
|
|
|
|
{
|
2026-02-23 22:08:18 +00:00
|
|
|
prefs = sLib.compose [
|
|
|
|
|
(builtins.concatStringsSep "\n")
|
|
|
|
|
(x: [ "// Generated by ${info.name} module" ] ++ x)
|
|
|
|
|
(lib.mapAttrsToList (
|
2026-02-22 19:57:42 +00:00
|
|
|
let
|
|
|
|
|
prefFunc = if lockPref then "lockPref" else "user_pref";
|
|
|
|
|
in
|
|
|
|
|
key: val: ''${prefFunc}("${key}", ${builtins.toJSON val});''
|
2026-02-23 22:08:18 +00:00
|
|
|
))
|
|
|
|
|
] prefs;
|
2026-02-22 19:57:42 +00:00
|
|
|
};
|
|
|
|
|
}
|