@@ -61,14 +61,14 @@ class DerivationBuilderImpl : public DerivationBuilder, public DerivationBuilder
61
61
{
62
62
protected:
63
63
64
- Store & store;
64
+ LocalStore & store;
65
65
66
66
std::unique_ptr<DerivationBuilderCallbacks> miscMethods;
67
67
68
68
public:
69
69
70
70
DerivationBuilderImpl (
71
- Store & store, std::unique_ptr<DerivationBuilderCallbacks> miscMethods, DerivationBuilderParams params)
71
+ LocalStore & store, std::unique_ptr<DerivationBuilderCallbacks> miscMethods, DerivationBuilderParams params)
72
72
: DerivationBuilderParams{std::move (params)}
73
73
, store{store}
74
74
, miscMethods{std::move (miscMethods)}
@@ -424,13 +424,6 @@ void handleDiffHook(
424
424
425
425
const Path DerivationBuilderImpl::homeDir = " /homeless-shelter" ;
426
426
427
- static LocalStore & getLocalStore (Store & store)
428
- {
429
- auto p = dynamic_cast <LocalStore *>(&store);
430
- assert (p);
431
- return *p;
432
- }
433
-
434
427
void DerivationBuilderImpl::killSandbox (bool getStats)
435
428
{
436
429
if (buildUser) {
@@ -631,10 +624,9 @@ bool DerivationBuilderImpl::decideWhetherDiskFull()
631
624
so, we don't mark this build as a permanent failure. */
632
625
#if HAVE_STATVFS
633
626
{
634
- auto & localStore = getLocalStore (store);
635
627
uint64_t required = 8ULL * 1024 * 1024 ; // FIXME: make configurable
636
628
struct statvfs st;
637
- if (statvfs (localStore .config ->realStoreDir .get ().c_str (), &st) == 0
629
+ if (statvfs (store .config ->realStoreDir .get ().c_str (), &st) == 0
638
630
&& (uint64_t ) st.f_bavail * st.f_bsize < required)
639
631
diskFull = true ;
640
632
if (statvfs (tmpDir.c_str (), &st) == 0 && (uint64_t ) st.f_bavail * st.f_bsize < required)
@@ -712,7 +704,7 @@ void DerivationBuilderImpl::startBuilder()
712
704
Magenta (drv.platform ),
713
705
concatStringsSep (" , " , drvOptions.getRequiredSystemFeatures (drv)),
714
706
Magenta (settings.thisSystem ),
715
- concatStringsSep<StringSet>(" , " , store.config .systemFeatures ));
707
+ concatStringsSep<StringSet>(" , " , store.Store :: config.systemFeatures ));
716
708
717
709
// since aarch64-darwin has Rosetta 2, this user can actually run x86_64-darwin on their hardware - we should
718
710
// tell them to run the command to install Darwin 2
@@ -724,7 +716,7 @@ void DerivationBuilderImpl::startBuilder()
724
716
throw BuildError (msg);
725
717
}
726
718
727
- auto buildDir = getLocalStore ( store) .config ->getBuildDir ();
719
+ auto buildDir = store.config ->getBuildDir ();
728
720
729
721
createDirs (buildDir);
730
722
@@ -1173,7 +1165,7 @@ void DerivationBuilderImpl::startDaemon()
1173
1165
1174
1166
auto store = makeRestrictedStore (
1175
1167
[&] {
1176
- auto config = make_ref<LocalStore::Config>(*getLocalStore ( this ->store ) .config );
1168
+ auto config = make_ref<LocalStore::Config>(*this ->store .config );
1177
1169
config->pathInfoCacheSize = 0 ;
1178
1170
config->stateDir = " /no-such-path" ;
1179
1171
config->logDir = " /no-such-path" ;
@@ -1430,8 +1422,6 @@ SingleDrvOutputs DerivationBuilderImpl::registerOutputs()
1430
1422
outputs to allow hard links between outputs. */
1431
1423
InodesSeen inodesSeen;
1432
1424
1433
- Path checkSuffix = " .check" ;
1434
-
1435
1425
std::exception_ptr delayedException;
1436
1426
1437
1427
/* The paths that can be referenced are the input closures, the
@@ -1466,23 +1456,19 @@ SingleDrvOutputs DerivationBuilderImpl::registerOutputs()
1466
1456
std::map<std::string, struct stat > outputStats;
1467
1457
for (auto & [outputName, _] : drv.outputs ) {
1468
1458
auto scratchOutput = get (scratchOutputs, outputName);
1469
- if (!scratchOutput)
1470
- throw BuildError (
1471
- " builder for '%s' has no scratch output for '%s'" , store.printStorePath (drvPath), outputName);
1459
+ assert (scratchOutput);
1472
1460
auto actualPath = realPathInSandbox (store.printStorePath (*scratchOutput));
1473
1461
1474
1462
outputsToSort.insert (outputName);
1475
1463
1476
1464
/* Updated wanted info to remove the outputs we definitely don't need to register */
1477
1465
auto initialOutput = get (initialOutputs, outputName);
1478
- if (!initialOutput)
1479
- throw BuildError (
1480
- " builder for '%s' has no initial output for '%s'" , store.printStorePath (drvPath), outputName);
1466
+ assert (initialOutput);
1481
1467
auto & initialInfo = *initialOutput;
1482
1468
1483
1469
/* Don't register if already valid, and not checking */
1484
- initialInfo. wanted = buildMode == bmCheck || !(initialInfo.known && initialInfo.known ->isValid ());
1485
- if (!initialInfo. wanted ) {
1470
+ bool wanted = buildMode == bmCheck || !(initialInfo.known && initialInfo.known ->isValid ());
1471
+ if (!wanted) {
1486
1472
outputReferencesIfUnregistered.insert_or_assign (
1487
1473
outputName, AlreadyRegistered{.path = initialInfo.known ->path });
1488
1474
continue ;
@@ -1839,8 +1825,6 @@ SingleDrvOutputs DerivationBuilderImpl::registerOutputs()
1839
1825
}
1840
1826
}
1841
1827
1842
- auto & localStore = getLocalStore (store);
1843
-
1844
1828
if (buildMode == bmCheck) {
1845
1829
1846
1830
if (!store.isValidPath (newInfo.path ))
@@ -1849,7 +1833,7 @@ SingleDrvOutputs DerivationBuilderImpl::registerOutputs()
1849
1833
if (newInfo.narHash != oldInfo.narHash ) {
1850
1834
miscMethods->noteCheckMismatch ();
1851
1835
if (settings.runDiffHook || settings.keepFailed ) {
1852
- auto dst = store.toRealPath (finalDestPath + checkSuffix );
1836
+ auto dst = store.toRealPath (finalDestPath + " .check " );
1853
1837
deletePath (dst);
1854
1838
movePath (actualPath, dst);
1855
1839
@@ -1876,8 +1860,8 @@ SingleDrvOutputs DerivationBuilderImpl::registerOutputs()
1876
1860
/* Since we verified the build, it's now ultimately trusted. */
1877
1861
if (!oldInfo.ultimate ) {
1878
1862
oldInfo.ultimate = true ;
1879
- localStore .signPathInfo (oldInfo);
1880
- localStore .registerValidPaths ({{oldInfo.path , oldInfo}});
1863
+ store .signPathInfo (oldInfo);
1864
+ store .registerValidPaths ({{oldInfo.path , oldInfo}});
1881
1865
}
1882
1866
1883
1867
continue ;
@@ -1891,20 +1875,20 @@ SingleDrvOutputs DerivationBuilderImpl::registerOutputs()
1891
1875
debug (" unreferenced input: '%1%'" , store.printStorePath (i));
1892
1876
}
1893
1877
1894
- localStore .optimisePath (actualPath, NoRepair); // FIXME: combine with scanForReferences()
1878
+ store .optimisePath (actualPath, NoRepair); // FIXME: combine with scanForReferences()
1895
1879
miscMethods->markContentsGood (newInfo.path );
1896
1880
1897
1881
newInfo.deriver = drvPath;
1898
1882
newInfo.ultimate = true ;
1899
- localStore .signPathInfo (newInfo);
1883
+ store .signPathInfo (newInfo);
1900
1884
1901
1885
finish (newInfo.path );
1902
1886
1903
1887
/* If it's a CA path, register it right away. This is necessary if it
1904
1888
isn't statically known so that we can safely unlock the path before
1905
1889
the next iteration */
1906
1890
if (newInfo.ca )
1907
- localStore .registerValidPaths ({{newInfo.path , newInfo}});
1891
+ store .registerValidPaths ({{newInfo.path , newInfo}});
1908
1892
1909
1893
infos.emplace (outputName, std::move (newInfo));
1910
1894
}
@@ -1925,13 +1909,11 @@ SingleDrvOutputs DerivationBuilderImpl::registerOutputs()
1925
1909
paths referenced by each of them. If there are cycles in the
1926
1910
outputs, this will fail. */
1927
1911
{
1928
- auto & localStore = getLocalStore (store);
1929
-
1930
1912
ValidPathInfos infos2;
1931
1913
for (auto & [outputName, newInfo] : infos) {
1932
1914
infos2.insert_or_assign (newInfo.path , newInfo);
1933
1915
}
1934
- localStore .registerValidPaths (infos2);
1916
+ store .registerValidPaths (infos2);
1935
1917
}
1936
1918
1937
1919
/* In case of a fixed-output derivation hash mismatch, throw an
@@ -2164,7 +2146,7 @@ StorePath DerivationBuilderImpl::makeFallbackPath(const StorePath & path)
2164
2146
namespace nix {
2165
2147
2166
2148
std::unique_ptr<DerivationBuilder> makeDerivationBuilder (
2167
- Store & store, std::unique_ptr<DerivationBuilderCallbacks> miscMethods, DerivationBuilderParams params)
2149
+ LocalStore & store, std::unique_ptr<DerivationBuilderCallbacks> miscMethods, DerivationBuilderParams params)
2168
2150
{
2169
2151
bool useSandbox = false ;
2170
2152
@@ -2191,8 +2173,7 @@ std::unique_ptr<DerivationBuilder> makeDerivationBuilder(
2191
2173
useSandbox = params.drv .type ().isSandboxed () && !params.drvOptions .noChroot ;
2192
2174
}
2193
2175
2194
- auto & localStore = getLocalStore (store);
2195
- if (localStore.storeDir != localStore.config ->realStoreDir .get ()) {
2176
+ if (store.storeDir != store.config ->realStoreDir .get ()) {
2196
2177
#ifdef __linux__
2197
2178
useSandbox = true ;
2198
2179
#else
0 commit comments