mirror of
https://github.com/nix-community/home-manager
synced 2024-11-27 05:29:46 +01:00
xsettingsd: make configurable through module
This commit is contained in:
parent
959217e51d
commit
52e84a040e
5 changed files with 77 additions and 1 deletions
|
@ -6,6 +6,20 @@ let
|
||||||
|
|
||||||
cfg = config.services.xsettingsd;
|
cfg = config.services.xsettingsd;
|
||||||
|
|
||||||
|
renderSettings = settings:
|
||||||
|
concatStrings (mapAttrsToList renderSetting settings);
|
||||||
|
|
||||||
|
renderSetting = key: value: ''
|
||||||
|
${key} ${renderValue value}
|
||||||
|
'';
|
||||||
|
|
||||||
|
renderValue = value:
|
||||||
|
{
|
||||||
|
int = toString value;
|
||||||
|
bool = if value then "1" else "0";
|
||||||
|
string = ''"${value}"'';
|
||||||
|
}.${builtins.typeOf value};
|
||||||
|
|
||||||
in {
|
in {
|
||||||
meta.maintainers = [ maintainers.imalison ];
|
meta.maintainers = [ maintainers.imalison ];
|
||||||
|
|
||||||
|
@ -21,6 +35,34 @@ in {
|
||||||
Package containing the <command>xsettingsd</command> program.
|
Package containing the <command>xsettingsd</command> program.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
settings = mkOption {
|
||||||
|
type = with types; attrsOf (oneOf [ bool int str ]);
|
||||||
|
default = { };
|
||||||
|
example = literalExample ''
|
||||||
|
{
|
||||||
|
"Net/ThemeName" = "Numix";
|
||||||
|
"Xft/Antialias" = true;
|
||||||
|
"Xft/Hinting" = true;
|
||||||
|
"Xft/RGBA" = "rgb";
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
Xsettingsd options for configuration file. See
|
||||||
|
<link xlink:href="https://github.com/derat/xsettingsd/wiki/Settings"/>
|
||||||
|
for documentation on these values.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
configFile = mkOption {
|
||||||
|
type = types.nullOr types.package;
|
||||||
|
internal = true;
|
||||||
|
readOnly = true;
|
||||||
|
default = if cfg.settings == { } then
|
||||||
|
null
|
||||||
|
else
|
||||||
|
pkgs.writeText "xsettingsd.conf" (renderSettings cfg.settings);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -41,7 +83,9 @@ in {
|
||||||
|
|
||||||
Service = {
|
Service = {
|
||||||
Environment = "PATH=${config.home.profileDirectory}/bin";
|
Environment = "PATH=${config.home.profileDirectory}/bin";
|
||||||
ExecStart = "${cfg.package}/bin/xsettingsd";
|
ExecStart = "${cfg.package}/bin/xsettingsd"
|
||||||
|
+ optionalString (cfg.configFile != null)
|
||||||
|
" -c ${escapeShellArg cfg.configFile}";
|
||||||
Restart = "on-abort";
|
Restart = "on-abort";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -139,6 +139,7 @@ import nmt {
|
||||||
./modules/services/window-managers/i3
|
./modules/services/window-managers/i3
|
||||||
./modules/services/window-managers/sway
|
./modules/services/window-managers/sway
|
||||||
./modules/services/wlsunset
|
./modules/services/wlsunset
|
||||||
|
./modules/services/xsettingsd
|
||||||
./modules/systemd
|
./modules/systemd
|
||||||
./modules/targets-linux
|
./modules/targets-linux
|
||||||
] ++ lib.optionals enableBig [
|
] ++ lib.optionals enableBig [
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Net/ThemeName "Numix"
|
||||||
|
Xft/Antialias 1
|
||||||
|
Xft/Hinting 1
|
||||||
|
Xft/RGBA "rgb"
|
26
tests/modules/services/xsettingsd/basic-configuration.nix
Normal file
26
tests/modules/services/xsettingsd/basic-configuration.nix
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
services.xsettingsd = {
|
||||||
|
enable = true;
|
||||||
|
package = config.lib.test.mkStubPackage { };
|
||||||
|
settings = {
|
||||||
|
"Net/ThemeName" = "Numix";
|
||||||
|
"Xft/Antialias" = true;
|
||||||
|
"Xft/Hinting" = true;
|
||||||
|
"Xft/RGBA" = "rgb";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
nmt.script = ''
|
||||||
|
serviceFile=home-files/.config/systemd/user/xsettingsd.service
|
||||||
|
|
||||||
|
assertFileExists $serviceFile
|
||||||
|
assertFileRegex $serviceFile 'ExecStart=.*/bin/xsettingsd.*'
|
||||||
|
|
||||||
|
assertFileExists ${config.services.xsettingsd.configFile}
|
||||||
|
assertFileContent ${config.services.xsettingsd.configFile} \
|
||||||
|
${./basic-configuration.conf}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
1
tests/modules/services/xsettingsd/default.nix
Normal file
1
tests/modules/services/xsettingsd/default.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ xsettingsd-basic-configuration = ./basic-configuration.nix; }
|
Loading…
Reference in a new issue