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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
/*
SPDX-FileCopyrightText: 2025–2026 toastal
SPDX-License-Identifier: ISC
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice & this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED “AS IS” & ISC DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY &
FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
OF THIS SOFTWARE.
──────────────────────────────────────────────────────────────────────────────
┏┓╻+╻ ╱┏┳┓┏┓┏┳┓┏┓╻
┃┃┃┃┗━┓╹┃╹┣┫┃┃┃┣┫┃ This file was generated by Nixtamal.
╹┗┛╹╱ ╹ ╹ ╹╹╹ ╹╹╹┗┛ Do not edit as it will be overwritten.
──────────────────────────────────────────────────────────────────────────────
*/
{
system ? builtins.currentSystem,
nixpkgs ? null,
bootstrap-nixpkgs-lock-name ? null,
}:
let lock = builtins.fromJSON (builtins.readFile ./lock.json); in
assert (lock.v == "0.1.1");
let
try-fetch = name: fetcher:
let
try-fetch' = failed-urls: url: urls:
let result = builtins.tryEval (fetcher url); in
if result.success then
result.value
else
let failed-urls' = [ url ] ++ failed-urls; in
if builtins.length urls <= 0 then
let fus = builtins.concatStringsSep " " failed-urls'; in
throw "Input 「${name}」fetchable @ [ ${fus} ]"
else
try-fetch' failed-urls' (builtins.head urls) (builtins.tail urls);
in
try-fetch' [ ];
builtin-fetch-tarball = {name, kind, hash}:
try-fetch name (url:
builtins.fetchTarball {
inherit url;
${hash.al} = hash.vl;
}
) kind.ur kind.ms;
builtin-to-input = name: input:
let k = builtins.head input.kd; in
if k == 1 then
builtin-fetch-tarball {
inherit name;
kind = builtins.elemAt input.kd 1;
hash = input.ha;
}
else
throw "Unsupported input kind “${builtins.toString k}”.";
nixpkgs' = if builtins.isNull nixpkgs then
builtin-to-input "nixpkgs-for-nixtamal" (
if builtins.isString bootstrap-nixpkgs-lock-name then
lock.i.${bootstrap-nixpkgs-lock-name}
else
lock.i.nixpkgs-nixtamal or lock.i.nixpkgs
)
else
nixpkgs;
pkgs = import nixpkgs' {inherit system;};
inherit (pkgs) lib;
fetch-zip = {name, kind, hash}: pkgs.fetchzip {
inherit name;
url = kind.ur;
${hash.al} = hash.vl;
} // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };
fetch-darcs = {name, kind, hash}:
let
using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;
mirror-support = pkgs.fetchdarcs.__functionArgs ? "mirrors";
reference =
let
type = builtins.elemAt kind.rf 0;
value = builtins.elemAt kind.rf 1;
in
if type == 0 then
let ctx_path = builtins.elemAt value 1; in
assert (lib.hasSuffix ".txt" ctx_path);
let
txt-files = lib.sourceFilesBySuffices ./. [ ".txt" ];
dir = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.fromSource txt-files;
};
in
{context = "${dir}/${ctx_path}";}
else if type == 1 then
{rev = value;}
else
throw "Invalid Darcs reference";
in
lib.warnIf (using-mirrors && !mirror-support)
"Upstream pkgs.fetchdarcs doesn’t yet support mirrors for 「${name}」"
pkgs.fetchdarcs ({
url = kind.rp;
${hash.al} = hash.vl;
} // reference // lib.optionalAttrs (using-mirrors && mirror-support){
mirrors = kind.ms;
});
to-input = name: input:
let k = builtins.head input.kd; in
if k == 1 then
fetch-zip {
inherit name;
kind = builtins.elemAt input.kd 1;
hash = input.ha;
}
else if k == 3 then
fetch-darcs {
inherit name;
kind = builtins.elemAt input.kd 1;
hash = input.ha;
}
else
throw "Unsupported input kind “${builtins.toString k}”.";
in
builtins.mapAttrs to-input lock.i
|