···22 pkgs,
33 lib,
44 options,
55+ config,
56 ...
67} @ args: let
78 configPath = /run/spindle/user-config/config.json;
···103104 name = "spindle-deps";
104105 packages = map resolvePackage dependencies;
105106 };
107107+ spindleDevEnv = spindleDevShell.overrideAttrs (_: {
108108+ name = "spindle-deps-env";
109109+ # materialize the devshell like how nix print-dev-env does internally
110110+ args = ["${config.nix.package.src}/src/nix/get-env.sh"];
111111+ });
106112in {
107113 nix.registry = builtins.mapAttrs (name: _:
108114 lib.mkForce {
···112118 };
113119 })
114120 registry;
115115- # put the devshell into the resulting image env.
116116- # we do this instead of using a `.nix` file because it lets us skip eval time.
117121 environment.etc = lib.mkIf (dependencies != []) {
118118- # this is safe because we have the closure in the env also!
119119- "spindle/devshell-drv".text = builtins.unsafeDiscardStringContext spindleDevShell.drvPath;
120120- "spindle/devshell-closure".source = pkgs.closureInfo {rootPaths = [spindleDevShell];};
122122+ "spindle/devshell-drv".text = "${spindleDevEnv}";
121123 };
122124 services = builtins.mapAttrs (normalize (options.services or {})) (userConfig.services or {});
123125 virtualisation = builtins.mapAttrs (normalize (options.virtualisation or {})) (userConfig.virtualisation or {});
+21-4
spindle/engines/microvm/test-spindle-microvm.sh
···632632 # dependencies live in the activation devshell now, not systemPackages, so a
633633 # step picks them up by sourcing the materialised env (this is what the
634634 # engine's RunStep does automatically; the CLI runner does not, so we do it
635635- # here).
636636- local out
637637- out=$(run_vm --name "activation-dependencies" --timeout "600s" --activate "$config" -- /run/current-system/sw/bin/bash -l -c '
635635+ # here). this script is reused across the build and cache-hit runs below.
636636+ local job='
638637env_file=/run/spindle/devshell-env.sh
639638[ -f "$env_file" ] && echo "env_file=present" || echo "env_file=missing"
640639···655654656655# flakeref + aliased deps
657656echo "hello=$(hello)"
658658-') || return 1
657657+'
658658+659659+ local db_path="$TEMP_DIR/activation-dependencies.db"
660660+661661+ # first run: build the config, materialise the devshell env profile, upload
662662+ # its closure, and record both toplevel + env profile in the db.
663663+ local out
664664+ out=$(run_vm --name "activation-dependencies" --timeout "600s" --activate "$config" --db "$db_path" --upload -- /run/current-system/sw/bin/bash -l -c "$job") || return 1
659665660666 check_needles "$out" \
661667 "env_file=present" "pkgconfig=[0-9]" "openssl_found=yes" \
662668 "openssl_version=[0-9]" "dev_headers=found" "hello=Hello, world!" || return 1
663669 echo "success: bare (pkg-config + openssl, dev headers found via PKG_CONFIG_PATH), flakeref, and aliased deps all resolved"
670670+671671+ # second run: same config + db, no upload. the devshell .drv is absent (no
672672+ # eval happens on a cache hit), so the env must be re-read from the cached
673673+ # env profile. the deps must still resolve exactly as on the build run.
674674+ out=$(run_vm --name "activation-dependencies-cached" --timeout "300s" --activate "$config" --db "$db_path" -- /run/current-system/sw/bin/bash -l -c "$job") || return 1
675675+676676+ check_needles "$out" \
677677+ "realizing cached NixOS config" \
678678+ "env_file=present" "pkgconfig=[0-9]" "openssl_found=yes" \
679679+ "openssl_version=[0-9]" "dev_headers=found" "hello=Hello, world!" || return 1
680680+ echo "success: cache-hit run re-read the devshell env from the cached profile (no drv) and all deps resolved"
664681}
665682666683test_activation_registry_pin() {