Monorepo for Tangled
0

Configure Feed

Select the types of activity you want to include in your feed.

nix/microvm: replicate how nix print-dev-env materializes the envs

Signed-off-by: dawn <dawn@tangled.org>

dawn (Jun 27, 2026, 2:21 PM +0300) b8a0864d cd3e67f0

+28 -9
+7 -5
nix/microvm/user-config.nix
··· 2 2 pkgs, 3 3 lib, 4 4 options, 5 + config, 5 6 ... 6 7 } @ args: let 7 8 configPath = /run/spindle/user-config/config.json; ··· 103 104 name = "spindle-deps"; 104 105 packages = map resolvePackage dependencies; 105 106 }; 107 + spindleDevEnv = spindleDevShell.overrideAttrs (_: { 108 + name = "spindle-deps-env"; 109 + # materialize the devshell like how nix print-dev-env does internally 110 + args = ["${config.nix.package.src}/src/nix/get-env.sh"]; 111 + }); 106 112 in { 107 113 nix.registry = builtins.mapAttrs (name: _: 108 114 lib.mkForce { ··· 112 118 }; 113 119 }) 114 120 registry; 115 - # put the devshell into the resulting image env. 116 - # we do this instead of using a `.nix` file because it lets us skip eval time. 117 121 environment.etc = lib.mkIf (dependencies != []) { 118 - # this is safe because we have the closure in the env also! 119 - "spindle/devshell-drv".text = builtins.unsafeDiscardStringContext spindleDevShell.drvPath; 120 - "spindle/devshell-closure".source = pkgs.closureInfo {rootPaths = [spindleDevShell];}; 122 + "spindle/devshell-drv".text = "${spindleDevEnv}"; 121 123 }; 122 124 services = builtins.mapAttrs (normalize (options.services or {})) (userConfig.services or {}); 123 125 virtualisation = builtins.mapAttrs (normalize (options.virtualisation or {})) (userConfig.virtualisation or {});
+21 -4
spindle/engines/microvm/test-spindle-microvm.sh
··· 632 632 # dependencies live in the activation devshell now, not systemPackages, so a 633 633 # step picks them up by sourcing the materialised env (this is what the 634 634 # engine's RunStep does automatically; the CLI runner does not, so we do it 635 - # here). 636 - local out 637 - out=$(run_vm --name "activation-dependencies" --timeout "600s" --activate "$config" -- /run/current-system/sw/bin/bash -l -c ' 635 + # here). this script is reused across the build and cache-hit runs below. 636 + local job=' 638 637 env_file=/run/spindle/devshell-env.sh 639 638 [ -f "$env_file" ] && echo "env_file=present" || echo "env_file=missing" 640 639 ··· 655 654 656 655 # flakeref + aliased deps 657 656 echo "hello=$(hello)" 658 - ') || return 1 657 + ' 658 + 659 + local db_path="$TEMP_DIR/activation-dependencies.db" 660 + 661 + # first run: build the config, materialise the devshell env profile, upload 662 + # its closure, and record both toplevel + env profile in the db. 663 + local out 664 + 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 659 665 660 666 check_needles "$out" \ 661 667 "env_file=present" "pkgconfig=[0-9]" "openssl_found=yes" \ 662 668 "openssl_version=[0-9]" "dev_headers=found" "hello=Hello, world!" || return 1 663 669 echo "success: bare (pkg-config + openssl, dev headers found via PKG_CONFIG_PATH), flakeref, and aliased deps all resolved" 670 + 671 + # second run: same config + db, no upload. the devshell .drv is absent (no 672 + # eval happens on a cache hit), so the env must be re-read from the cached 673 + # env profile. the deps must still resolve exactly as on the build run. 674 + 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 675 + 676 + check_needles "$out" \ 677 + "realizing cached NixOS config" \ 678 + "env_file=present" "pkgconfig=[0-9]" "openssl_found=yes" \ 679 + "openssl_version=[0-9]" "dev_headers=found" "hello=Hello, world!" || return 1 680 + echo "success: cache-hit run re-read the devshell env from the cached profile (no drv) and all deps resolved" 664 681 } 665 682 666 683 test_activation_registry_pin() {