|
140 | 140 | mkdir -p "$out" |
141 | 141 | ''; |
142 | 142 | customConfig = combinedConfig // { package = customPackage; }; |
| 143 | + remoteControlConfig = { |
| 144 | + enable = true; |
| 145 | + package = customPackage; |
| 146 | + remoteControl = { |
| 147 | + enable = true; |
| 148 | + package = pkgs.writeShellScriptBin "codex" "exit 0"; |
| 149 | + environmentFile = "/run/secrets/codex-remote-control.env"; |
| 150 | + }; |
| 151 | + }; |
| 152 | + remoteControlConfigWithEnvironmentFile = environmentFile: |
| 153 | + remoteControlConfig |
| 154 | + // { |
| 155 | + remoteControl = remoteControlConfig.remoteControl // { inherit environmentFile; }; |
| 156 | + }; |
| 157 | + homeRemoteService = |
| 158 | + (evalHomeManager remoteControlConfig).config.systemd.user.services.codex-remote-control; |
| 159 | + nixosRemoteService = |
| 160 | + (evalNixOS remoteControlConfig).config.systemd.user.services.codex-remote-control; |
| 161 | + optionalHomeRemoteService = |
| 162 | + (evalHomeManager ( |
| 163 | + remoteControlConfigWithEnvironmentFile "-/run/secrets/codex-remote-control.env" |
| 164 | + )).config.systemd.user.services.codex-remote-control; |
| 165 | + optionalNixOSRemoteService = |
| 166 | + (evalNixOS ( |
| 167 | + remoteControlConfigWithEnvironmentFile "-/run/secrets/codex-remote-control.env" |
| 168 | + )).config.systemd.user.services.codex-remote-control; |
143 | 169 |
|
144 | 170 | invalidBuilder = builtins.tryEval ( |
145 | 171 | (packages.codex-desktop.override { |
|
162 | 188 | }).config.environment.systemPackages |
163 | 189 | true |
164 | 190 | ); |
| 191 | + invalidHomeManagerEnvironmentFile = builtins.tryEval ( |
| 192 | + builtins.deepSeq |
| 193 | + (evalHomeManager ( |
| 194 | + remoteControlConfigWithEnvironmentFile ./linux-features-test.nix |
| 195 | + )).config.systemd.user.services.codex-remote-control |
| 196 | + true |
| 197 | + ); |
| 198 | + invalidNixOSEnvironmentFile = builtins.tryEval ( |
| 199 | + builtins.deepSeq |
| 200 | + (evalNixOS ( |
| 201 | + remoteControlConfigWithEnvironmentFile ./linux-features-test.nix |
| 202 | + )).config.systemd.user.services.codex-remote-control |
| 203 | + true |
| 204 | + ); |
| 205 | + storeEnvironmentFiles = [ |
| 206 | + "${./linux-features-test.nix}" |
| 207 | + "-${./linux-features-test.nix}" |
| 208 | + ]; |
| 209 | + invalidRuntimeEnvironmentFiles = [ |
| 210 | + "" |
| 211 | + "secrets.env" |
| 212 | + "-secrets.env" |
| 213 | + "//nix/store/example-secret" |
| 214 | + "/run/../nix/store/example-secret" |
| 215 | + "/nix//store/example-secret" |
| 216 | + "/run/secrets/./codex-remote-control.env" |
| 217 | + "/run/secrets/" |
| 218 | + ]; |
| 219 | + contextEnvironmentFiles = [ |
| 220 | + "/run/secrets/${./linux-features-test.nix}" |
| 221 | + "-/run/secrets/${./linux-features-test.nix}" |
| 222 | + ]; |
| 223 | + homeManagerStoreEnvironmentFileAssertions = map ( |
| 224 | + environmentFile: |
| 225 | + (evalHomeManager ( |
| 226 | + remoteControlConfigWithEnvironmentFile environmentFile |
| 227 | + )).config.assertions |
| 228 | + ) storeEnvironmentFiles; |
| 229 | + nixosStoreEnvironmentFileAssertions = map ( |
| 230 | + environmentFile: |
| 231 | + (evalNixOS ( |
| 232 | + remoteControlConfigWithEnvironmentFile environmentFile |
| 233 | + )).config.assertions |
| 234 | + ) storeEnvironmentFiles; |
| 235 | + homeManagerRuntimeEnvironmentFileAssertions = map ( |
| 236 | + environmentFile: |
| 237 | + (evalHomeManager ( |
| 238 | + remoteControlConfigWithEnvironmentFile environmentFile |
| 239 | + )).config.assertions |
| 240 | + ) invalidRuntimeEnvironmentFiles; |
| 241 | + nixosRuntimeEnvironmentFileAssertions = map ( |
| 242 | + environmentFile: |
| 243 | + (evalNixOS ( |
| 244 | + remoteControlConfigWithEnvironmentFile environmentFile |
| 245 | + )).config.assertions |
| 246 | + ) invalidRuntimeEnvironmentFiles; |
| 247 | + homeManagerContextEnvironmentFileAssertions = map ( |
| 248 | + environmentFile: |
| 249 | + (evalHomeManager ( |
| 250 | + remoteControlConfigWithEnvironmentFile environmentFile |
| 251 | + )).config.assertions |
| 252 | + ) contextEnvironmentFiles; |
| 253 | + nixosContextEnvironmentFileAssertions = map ( |
| 254 | + environmentFile: |
| 255 | + (evalNixOS ( |
| 256 | + remoteControlConfigWithEnvironmentFile environmentFile |
| 257 | + )).config.assertions |
| 258 | + ) contextEnvironmentFiles; |
165 | 259 | in |
166 | 260 | assert lib.assertMsg |
167 | 261 | (linuxFeatures.normalize testFeatureIds == normalizedTestFeatureIds) |
@@ -196,6 +290,42 @@ assert lib.assertMsg |
196 | 290 | assert lib.assertMsg (!invalidBuilder.success) "the package builder accepted an unsupported feature"; |
197 | 291 | assert lib.assertMsg (!invalidHomeManager.success) "Home Manager accepted an unsupported feature"; |
198 | 292 | assert lib.assertMsg (!invalidNixOS.success) "NixOS accepted an unsupported feature"; |
| 293 | +assert lib.assertMsg |
| 294 | + (homeRemoteService.Service.EnvironmentFile == "/run/secrets/codex-remote-control.env") |
| 295 | + "Home Manager changed the runtime remote-control environment-file path"; |
| 296 | +assert lib.assertMsg |
| 297 | + (nixosRemoteService.serviceConfig.EnvironmentFile == "/run/secrets/codex-remote-control.env") |
| 298 | + "NixOS changed the runtime remote-control environment-file path"; |
| 299 | +assert lib.assertMsg |
| 300 | + (optionalHomeRemoteService.Service.EnvironmentFile == "-/run/secrets/codex-remote-control.env") |
| 301 | + "Home Manager rejected or changed an optional absolute environment-file path"; |
| 302 | +assert lib.assertMsg |
| 303 | + (optionalNixOSRemoteService.serviceConfig.EnvironmentFile == "-/run/secrets/codex-remote-control.env") |
| 304 | + "NixOS rejected or changed an optional absolute environment-file path"; |
| 305 | +assert lib.assertMsg |
| 306 | + (!invalidHomeManagerEnvironmentFile.success) |
| 307 | + "Home Manager accepted a Nix path that can copy remote-control secrets into the store"; |
| 308 | +assert lib.assertMsg |
| 309 | + (!invalidNixOSEnvironmentFile.success) |
| 310 | + "NixOS accepted a Nix path that can copy remote-control secrets into the store"; |
| 311 | +assert lib.assertMsg |
| 312 | + (lib.all (assertions: !lib.all (item: item.assertion) assertions) homeManagerStoreEnvironmentFileAssertions) |
| 313 | + "Home Manager accepted a store path for the remote-control environment file"; |
| 314 | +assert lib.assertMsg |
| 315 | + (lib.all (assertions: !lib.all (item: item.assertion) assertions) nixosStoreEnvironmentFileAssertions) |
| 316 | + "NixOS accepted a store path for the remote-control environment file"; |
| 317 | +assert lib.assertMsg |
| 318 | + (lib.all (assertions: !lib.all (item: item.assertion) assertions) homeManagerRuntimeEnvironmentFileAssertions) |
| 319 | + "Home Manager accepted an empty, relative, or non-canonical remote-control environment-file path"; |
| 320 | +assert lib.assertMsg |
| 321 | + (lib.all (assertions: !lib.all (item: item.assertion) assertions) nixosRuntimeEnvironmentFileAssertions) |
| 322 | + "NixOS accepted an empty, relative, or non-canonical remote-control environment-file path"; |
| 323 | +assert lib.assertMsg |
| 324 | + (lib.all (assertions: !lib.all (item: item.assertion) assertions) homeManagerContextEnvironmentFileAssertions) |
| 325 | + "Home Manager accepted a context-bearing remote-control environment-file path"; |
| 326 | +assert lib.assertMsg |
| 327 | + (lib.all (assertions: !lib.all (item: item.assertion) assertions) nixosContextEnvironmentFileAssertions) |
| 328 | + "NixOS accepted a context-bearing remote-control environment-file path"; |
199 | 329 | pkgs.runCommand "nix-linux-features-evaluation" { } '' |
200 | 330 | touch "$out" |
201 | 331 | '' |
0 commit comments