xsettingsd: make configurable through module

main
Gabriel Fontes 3 years ago committed by Robert Helgesson
parent 959217e51d
commit 52e84a040e
No known key found for this signature in database
GPG Key ID: 36BDAA14C2797E89
  1. 46
      modules/services/xsettingsd.nix
  2. 1
      tests/default.nix
  3. 4
      tests/modules/services/xsettingsd/basic-configuration.conf
  4. 26
      tests/modules/services/xsettingsd/basic-configuration.nix
  5. 1
      tests/modules/services/xsettingsd/default.nix

@ -6,6 +6,20 @@ let
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 {
meta.maintainers = [ maintainers.imalison ];
@ -21,6 +35,34 @@ in {
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 = {
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";
};
};

@ -139,6 +139,7 @@ import nmt {
./modules/services/window-managers/i3
./modules/services/window-managers/sway
./modules/services/wlsunset
./modules/services/xsettingsd
./modules/systemd
./modules/targets-linux
] ++ lib.optionals enableBig [

@ -0,0 +1,4 @@
Net/ThemeName "Numix"
Xft/Antialias 1
Xft/Hinting 1
Xft/RGBA "rgb"

@ -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}
'';
};
}

@ -0,0 +1 @@
{ xsettingsd-basic-configuration = ./basic-configuration.nix; }
Loading…
Cancel
Save