Skip to content

Commit 9792d6b

Browse files
committed
Move DerivationBuilder to its own file/header
The building logic is now free of the scheduling logic! (The interface between them is just what is in the new header. This makes it much easier to audit, and shrink over time.)
1 parent 6c2a7fd commit 9792d6b

File tree

9 files changed

+143
-6799
lines changed

9 files changed

+143
-6799
lines changed

maintainers/flake-module.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@
284284
''^src/libstore/build/goal\.cc$''
285285
''^src/libstore/include/nix/store/build/goal\.hh$''
286286
''^src/libstore/unix/build/hook-instance\.cc$''
287+
''^src/libstore/unix/build/derivation-builder\.cc$''
288+
''^src/libstore/unix/include/nix/store/build/derivation-builder\.hh$''
287289
''^src/libstore/unix/build/local-derivation-goal\.cc$''
288290
''^src/libstore/unix/include/nix/store/build/local-derivation-goal\.hh$''
289291
''^src/libstore/build/substitution-goal\.cc$''
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#pragma once
2+
/**
3+
* @file Misc type defitions for both local building and remote (RPC building)
4+
*/
5+
6+
#include "nix/util/hash.hh"
7+
#include "nix/store/path.hh"
8+
9+
namespace nix {
10+
11+
class Store;
12+
13+
/**
14+
* Unless we are repairing, we don't both to test validity and just assume it,
15+
* so the choices are `Absent` or `Valid`.
16+
*/
17+
enum struct PathStatus {
18+
Corrupt,
19+
Absent,
20+
Valid,
21+
};
22+
23+
struct InitialOutputStatus
24+
{
25+
StorePath path;
26+
PathStatus status;
27+
/**
28+
* Valid in the store, and additionally non-corrupt if we are repairing
29+
*/
30+
bool isValid() const
31+
{
32+
return status == PathStatus::Valid;
33+
}
34+
/**
35+
* Merely present, allowed to be corrupt
36+
*/
37+
bool isPresent() const
38+
{
39+
return status == PathStatus::Corrupt || status == PathStatus::Valid;
40+
}
41+
};
42+
43+
struct InitialOutput
44+
{
45+
bool wanted;
46+
Hash outputHash;
47+
std::optional<InitialOutputStatus> known;
48+
};
49+
50+
void runPostBuildHook(Store & store, Logger & logger, const StorePath & drvPath, const StorePathSet & outputPaths);
51+
52+
}

src/libstore/include/nix/store/build/derivation-goal.hh

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
#include "nix/store/parsed-derivations.hh"
55
#include "nix/store/derivations.hh"
66
#include "nix/store/derivation-options.hh"
7-
#ifndef _WIN32
8-
# include "nix/store/user-lock.hh"
9-
#endif
7+
#include "nix/store/build/derivation-building-misc.hh"
108
#include "nix/store/outputs-spec.hh"
119
#include "nix/store/store-api.hh"
1210
#include "nix/store/pathlocks.hh"
@@ -22,40 +20,6 @@ struct HookInstance;
2220

2321
typedef enum {rpAccept, rpDecline, rpPostpone} HookReply;
2422

25-
/**
26-
* Unless we are repairing, we don't both to test validity and just assume it,
27-
* so the choices are `Absent` or `Valid`.
28-
*/
29-
enum struct PathStatus {
30-
Corrupt,
31-
Absent,
32-
Valid,
33-
};
34-
35-
struct InitialOutputStatus {
36-
StorePath path;
37-
PathStatus status;
38-
/**
39-
* Valid in the store, and additionally non-corrupt if we are repairing
40-
*/
41-
bool isValid() const {
42-
return status == PathStatus::Valid;
43-
}
44-
/**
45-
* Merely present, allowed to be corrupt
46-
*/
47-
bool isPresent() const {
48-
return status == PathStatus::Corrupt
49-
|| status == PathStatus::Valid;
50-
}
51-
};
52-
53-
struct InitialOutput {
54-
bool wanted;
55-
Hash outputHash;
56-
std::optional<InitialOutputStatus> known;
57-
};
58-
5923
/** Used internally */
6024
void runPostBuildHook(
6125
Store & store,
@@ -308,6 +272,4 @@ struct DerivationGoal : public Goal
308272
};
309273
};
310274

311-
MakeError(NotDeterministic, BuildError);
312-
313275
}

src/libstore/include/nix/store/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ headers = [config_pub_h] + files(
1313
'binary-cache-store.hh',
1414
'build-result.hh',
1515
'build/derivation-goal.hh',
16+
'build/derivation-building-misc.hh',
1617
'build/drv-output-substitution-goal.hh',
1718
'build/goal.hh',
1819
'build/substitution-goal.hh',

0 commit comments

Comments
 (0)