2022-11-02 10:06:05 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.xfconf;
|
|
|
|
|
2023-05-05 10:52:22 +02:00
|
|
|
xfIntVariant = types.submodule {
|
|
|
|
options = {
|
|
|
|
type = mkOption {
|
|
|
|
type = types.enum [ "int" "uint" "uint64" ];
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-05-05 10:52:22 +02:00
|
|
|
To distinguish between int, uint and uint64 in xfconf,
|
|
|
|
you can specify the type in xfconf with this submodule.
|
|
|
|
For other types, you don't need to use this submodule,
|
|
|
|
just specify the value is enough.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
value = mkOption {
|
|
|
|
type = types.int;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "The value in xfconf.";
|
2023-05-05 10:52:22 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-11-02 10:06:05 +01:00
|
|
|
withType = v:
|
2023-05-05 10:52:22 +02:00
|
|
|
if builtins.isAttrs v then [
|
|
|
|
"-t"
|
|
|
|
v.type
|
|
|
|
"-s"
|
|
|
|
(toString v.value)
|
|
|
|
] else if builtins.isBool v then [
|
2022-11-02 10:06:05 +01:00
|
|
|
"-t"
|
|
|
|
"bool"
|
|
|
|
"-s"
|
|
|
|
(if v then "true" else "false")
|
|
|
|
] else if builtins.isInt v then [
|
|
|
|
"-t"
|
|
|
|
"int"
|
|
|
|
"-s"
|
|
|
|
(toString v)
|
|
|
|
] else if builtins.isFloat v then [
|
|
|
|
"-t"
|
|
|
|
"double"
|
|
|
|
"-s"
|
|
|
|
(toString v)
|
|
|
|
] else if builtins.isString v then [
|
|
|
|
"-t"
|
|
|
|
"string"
|
|
|
|
"-s"
|
|
|
|
v
|
|
|
|
] else if builtins.isList v then
|
|
|
|
[ "-a" ] ++ concatMap withType v
|
|
|
|
else
|
|
|
|
throw "unexpected xfconf type: ${builtins.typeOf v}";
|
|
|
|
|
|
|
|
in {
|
|
|
|
meta.maintainers = [ maintainers.chuangzhu ];
|
|
|
|
|
|
|
|
options.xfconf = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
visible = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2022-11-02 10:06:05 +01:00
|
|
|
Whether to enable Xfconf settings.
|
2023-07-01 01:30:13 +02:00
|
|
|
|
2022-11-02 10:06:05 +01:00
|
|
|
Note, if you use NixOS then you must add
|
2023-07-01 01:30:13 +02:00
|
|
|
`programs.xfconf.enable = true`
|
2022-11-02 10:06:05 +01:00
|
|
|
to your system configuration. Otherwise you will see a systemd error
|
|
|
|
message when your configuration is activated.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = with types;
|
2023-05-07 22:20:49 +02:00
|
|
|
# xfIntVariant must come AFTER str; otherwise strings are treated as submodule imports...
|
2023-07-03 20:34:42 +02:00
|
|
|
let value = nullOr (oneOf [ bool int float str xfIntVariant ]);
|
2023-05-07 22:20:49 +02:00
|
|
|
in attrsOf (attrsOf (either value (listOf value))) // {
|
2022-11-02 10:06:05 +01:00
|
|
|
description = "xfconf settings";
|
|
|
|
};
|
|
|
|
default = { };
|
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
xfce4-session = {
|
|
|
|
"startup/ssh-agent/enabled" = false;
|
|
|
|
"general/LockCommand" = "''${pkgs.lightdm}/bin/dm-tool lock";
|
|
|
|
};
|
|
|
|
xfce4-desktop = {
|
|
|
|
"backdrop/screen0/monitorLVDS-1/workspace0/last-image" =
|
|
|
|
"''${pkgs.nixos-artwork.wallpapers.stripes-logo.gnomeFilePath}";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2022-11-02 10:06:05 +01:00
|
|
|
Settings to write to the Xfconf configuration system.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf (cfg.enable && cfg.settings != { }) {
|
|
|
|
assertions =
|
|
|
|
[ (hm.assertions.assertPlatform "xfconf" pkgs platforms.linux) ];
|
|
|
|
|
|
|
|
home.activation.xfconfSettings = hm.dag.entryAfter [ "installPackages" ]
|
|
|
|
(let
|
|
|
|
mkCommand = channel: property: value: ''
|
2024-01-13 23:15:00 +01:00
|
|
|
run ${pkgs.xfce.xfconf}/bin/xfconf-query \
|
2022-11-02 10:06:05 +01:00
|
|
|
${
|
2023-07-03 20:34:42 +02:00
|
|
|
escapeShellArgs ([ "-c" channel "-p" "/${property}" ]
|
|
|
|
++ (if value == null then
|
|
|
|
[ "-r" ]
|
|
|
|
else
|
|
|
|
[ "-n" ] ++ withType value))
|
2022-11-02 10:06:05 +01:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
|
|
|
commands = mapAttrsToList
|
|
|
|
(channel: properties: mapAttrsToList (mkCommand channel) properties)
|
|
|
|
cfg.settings;
|
2023-03-05 09:47:06 +01:00
|
|
|
|
2024-02-01 00:24:56 +01:00
|
|
|
load = pkgs.writeShellScript "load-xfconf" ''
|
|
|
|
${config.lib.bash.initHomeManagerLib}
|
|
|
|
${concatMapStrings concatStrings commands}
|
|
|
|
'';
|
2023-03-05 09:47:06 +01:00
|
|
|
in ''
|
|
|
|
if [[ -v DBUS_SESSION_BUS_ADDRESS ]]; then
|
|
|
|
export DBUS_RUN_SESSION_CMD=""
|
|
|
|
else
|
|
|
|
export DBUS_RUN_SESSION_CMD="${pkgs.dbus}/bin/dbus-run-session --dbus-daemon=${pkgs.dbus}/bin/dbus-daemon"
|
|
|
|
fi
|
|
|
|
|
2024-01-13 23:15:00 +01:00
|
|
|
run $DBUS_RUN_SESSION_CMD ${load}
|
2023-03-05 09:47:06 +01:00
|
|
|
|
|
|
|
unset DBUS_RUN_SESSION_CMD
|
|
|
|
'');
|
2022-11-02 10:06:05 +01:00
|
|
|
};
|
|
|
|
}
|