Find the host's GL driver when the store's is not the system's
Off NixOS the driver the loader needs belongs to the host, not the store, so vidya never got a config and the window never opened. The launcher now hands itself to nixGL unless /run/current-system says it is on NixOS, which covers a distrobox Arch the same as a bare one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
633faad parent: ca3afbe modified
flake.lock +55 -0 | @@ -1,5 +1,23 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "nodes": { |
| 3 | + "flake-utils": { | |
| 4 | + "inputs": { | |
| 5 | + "systems": "systems" | |
| 6 | + }, | |
| 7 | + "locked": { | |
| 8 | + "lastModified": 1731533236, | |
| 9 | + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", | |
| 10 | + "owner": "numtide", | |
| 11 | + "repo": "flake-utils", | |
| 12 | + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", | |
| 13 | + "type": "github" | |
| 14 | + }, | |
| 15 | + "original": { | |
| 16 | + "owner": "numtide", | |
| 17 | + "repo": "flake-utils", | |
| 18 | + "type": "github" | |
| 19 | + } | |
| 20 | + }, | |
| 3 | 21 | "glimmer": { |
| 4 | 22 | "flake": false, |
| 5 | 23 | "locked": { |
| @@ -51,6 +69,27 @@ | ||
| 51 | 69 | "url": "https://github.com/jolt-lang/jolt" |
| 52 | 70 | } |
| 53 | 71 | }, |
| 72 | + "nixgl": { | |
| 73 | + "inputs": { | |
| 74 | + "flake-utils": "flake-utils", | |
| 75 | + "nixpkgs": [ | |
| 76 | + "nixpkgs" | |
| 77 | + ] | |
| 78 | + }, | |
| 79 | + "locked": { | |
| 80 | + "lastModified": 1762090880, | |
| 81 | + "narHash": "sha256-fbRQzIGPkjZa83MowjbD2ALaJf9y6KMDdJBQMKFeY/8=", | |
| 82 | + "owner": "nix-community", | |
| 83 | + "repo": "nixGL", | |
| 84 | + "rev": "b6105297e6f0cd041670c3e8628394d4ee247ed5", | |
| 85 | + "type": "github" | |
| 86 | + }, | |
| 87 | + "original": { | |
| 88 | + "owner": "nix-community", | |
| 89 | + "repo": "nixGL", | |
| 90 | + "type": "github" | |
| 91 | + } | |
| 92 | + }, | |
| 54 | 93 | "nixpkgs": { |
| 55 | 94 | "locked": { |
| 56 | 95 | "lastModified": 1788039129, |
| @@ -72,8 +111,24 @@ | ||
| 72 | 111 | "glimmer": "glimmer", |
| 73 | 112 | "jolt-native": "jolt-native", |
| 74 | 113 | "jolt-src": "jolt-src", |
| 114 | + "nixgl": "nixgl", | |
| 75 | 115 | "nixpkgs": "nixpkgs" |
| 76 | 116 | } |
| 117 | + }, | |
| 118 | + "systems": { | |
| 119 | + "locked": { | |
| 120 | + "lastModified": 1681028828, | |
| 121 | + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", | |
| 122 | + "owner": "nix-systems", | |
| 123 | + "repo": "default", | |
| 124 | + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", | |
| 125 | + "type": "github" | |
| 126 | + }, | |
| 127 | + "original": { | |
| 128 | + "owner": "nix-systems", | |
| 129 | + "repo": "default", | |
| 130 | + "type": "github" | |
| 131 | + } | |
| 77 | 132 | } |
| 78 | 133 | }, |
| 79 | 134 | "root": "root", |
| @@ -1,5 +1,23 @@ | |||
| 1 | { | 1 | { |
| 2 | "nodes": { | 2 | "nodes": { |
| 3 | + "flake-utils": { | ||
| 4 | + "inputs": { | ||
| 5 | + "systems": "systems" | ||
| 6 | + }, | ||
| 7 | + "locked": { | ||
| 8 | + "lastModified": 1731533236, | ||
| 9 | + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", | ||
| 10 | + "owner": "numtide", | ||
| 11 | + "repo": "flake-utils", | ||
| 12 | + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", | ||
| 13 | + "type": "github" | ||
| 14 | + }, | ||
| 15 | + "original": { | ||
| 16 | + "owner": "numtide", | ||
| 17 | + "repo": "flake-utils", | ||
| 18 | + "type": "github" | ||
| 19 | + } | ||
| 20 | + }, | ||
| 3 | "glimmer": { | 21 | "glimmer": { |
| 4 | "flake": false, | 22 | "flake": false, |
| 5 | "locked": { | 23 | "locked": { |
| @@ -51,6 +69,27 @@ | |||
| 51 | "url": "https://github.com/jolt-lang/jolt" | 69 | "url": "https://github.com/jolt-lang/jolt" |
| 52 | } | 70 | } |
| 53 | }, | 71 | }, |
| 72 | + "nixgl": { | ||
| 73 | + "inputs": { | ||
| 74 | + "flake-utils": "flake-utils", | ||
| 75 | + "nixpkgs": [ | ||
| 76 | + "nixpkgs" | ||
| 77 | + ] | ||
| 78 | + }, | ||
| 79 | + "locked": { | ||
| 80 | + "lastModified": 1762090880, | ||
| 81 | + "narHash": "sha256-fbRQzIGPkjZa83MowjbD2ALaJf9y6KMDdJBQMKFeY/8=", | ||
| 82 | + "owner": "nix-community", | ||
| 83 | + "repo": "nixGL", | ||
| 84 | + "rev": "b6105297e6f0cd041670c3e8628394d4ee247ed5", | ||
| 85 | + "type": "github" | ||
| 86 | + }, | ||
| 87 | + "original": { | ||
| 88 | + "owner": "nix-community", | ||
| 89 | + "repo": "nixGL", | ||
| 90 | + "type": "github" | ||
| 91 | + } | ||
| 92 | + }, | ||
| 54 | "nixpkgs": { | 93 | "nixpkgs": { |
| 55 | "locked": { | 94 | "locked": { |
| 56 | "lastModified": 1788039129, | 95 | "lastModified": 1788039129, |
| @@ -72,8 +111,24 @@ | |||
| 72 | "glimmer": "glimmer", | 111 | "glimmer": "glimmer", |
| 73 | "jolt-native": "jolt-native", | 112 | "jolt-native": "jolt-native", |
| 74 | "jolt-src": "jolt-src", | 113 | "jolt-src": "jolt-src", |
| 114 | + "nixgl": "nixgl", | ||
| 75 | "nixpkgs": "nixpkgs" | 115 | "nixpkgs": "nixpkgs" |
| 76 | } | 116 | } |
| 117 | + }, | ||
| 118 | + "systems": { | ||
| 119 | + "locked": { | ||
| 120 | + "lastModified": 1681028828, | ||
| 121 | + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", | ||
| 122 | + "owner": "nix-systems", | ||
| 123 | + "repo": "default", | ||
| 124 | + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", | ||
| 125 | + "type": "github" | ||
| 126 | + }, | ||
| 127 | + "original": { | ||
| 128 | + "owner": "nix-systems", | ||
| 129 | + "repo": "default", | ||
| 130 | + "type": "github" | ||
| 131 | + } | ||
| 77 | } | 132 | } |
| 78 | }, | 133 | }, |
| 79 | "root": "root", | 134 | "root": "root", |
modified
flake.nix +24 -5 | @@ -13,9 +13,10 @@ | ||
| 13 | 13 | # |
| 14 | 14 | # On a machine that is not NixOS the GL driver is the host's and the loader |
| 15 | 15 | # will not find it, so the window never opens ("GL display: argument does not |
| 16 | - # name a valid config"). Launch through nixGL there: | |
| 17 | - # | |
| 18 | - # nix run --impure "git+https://github.com/nix-community/nixGL#nixGLIntel" -- ./result/bin/frq | |
| 16 | + # name a valid config"). The launcher handles that itself: off NixOS it hands | |
| 17 | + # the process to nixGL, which puts the host's driver ahead of the store's. | |
| 18 | + # Nothing extra to type, and a distrobox/container Arch is the same case as | |
| 19 | + # a bare one. | |
| 19 | 20 | description = "frq — a freeq client in jolt"; |
| 20 | 21 | |
| 21 | 22 | inputs = { |
| @@ -38,9 +39,15 @@ | ||
| 38 | 39 | url = "git+https://gitlab.com/nandithebull/glimmer?rev=399df371c790d690fb6e4560c3d4d7f838502857"; |
| 39 | 40 | flake = false; |
| 40 | 41 | }; |
| 42 | + | |
| 43 | + # Only ever used off NixOS, to put the host GL driver on the loader path. | |
| 44 | + nixgl = { | |
| 45 | + url = "github:nix-community/nixGL"; | |
| 46 | + inputs.nixpkgs.follows = "nixpkgs"; | |
| 47 | + }; | |
| 41 | 48 | }; |
| 42 | 49 | |
| 43 | - outputs = { self, nixpkgs, jolt-src, jolt-native, glimmer }: | |
| 50 | + outputs = { self, nixpkgs, jolt-src, jolt-native, glimmer, nixgl }: | |
| 44 | 51 | let |
| 45 | 52 | systems = [ "x86_64-linux" "aarch64-linux" ]; |
| 46 | 53 | forEachSystem = f: |
| @@ -51,6 +58,11 @@ | ||
| 51 | 58 | let |
| 52 | 59 | inherit (pkgs) lib; |
| 53 | 60 | |
| 61 | + # Mesa, despite the name: it covers Intel and AMD alike. The NVIDIA | |
| 62 | + # wrappers are the ones that need --impure (they read the host kernel | |
| 63 | + # module's version), which is why this only ever reaches for Intel. | |
| 64 | + nixGL = nixgl.packages.${pkgs.stdenv.hostPlatform.system}.nixGLIntel; | |
| 65 | + | |
| 54 | 66 | # libvidya (the retained-tree ABI glimmer-vidya binds, on egui) and |
| 55 | 67 | # libjoltmoq (the AV media plane). One workspace, two cdylibs. |
| 56 | 68 | native = pkgs.rustPlatform.buildRustPackage { |
| @@ -172,7 +184,14 @@ | ||
| 172 | 184 | frqScript = pkgs.writeShellScript "frq" '' |
| 173 | 185 | export LD_LIBRARY_PATH="${native}/lib:${lib.makeLibraryPath runtimeLibs}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" |
| 174 | 186 | cd ${frqSource} |
| 175 | - exec ${joltRuntime}/bin/jolt \ | |
| 187 | + | |
| 188 | + # On NixOS the store's Mesa is the system's and the window opens. | |
| 189 | + # Anywhere else the real driver is the host's, so defer to nixGL — | |
| 190 | + # it prepends the host driver, which has to win over ours. | |
| 191 | + runner="" | |
| 192 | + [ -e /run/current-system ] || runner="${nixGL}/bin/nixGLIntel" | |
| 193 | + | |
| 194 | + exec ''${runner} ${joltRuntime}/bin/jolt \ | |
| 176 | 195 | -Sdeps '{:deps {jolt-lang/glimmer {:local/root "${glimmer}"} nandi/glimmer-vidya {:local/root "${glimmerVidya}"}}}' \ |
| 177 | 196 | -M:frq "$@" |
| 178 | 197 | ''; |
| @@ -13,9 +13,10 @@ | |||
| 13 | # | 13 | # |
| 14 | # On a machine that is not NixOS the GL driver is the host's and the loader | 14 | # On a machine that is not NixOS the GL driver is the host's and the loader |
| 15 | # will not find it, so the window never opens ("GL display: argument does not | 15 | # will not find it, so the window never opens ("GL display: argument does not |
| 16 | - # name a valid config"). Launch through nixGL there: | 16 | + # name a valid config"). The launcher handles that itself: off NixOS it hands |
| 17 | - # | 17 | + # the process to nixGL, which puts the host's driver ahead of the store's. |
| 18 | - # nix run --impure "git+https://github.com/nix-community/nixGL#nixGLIntel" -- ./result/bin/frq | 18 | + # Nothing extra to type, and a distrobox/container Arch is the same case as |
| 19 | + # a bare one. | ||
| 19 | description = "frq — a freeq client in jolt"; | 20 | description = "frq — a freeq client in jolt"; |
| 20 | 21 | ||
| 21 | inputs = { | 22 | inputs = { |
| @@ -38,9 +39,15 @@ | |||
| 38 | url = "git+https://gitlab.com/nandithebull/glimmer?rev=399df371c790d690fb6e4560c3d4d7f838502857"; | 39 | url = "git+https://gitlab.com/nandithebull/glimmer?rev=399df371c790d690fb6e4560c3d4d7f838502857"; |
| 39 | flake = false; | 40 | flake = false; |
| 40 | }; | 41 | }; |
| 42 | + | ||
| 43 | + # Only ever used off NixOS, to put the host GL driver on the loader path. | ||
| 44 | + nixgl = { | ||
| 45 | + url = "github:nix-community/nixGL"; | ||
| 46 | + inputs.nixpkgs.follows = "nixpkgs"; | ||
| 47 | + }; | ||
| 41 | }; | 48 | }; |
| 42 | 49 | ||
| 43 | - outputs = { self, nixpkgs, jolt-src, jolt-native, glimmer }: | 50 | + outputs = { self, nixpkgs, jolt-src, jolt-native, glimmer, nixgl }: |
| 44 | let | 51 | let |
| 45 | systems = [ "x86_64-linux" "aarch64-linux" ]; | 52 | systems = [ "x86_64-linux" "aarch64-linux" ]; |
| 46 | forEachSystem = f: | 53 | forEachSystem = f: |
| @@ -51,6 +58,11 @@ | |||
| 51 | let | 58 | let |
| 52 | inherit (pkgs) lib; | 59 | inherit (pkgs) lib; |
| 53 | 60 | ||
| 61 | + # Mesa, despite the name: it covers Intel and AMD alike. The NVIDIA | ||
| 62 | + # wrappers are the ones that need --impure (they read the host kernel | ||
| 63 | + # module's version), which is why this only ever reaches for Intel. | ||
| 64 | + nixGL = nixgl.packages.${pkgs.stdenv.hostPlatform.system}.nixGLIntel; | ||
| 65 | + | ||
| 54 | # libvidya (the retained-tree ABI glimmer-vidya binds, on egui) and | 66 | # libvidya (the retained-tree ABI glimmer-vidya binds, on egui) and |
| 55 | # libjoltmoq (the AV media plane). One workspace, two cdylibs. | 67 | # libjoltmoq (the AV media plane). One workspace, two cdylibs. |
| 56 | native = pkgs.rustPlatform.buildRustPackage { | 68 | native = pkgs.rustPlatform.buildRustPackage { |
| @@ -172,7 +184,14 @@ | |||
| 172 | frqScript = pkgs.writeShellScript "frq" '' | 184 | frqScript = pkgs.writeShellScript "frq" '' |
| 173 | export LD_LIBRARY_PATH="${native}/lib:${lib.makeLibraryPath runtimeLibs}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" | 185 | export LD_LIBRARY_PATH="${native}/lib:${lib.makeLibraryPath runtimeLibs}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" |
| 174 | cd ${frqSource} | 186 | cd ${frqSource} |
| 175 | - exec ${joltRuntime}/bin/jolt \ | 187 | + |
| 188 | + # On NixOS the store's Mesa is the system's and the window opens. | ||
| 189 | + # Anywhere else the real driver is the host's, so defer to nixGL — | ||
| 190 | + # it prepends the host driver, which has to win over ours. | ||
| 191 | + runner="" | ||
| 192 | + [ -e /run/current-system ] || runner="${nixGL}/bin/nixGLIntel" | ||
| 193 | + | ||
| 194 | + exec ''${runner} ${joltRuntime}/bin/jolt \ | ||
| 176 | -Sdeps '{:deps {jolt-lang/glimmer {:local/root "${glimmer}"} nandi/glimmer-vidya {:local/root "${glimmerVidya}"}}}' \ | 195 | -Sdeps '{:deps {jolt-lang/glimmer {:local/root "${glimmer}"} nandi/glimmer-vidya {:local/root "${glimmerVidya}"}}}' \ |
| 177 | -M:frq "$@" | 196 | -M:frq "$@" |
| 178 | ''; | 197 | ''; |