@@ -32,44 +32,49 @@ my $ctx = test_context(
3232# locally. For completeness, we also verify that we can substitute
3333# the build locally.
3434
35+ # Use the builder store (physical = logical) for direct nix-* calls,
36+ # because the central store has physical != logical which breaks nix-build
37+ # when the derivation references paths outside the logical store dir.
38+ my $store_uri = $ctx -> {builder }{nix_store_uri };
39+
3540subtest " Pre-build the job, upload to the cache, and then delete locally" => sub {
3641 my $outlink = $ctx -> tmpdir . " /basic-canbesubstituted" ;
3742 my ($res , $stdout , $stderr );
38- ($res ) = $ctx -> capture_cmd(60, ' nix-build' , $ctx -> jobsdir . ' /notifications.nix' , ' -A' , ' canbesubstituted' , ' --out-link' , $outlink );
43+ ($res ) = $ctx -> capture_cmd(60, ' nix-build' , ' --store ' , $store_uri , $ctx -> jobsdir . ' /notifications.nix' , ' -A' , ' canbesubstituted' , ' --out-link' , $outlink );
3944 is($res , 0, " Building notifications.nix succeeded" );
40- ($res ) = $ctx -> capture_cmd(60, ' nix' , ' copy' , ' --to' , " file://${binarycachedir} " , $outlink );
45+ ($res ) = $ctx -> capture_cmd(60, ' nix' , ' --store ' , $store_uri , ' copy' , ' --to' , " file://${binarycachedir} " , $outlink );
4146 is($res , 0, " Copying the closure to the binary cache succeeded" );
4247 my $outpath = readlink ($outlink );
4348
4449 # Delete the store path and all of the system's garbage
4550 is(unlink ($outlink ), 1, " Deleting the GC root succeeds" );
46- ($res ) = $ctx -> capture_cmd(60, ' nix' , ' log' , $outpath );
51+ ($res ) = $ctx -> capture_cmd(60, ' nix' , ' --store ' , $store_uri , ' log' , $outpath );
4752 is($res , 0, " Reading the output's log succeeds" );
48- ($res ) = $ctx -> capture_cmd(15, ' nix-store' , ' --delete' , $outpath );
53+ ($res ) = $ctx -> capture_cmd(15, ' nix-store' , ' --store ' , $store_uri , ' -- delete' , $outpath );
4954 is($res , 0, " Deleting the notifications.nix output succeeded" );
50- ($res ) = $ctx -> capture_cmd(60, ' nix-collect-garbage' );
55+ ($res ) = $ctx -> capture_cmd(60, ' nix-collect-garbage' , ' --store ' , $store_uri );
5156 is($res , 0, " Delete all the system's garbage" );
52- File::Path::rmtree($ctx -> {central }{nix_log_dir });
57+ File::Path::rmtree($ctx -> {builder }{nix_log_dir });
5358};
5459
5560subtest " Ensure substituting the job works, but reading the log fails" => sub {
5661 # Build the store path, with --max-jobs 0 to prevent builds
5762 my $outlink = $ctx -> tmpdir . " /basic-canbesubstituted" ;
5863 my ($res );
59- ($res ) = $ctx -> capture_cmd(60, ' nix-build' , $ctx -> jobsdir . ' /notifications.nix' , ' -A' , ' canbesubstituted' , ' --max-jobs' , ' 0' , ' --out-link' , $outlink );
64+ ($res ) = $ctx -> capture_cmd(60, ' nix-build' , ' --store ' , $store_uri , $ctx -> jobsdir . ' /notifications.nix' , ' -A' , ' canbesubstituted' , ' --max-jobs' , ' 0' , ' --out-link' , $outlink );
6065 is($res , 0, " Building notifications.nix succeeded" );
6166 my $outpath = readlink ($outlink );
6267
6368 # Verify trying to read this path's log fails, since we substituted it
64- ($res ) = $ctx -> capture_cmd(60, ' nix' , ' log' , $outpath );
69+ ($res ) = $ctx -> capture_cmd(60, ' nix' , ' --store ' , $store_uri , ' log' , $outpath );
6570 isnt($res , 0, " Reading the deleted output's log fails" );
6671
6772 # Delete the store path again and all of the store's garbage, ensuring
6873 # Hydra will try to build it.
6974 is(unlink ($outlink ), 1, " Deleting the GC root succeeds" );
70- ($res ) = $ctx -> capture_cmd(15, ' nix-store' , ' --delete' , $outpath );
75+ ($res ) = $ctx -> capture_cmd(15, ' nix-store' , ' --store ' , $store_uri , ' -- delete' , $outpath );
7176 is($res , 0, " Deleting the notifications.nix output succeeded" );
72- ($res ) = $ctx -> capture_cmd(60, ' nix-collect-garbage' );
77+ ($res ) = $ctx -> capture_cmd(60, ' nix-collect-garbage' , ' --store ' , $store_uri );
7378 is($res , 0, " Delete all the system's garbage" );
7479};
7580
0 commit comments