From 6b4422c8cd54588464c84cc0aaaa17ac99e4be13 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Thu, 29 Aug 2024 20:07:28 +0800 Subject: [PATCH] wrapper-manager/dconf: add test and fix module More proof that I don't do testing in this project. :) --- modules/wrapper-manager/dconf.nix | 7 ++--- tests/modules/wrapper-manager/dconf/basic.nix | 26 +++++++++++++++++++ .../modules/wrapper-manager/dconf/default.nix | 3 +++ tests/modules/wrapper-manager/default.nix | 1 + 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 tests/modules/wrapper-manager/dconf/basic.nix create mode 100644 tests/modules/wrapper-manager/dconf/default.nix diff --git a/modules/wrapper-manager/dconf.nix b/modules/wrapper-manager/dconf.nix index b7179ff8..4755bfcd 100644 --- a/modules/wrapper-manager/dconf.nix +++ b/modules/wrapper-manager/dconf.nix @@ -39,14 +39,15 @@ in dconfProfileFile = pkgs.writeText "dconf-profile" - (lib.concatMapStrings (profile: "${profile}\n") submoduleCfg.profiles); + (lib.concatMapStrings (db: "${db}\n") submoduleCfg.profile); + dconfDirName = "wrapper-manager-dconf-${config.executableName}"; dconfSettings = - settingsFormat.generate "wrapper-manager-dconf-${config.executableName}" submoduleCfg.settings; + settingsFormat.generate dconfDirName submoduleCfg.settings; dconfSettingsDatabase = pkgs.runCommand "wrapper-manager-dconf-${config.executableName}-database" { nativeBuildInputs = [ submoduleCfg.package ]; } '' - dconf compile ${builtins.placeholder "out"} ${dconfSettings} + dconf compile ${builtins.placeholder "out"} "${dconfSettings}/dconf" ''; in { options.dconf = { diff --git a/tests/modules/wrapper-manager/dconf/basic.nix b/tests/modules/wrapper-manager/dconf/basic.nix new file mode 100644 index 00000000..bd32dff3 --- /dev/null +++ b/tests/modules/wrapper-manager/dconf/basic.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, ... }: + +let + section = "one/foodogsquared/SomeMadeUpCrap"; + key = "somemadeupkey"; + value = true; +in +{ + wrappers.dconf-test = { + arg0 = lib.getExe' pkgs.dconf "dconf"; + dconf = { + enable = true; + settings.${section}.${key} = value; + }; + }; + + build.extraPassthru.tests = { + dconfCheck = pkgs.runCommand "dconf-wrapped-test" { } '' + export HOME=$TMPDIR + + # We've hardcoded the value for now since Nix toString function makes the + # boolean either "1" or an empty string. + [ "$(${lib.getExe' config.build.toplevel "dconf-test"} read '/${section}/${key}')" = 'true' ] && touch $out + ''; + }; +} diff --git a/tests/modules/wrapper-manager/dconf/default.nix b/tests/modules/wrapper-manager/dconf/default.nix new file mode 100644 index 00000000..7fff7787 --- /dev/null +++ b/tests/modules/wrapper-manager/dconf/default.nix @@ -0,0 +1,3 @@ +{ + basic = ./basic.nix; +} diff --git a/tests/modules/wrapper-manager/default.nix b/tests/modules/wrapper-manager/default.nix index 5420ac90..fe29b381 100644 --- a/tests/modules/wrapper-manager/default.nix +++ b/tests/modules/wrapper-manager/default.nix @@ -21,4 +21,5 @@ in boxxy = runTests ./sandboxing/boxxy { }; zellij = runTests ./programs/zellij { }; jujutsu = runTests ./programs/jujutsu { }; + dconf = runTests ./dconf { }; }