Skip to content

Commit e20c2ab

Browse files
committed
upgrade npins
1 parent a28f421 commit e20c2ab

File tree

5 files changed

+268
-24
lines changed

5 files changed

+268
-24
lines changed

nix/default.nix

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/*
2+
This file is provided under the MIT licence:
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
6+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
8+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9+
*/
10+
# Generated by npins. Do not modify; will be overwritten regularly
11+
let
12+
data = builtins.fromJSON (builtins.readFile ./sources.json);
13+
version = data.version;
14+
15+
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
16+
range =
17+
first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1);
18+
19+
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
20+
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
21+
22+
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
23+
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
24+
concatMapStrings = f: list: concatStrings (map f list);
25+
concatStrings = builtins.concatStringsSep "";
26+
27+
# If the environment variable NPINS_OVERRIDE_${name} is set, then use
28+
# the path directly as opposed to the fetched source.
29+
# (Taken from Niv for compatibility)
30+
mayOverride =
31+
name: path:
32+
let
33+
envVarName = "NPINS_OVERRIDE_${saneName}";
34+
saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name;
35+
ersatz = builtins.getEnv envVarName;
36+
in
37+
if ersatz == "" then
38+
path
39+
else
40+
# this turns the string into an actual Nix path (for both absolute and
41+
# relative paths)
42+
builtins.trace "Overriding path of \"${name}\" with \"${ersatz}\" due to set \"${envVarName}\"" (
43+
if builtins.substring 0 1 ersatz == "/" then
44+
/. + ersatz
45+
else
46+
/. + builtins.getEnv "PWD" + "/${ersatz}"
47+
);
48+
49+
mkSource =
50+
name: spec:
51+
assert spec ? type;
52+
let
53+
path =
54+
if spec.type == "Git" then
55+
mkGitSource spec
56+
else if spec.type == "GitRelease" then
57+
mkGitSource spec
58+
else if spec.type == "PyPi" then
59+
mkPyPiSource spec
60+
else if spec.type == "Channel" then
61+
mkChannelSource spec
62+
else if spec.type == "Tarball" then
63+
mkTarballSource spec
64+
else
65+
builtins.throw "Unknown source type ${spec.type}";
66+
in
67+
spec // { outPath = mayOverride name path; };
68+
69+
mkGitSource =
70+
{
71+
repository,
72+
revision,
73+
url ? null,
74+
submodules,
75+
hash,
76+
branch ? null,
77+
...
78+
}:
79+
assert repository ? type;
80+
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
81+
# In the latter case, there we will always be an url to the tarball
82+
if url != null && !submodules then
83+
builtins.fetchTarball {
84+
inherit url;
85+
sha256 = hash; # FIXME: check nix version & use SRI hashes
86+
}
87+
else
88+
let
89+
url =
90+
if repository.type == "Git" then
91+
repository.url
92+
else if repository.type == "GitHub" then
93+
"https://github.com/${repository.owner}/${repository.repo}.git"
94+
else if repository.type == "GitLab" then
95+
"${repository.server}/${repository.repo_path}.git"
96+
else
97+
throw "Unrecognized repository type ${repository.type}";
98+
urlToName =
99+
url: rev:
100+
let
101+
matched = builtins.match "^.*/([^/]*)(\\.git)?$" url;
102+
103+
short = builtins.substring 0 7 rev;
104+
105+
appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else "";
106+
in
107+
"${if matched == null then "source" else builtins.head matched}${appendShort}";
108+
name = urlToName url revision;
109+
in
110+
builtins.fetchGit {
111+
rev = revision;
112+
inherit name;
113+
# hash = hash;
114+
inherit url submodules;
115+
};
116+
117+
mkPyPiSource =
118+
{ url, hash, ... }:
119+
builtins.fetchurl {
120+
inherit url;
121+
sha256 = hash;
122+
};
123+
124+
mkChannelSource =
125+
{ url, hash, ... }:
126+
builtins.fetchTarball {
127+
inherit url;
128+
sha256 = hash;
129+
};
130+
131+
mkTarballSource =
132+
{
133+
url,
134+
locked_url ? url,
135+
hash,
136+
...
137+
}:
138+
builtins.fetchTarball {
139+
url = locked_url;
140+
sha256 = hash;
141+
};
142+
in
143+
if version == 5 then
144+
builtins.mapAttrs mkSource data.pins
145+
else
146+
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"

nix/inputs.nix

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# {
66
# <name> = <source>;
77
# }
8-
main = import ../npins { };
8+
main = import ../npins;
99

1010
# Sources for Nix releases, the attribute name is the release version.
1111
# These are done specially because updating these is non-trivial.
@@ -26,8 +26,14 @@
2626
# Sources for Nixpkgs releases, the attribute name is the release name.
2727
# These can be updated with the standard npins tooling, but are tracked separately to avoid having to filter them out during processing.
2828
# See ./update-nixpkgs-releases.nix
29-
nixpkgs = import ../npins {
30-
json = ./sources.json;
31-
};
29+
nixpkgs =
30+
builtins.mapAttrs (name: value:
31+
# This matches the nix-prefetch-url --unpack --name source call in ./update-nix-releases.nix
32+
fetchTarball {
33+
name = "source";
34+
url = value.url;
35+
sha256 = value.hash;
36+
}
37+
) (builtins.fromJSON (builtins.readFile ./sources.json)).pins;
3238

3339
}

nix/sources.json

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"repo": "nixpkgs"
99
},
1010
"branch": "nixos-18.09",
11+
"submodules": false,
1112
"revision": "a7e559a5504572008567383c3dc8e142fa7a8633",
1213
"url": "https://github.com/nixos/nixpkgs/archive/a7e559a5504572008567383c3dc8e142fa7a8633.tar.gz",
1314
"hash": "16j95q58kkc69lfgpjkj76gw5sx8rcxwi3civm0mlfaxxyw9gzp6"
@@ -20,6 +21,7 @@
2021
"repo": "nixpkgs"
2122
},
2223
"branch": "nixos-19.03",
24+
"submodules": false,
2325
"revision": "34c7eb7545d155cc5b6f499b23a7cb1c96ab4d59",
2426
"url": "https://github.com/nixos/nixpkgs/archive/34c7eb7545d155cc5b6f499b23a7cb1c96ab4d59.tar.gz",
2527
"hash": "11z6ajj108fy2q5g8y4higlcaqncrbjm3dnv17pvif6avagw4mcb"
@@ -32,6 +34,7 @@
3234
"repo": "nixpkgs"
3335
},
3436
"branch": "nixos-19.09",
37+
"submodules": false,
3538
"revision": "75f4ba05c63be3f147bcc2f7bd4ba1f029cedcb1",
3639
"url": "https://github.com/nixos/nixpkgs/archive/75f4ba05c63be3f147bcc2f7bd4ba1f029cedcb1.tar.gz",
3740
"hash": "157c64220lf825ll4c0cxsdwg7cxqdx4z559fdp7kpz0g6p8fhhr"
@@ -44,6 +47,7 @@
4447
"repo": "nixpkgs"
4548
},
4649
"branch": "nixos-20.03",
50+
"submodules": false,
4751
"revision": "1db42b7fe3878f3f5f7a4f2dc210772fd080e205",
4852
"url": "https://github.com/nixos/nixpkgs/archive/1db42b7fe3878f3f5f7a4f2dc210772fd080e205.tar.gz",
4953
"hash": "05k9y9ki6jhaqdhycnidnk5zrdzsdammbk5lsmsbz249hjhhgcgh"
@@ -56,6 +60,7 @@
5660
"repo": "nixpkgs"
5761
},
5862
"branch": "nixos-20.09",
63+
"submodules": false,
5964
"revision": "1c1f5649bb9c1b0d98637c8c365228f57126f361",
6065
"url": "https://github.com/nixos/nixpkgs/archive/1c1f5649bb9c1b0d98637c8c365228f57126f361.tar.gz",
6166
"hash": "0f2nvdijyxfgl5kwyb4465pppd5vkhqxddx6v40k2s0z9jfhj0xl"
@@ -68,6 +73,7 @@
6873
"repo": "nixpkgs"
6974
},
7075
"branch": "nixos-21.05",
76+
"submodules": false,
7177
"revision": "022caabb5f2265ad4006c1fa5b1ebe69fb0c3faf",
7278
"url": "https://github.com/nixos/nixpkgs/archive/022caabb5f2265ad4006c1fa5b1ebe69fb0c3faf.tar.gz",
7379
"hash": "12q00nbd7fb812zchbcnmdg3pw45qhxm74hgpjmshc2dfmgkjh4n"
@@ -80,6 +86,7 @@
8086
"repo": "nixpkgs"
8187
},
8288
"branch": "nixos-21.11",
89+
"submodules": false,
8390
"revision": "eabc38219184cc3e04a974fe31857d8e0eac098d",
8491
"url": "https://github.com/nixos/nixpkgs/archive/eabc38219184cc3e04a974fe31857d8e0eac098d.tar.gz",
8592
"hash": "04ffwp2gzq0hhz7siskw6qh9ys8ragp7285vi1zh8xjksxn1msc5"
@@ -92,6 +99,7 @@
9299
"repo": "nixpkgs"
93100
},
94101
"branch": "nixos-22.05",
102+
"submodules": false,
95103
"revision": "380be19fbd2d9079f677978361792cb25e8a3635",
96104
"url": "https://github.com/nixos/nixpkgs/archive/380be19fbd2d9079f677978361792cb25e8a3635.tar.gz",
97105
"hash": "154x9swf494mqwi4z8nbq2f0sp8pwp4fvx51lqzindjfbb9yxxv5"
@@ -104,6 +112,7 @@
104112
"repo": "nixpkgs"
105113
},
106114
"branch": "nixos-22.11",
115+
"submodules": false,
107116
"revision": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b",
108117
"url": "https://github.com/nixos/nixpkgs/archive/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b.tar.gz",
109118
"hash": "1xi53rlslcprybsvrmipm69ypd3g3hr7wkxvzc73ag8296yclyll"
@@ -116,6 +125,7 @@
116125
"repo": "nixpkgs"
117126
},
118127
"branch": "nixos-23.05",
128+
"submodules": false,
119129
"revision": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421",
120130
"url": "https://github.com/nixos/nixpkgs/archive/70bdadeb94ffc8806c0570eb5c2695ad29f0e421.tar.gz",
121131
"hash": "05cbl1k193c9la9xhlz4y6y8ijpb2mkaqrab30zij6z4kqgclsrd"
@@ -128,6 +138,7 @@
128138
"repo": "nixpkgs"
129139
},
130140
"branch": "nixos-23.11",
141+
"submodules": false,
131142
"revision": "205fd4226592cc83fd4c0885a3e4c9c400efabb5",
132143
"url": "https://github.com/nixos/nixpkgs/archive/205fd4226592cc83fd4c0885a3e4c9c400efabb5.tar.gz",
133144
"hash": "1f5d2g1p6nfwycpmrnnmc2xmcszp804adp16knjvdkj8nz36y1fg"
@@ -140,6 +151,7 @@
140151
"repo": "nixpkgs"
141152
},
142153
"branch": "nixos-24.05",
154+
"submodules": false,
143155
"revision": "b134951a4c9f3c995fd7be05f3243f8ecd65d798",
144156
"url": "https://github.com/nixos/nixpkgs/archive/b134951a4c9f3c995fd7be05f3243f8ecd65d798.tar.gz",
145157
"hash": "0zydsqiaz8qi4zd63zsb2gij2p614cgkcaisnk11wjy3nmiq0x1s"
@@ -152,11 +164,24 @@
152164
"repo": "nixpkgs"
153165
},
154166
"branch": "nixos-24.11",
155-
"revision": "62c435d93bf046a5396f3016472e8f7c8e2aed65",
156-
"url": "https://github.com/nixos/nixpkgs/archive/62c435d93bf046a5396f3016472e8f7c8e2aed65.tar.gz",
157-
"hash": "0zpvadqbs19jblnd0j2rfs9m7j0n5spx0vilq8907g2gqrx63fqp"
167+
"submodules": false,
168+
"revision": "2baa12ff69913392faf0ace833bc54bba297ea95",
169+
"url": "https://github.com/nixos/nixpkgs/archive/2baa12ff69913392faf0ace833bc54bba297ea95.tar.gz",
170+
"hash": "0b98zjp4klps935sch2n0mysfr3l9sz13d2r74dsgnsnklsxm0ak"
171+
},
172+
"25.05": {
173+
"type": "Git",
174+
"repository": {
175+
"type": "GitHub",
176+
"owner": "nixos",
177+
"repo": "nixpkgs"
178+
},
179+
"branch": "nixos-25.05",
180+
"submodules": false,
181+
"revision": "55d1f923c480dadce40f5231feb472e81b0bab48",
182+
"url": "https://github.com/nixos/nixpkgs/archive/55d1f923c480dadce40f5231feb472e81b0bab48.tar.gz",
183+
"hash": "0i0ayb1p7ypbjnjf837qlfn6n3i3468cvalha54yakjdi6a6srnb"
158184
}
159185
},
160-
"version": 3
186+
"version": 5
161187
}
162-

0 commit comments

Comments
 (0)