mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 13:13:26 +00:00
9f9e277b60
These (and the `*MD` functions apart from `literalMD`) are now no-ops in nixpkgs and serve no purpose other than to add additional noise and potentially mislead people into thinking unmarked DocBook documentation will still be accepted. Note that if backporting changes including documentation to 23.05, the `mdDoc` calls will need to be re-added. To reproduce this commit, run: $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \ nix shell nixpkgs#coreutils \ -c find . -name '*.nix' \ -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \ --strip {} + $ ./format
137 lines
3.7 KiB
Nix
137 lines
3.7 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.xfconf;
|
|
|
|
xfIntVariant = types.submodule {
|
|
options = {
|
|
type = mkOption {
|
|
type = types.enum [ "int" "uint" "uint64" ];
|
|
description = ''
|
|
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;
|
|
description = "The value in xfconf.";
|
|
};
|
|
};
|
|
};
|
|
|
|
withType = v:
|
|
if builtins.isAttrs v then [
|
|
"-t"
|
|
v.type
|
|
"-s"
|
|
(toString v.value)
|
|
] else if builtins.isBool v then [
|
|
"-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;
|
|
description = ''
|
|
Whether to enable Xfconf settings.
|
|
|
|
Note, if you use NixOS then you must add
|
|
`programs.xfconf.enable = true`
|
|
to your system configuration. Otherwise you will see a systemd error
|
|
message when your configuration is activated.
|
|
'';
|
|
};
|
|
|
|
settings = mkOption {
|
|
type = with types;
|
|
# xfIntVariant must come AFTER str; otherwise strings are treated as submodule imports...
|
|
let value = nullOr (oneOf [ bool int float str xfIntVariant ]);
|
|
in attrsOf (attrsOf (either value (listOf value))) // {
|
|
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}";
|
|
};
|
|
}
|
|
'';
|
|
description = ''
|
|
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: ''
|
|
$DRY_RUN_CMD ${pkgs.xfce.xfconf}/bin/xfconf-query \
|
|
${
|
|
escapeShellArgs ([ "-c" channel "-p" "/${property}" ]
|
|
++ (if value == null then
|
|
[ "-r" ]
|
|
else
|
|
[ "-n" ] ++ withType value))
|
|
}
|
|
'';
|
|
|
|
commands = mapAttrsToList
|
|
(channel: properties: mapAttrsToList (mkCommand channel) properties)
|
|
cfg.settings;
|
|
|
|
load = pkgs.writeShellScript "load-xfconf"
|
|
(concatMapStrings concatStrings commands);
|
|
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
|
|
|
|
$DRY_RUN_CMD $DBUS_RUN_SESSION_CMD ${load}
|
|
|
|
unset DBUS_RUN_SESSION_CMD
|
|
'');
|
|
};
|
|
}
|