Repository navigation
Expand file tree
/
Copy pathwire.nix
More file actions
68 lines (65 loc) · 2.42 KB
/
Copy pathwire.nix
File metadata and controls
68 lines (65 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Every source, as a directory: the ten in this tree, and each pin of
# `flake.lock`.
#
# A source's own `nix/sources.nix` calls this, here and in its exported
# repository. There it passes `overrides.<name> = ../.`, so the source builds
# from its own tree against its siblings at the nixidae commit its lock names.
#
# Each member is a store path of its own, named `source`, holding what git
# tracks. That is what a fetch of the member's own repository gives, so a
# build here, a build in CI and a build of the exported repository agree,
# and a change in one member does not change another's source.
#
# In a checkout the tracked tree comes from `fetchGit` of the working copy:
# uncommitted edits count, and so does a new file, because jj marks it
# intent-to-add in git's index. A `result` link or a local scratch file does
# not, since git ignores it. A fetched tree has no `.git`, and is already
# what git tracks.
#
# A flake we do not own is called through nix/call-flake.nix, the only place
# a flake is read.
{
inputs ? import ./compat.nix,
overrides ? { },
}:
let
# A jj workspace that is not colocated has `.jj` and no `.git`. Nix cannot
# read what jj tracks there, and the plain path would take ignored files too.
tree =
if builtins.pathExists ../.git then
(builtins.fetchGit { url = toString ../.; }).outPath
else if builtins.pathExists ../.jj then
throw "nix/wire.nix: ${toString ../.} is a jj workspace without .git, so Nix cannot read what jj tracks in it. Run `jj git colocation enable` there (jj >= 0.46). nixidae/nixidae#18"
else
../.;
members = builtins.mapAttrs (
name: _:
builtins.path {
path = "${tree}/${name}";
name = "source";
}
) (import ./members.nix);
# An ignored checkout of one of these, beside the sources, takes the place
# of its pin, so an edit there reaches the next build. What git tracks in
# it counts, as for a member. A clone or a fetched tree has none, and the
# lock answers.
checkouts = [
"containerd"
"flake-compatish"
"kr8s"
];
checkout =
name:
let
dir = ../. + "/${name}";
in
builtins.elem name checkouts && builtins.pathExists dir && builtins.readDir dir != { };
pinned = builtins.mapAttrs (
name: input:
if checkout name then
(builtins.fetchGit { url = toString ../. + "/${name}"; }).outPath
else
input.outPath
) (removeAttrs inputs [ "self" ]);
in
pinned // members // overrides