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
|
# Evaluate one go-deps.nix with every fetcher and buildGo.external stubbed
# out, and list the pins it defines itself.
#
# The stubs are the point: the real buildGo.external runs an analyser over the
# fetched source during evaluation (import-from-derivation), so evaluating the
# real thing means downloading and building every dependency just to read a
# version string. Here a fetcher returns its own arguments instead, encoded
# into a string, and external returns its path and that string.
#
# Only attributes *defined* in `file` as `name = depot.nix.buildGo.external`
# are listed. Files re-export each other (`sharedDeps // rec { … }`,
# `inherit (sharedDeps) …`); without this filter every pin of the shared file
# would be reported again for each project that imports it.
{ file }:
let
pin = kind: a: {
outPath = "pin:" + builtins.toJSON ({
inherit kind;
rev = a.rev or a.tag;
} // (if a ? url then { inherit (a) url; } else { inherit (a) owner repo; }));
};
pkgs = {
fetchFromGitHub = pin "github";
fetchFromGitLab = pin "gitlab";
fetchgit = pin "git";
# bubbletea's src strips examples/ with a runCommand; the pin survives
# inside the script text, which is what we return.
runCommand = _name: _env: script: script;
stdenv.isDarwin = false;
};
depot.nix.buildGo.external = a: { inherit (a) path; src = toString a.src; };
set = import file { inherit depot pkgs; };
lines = builtins.filter builtins.isString
(builtins.split "\n" (builtins.readFile file));
definedHere = n:
let p = builtins.unsafeGetAttrPos n set; in
p != null && p.file == toString file
&& builtins.match "[[:space:]]*${n} = depot\\.nix\\.buildGo\\.external.*"
(builtins.elemAt lines (p.line - 1)) != null;
in
map (n: { name = n; inherit (set.${n}) path src; })
(builtins.filter definedHere (builtins.attrNames set))
|