Skip to content

Commit d1d29e8

Browse files
nix: expose GSettings schemas to desktop launcher (#1009)
1 parent f303718 commit d1d29e8

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ jobs:
220220
.#codex-desktop-computer-use-ui
221221
.#codex-desktop-remote-mobile-control
222222
.#codex-desktop-computer-use-ui-remote-mobile-control
223+
.#checks.x86_64-linux.nix-gsettings-schema-wrapper
223224
.#checks.x86_64-linux.watchdog-linux-features
224225
)
225226
for output in "${outputs[@]}"; do

flake.nix

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,15 @@
345345
stdenv.cc.cc.lib
346346
zlib
347347
]);
348+
gsettingsSchemaPackages = with pkgs; [
349+
gsettings-desktop-schemas
350+
gtk3
351+
];
352+
gsettingsSchemaRoot = pkg:
353+
pkgs.lib.removeSuffix "/glib-2.0/schemas" (pkgs.glib.getSchemaPath pkg);
354+
gsettingsSchemaDataDirs =
355+
pkgs.lib.concatMapStringsSep ":" gsettingsSchemaRoot gsettingsSchemaPackages;
356+
xdgDefaultDataDirs = "/usr/local/share:/usr/share";
348357
launcherPath = pkgs.lib.makeBinPath (with pkgs; [
349358
bash
350359
coreutils
@@ -688,6 +697,8 @@ PY
688697
689698
makeWrapper "$out/opt/codex-desktop/start.sh" "$out/bin/codex-desktop" \
690699
--prefix PATH : "${payloadLauncherPath}" \
700+
--run 'export XDG_DATA_DIRS="''${XDG_DATA_DIRS:-${xdgDefaultDataDirs}}"' \
701+
--prefix XDG_DATA_DIRS : "${gsettingsSchemaDataDirs}" \
691702
--prefix PATH : "/run/current-system/sw/bin" \
692703
--prefix PATH : "/etc/profiles/per-user/$(whoami)/bin"
693704
@@ -787,6 +798,43 @@ PY
787798
grep -F 'CODEX_NOTIFICATION_ACTIONS_SOURCE=' ${installer}/bin/codex-desktop-installer >/dev/null
788799
touch "$out"
789800
'';
801+
nix-gsettings-schema-wrapper = pkgs.runCommand "codex-desktop-nix-gsettings-schema-wrapper-check" { } ''
802+
schema_data_dirs=${pkgs.lib.escapeShellArg gsettingsSchemaDataDirs}
803+
default_data_dirs=${pkgs.lib.escapeShellArg xdgDefaultDataDirs}
804+
explicit_data_dirs=/custom/share:/other/share
805+
806+
run_wrapper() {
807+
case "$1" in
808+
unset) unset XDG_DATA_DIRS ;;
809+
empty) export XDG_DATA_DIRS= ;;
810+
populated) export XDG_DATA_DIRS="$explicit_data_dirs" ;;
811+
*) echo "unknown test case: $1" >&2; return 1 ;;
812+
esac
813+
814+
exec() {
815+
printf '%s\n' "$XDG_DATA_DIRS"
816+
}
817+
818+
source ${codexDesktop}/bin/codex-desktop
819+
}
820+
821+
assert_data_dirs() {
822+
test_case="$1"
823+
expected="$2"
824+
actual="$(run_wrapper "$test_case")"
825+
if [ "$actual" != "$expected" ]; then
826+
printf '%s: expected <%s>, got <%s>\n' \
827+
"$test_case" "$expected" "$actual" >&2
828+
return 1
829+
fi
830+
}
831+
832+
expected_defaults="$schema_data_dirs:$default_data_dirs"
833+
assert_data_dirs unset "$expected_defaults"
834+
assert_data_dirs empty "$expected_defaults"
835+
assert_data_dirs populated "$schema_data_dirs:$explicit_data_dirs"
836+
touch "$out"
837+
'';
790838
nix-linux-features-evaluation = import ./nix/linux-features-test.nix {
791839
inherit pkgs self system;
792840
};

0 commit comments

Comments
 (0)