flake: fix privateInputs loading in nix store contexts

When clan-core is fetched via fetchgit (e.g. in tests), the devFlake/private
directory exists but cannot be loaded as a flake. This causes errors when
building test machines.

Fix by:
1. Adding a .skip-private-inputs marker file in clan-core-for-checks to
   explicitly disable private inputs in test contexts
2. Checking for this marker file before attempting to load private inputs
3. Keeping the original tryEval approach as a fallback for compatibility

This ensures tests can run without errors while preserving the ability to
load private inputs in development environments.
This commit is contained in:
Jörg Thalheim
2025-07-29 14:58:29 +02:00
parent ae0ea37437
commit e99981cfaf
2 changed files with 12 additions and 2 deletions

View File

@@ -158,8 +158,11 @@ in
clan-core-for-checks = pkgs.runCommand "clan-core-for-checks" { } '' clan-core-for-checks = pkgs.runCommand "clan-core-for-checks" { } ''
cp -r ${pkgs.callPackage ./clan-core-for-checks.nix { }} $out cp -r ${pkgs.callPackage ./clan-core-for-checks.nix { }} $out
chmod +w $out/flake.lock chmod -R +w $out
cp ${../flake.lock} $out/flake.lock cp ${../flake.lock} $out/flake.lock
# Create marker file to disable private flake loading in tests
touch $out/.skip-private-inputs
''; '';
}; };
packages = lib.optionalAttrs (pkgs.stdenv.isLinux) { packages = lib.optionalAttrs (pkgs.stdenv.isLinux) {

View File

@@ -50,6 +50,7 @@
pathExists pathExists
; ;
# Load private flake inputs if available
loadDevFlake = loadDevFlake =
path: path:
let let
@@ -60,7 +61,13 @@
devFlake = builtins.tryEval (loadDevFlake ./devFlake/private); devFlake = builtins.tryEval (loadDevFlake ./devFlake/private);
privateInputs = if devFlake.success then devFlake.value.inputs else { }; privateInputs =
if pathExists ./.skip-private-inputs then
{ }
else if devFlake.success then
devFlake.value.inputs
else
{ };
in in
flake-parts.lib.mkFlake { inherit inputs; } ( flake-parts.lib.mkFlake { inherit inputs; } (
{ ... }: { ... }: