Skip to content

Commit f405bd2

Browse files
committed
Migrate from niv to npins
It has been a blast to use niv for the last few years. It has never really let me down and almost always done what I wanted. But even the best marriages might have to part at some point. I've recently wanted a few tiny changes in how Niv works but I do not feel confident in changing the Niv code. It is vast and the brief period in which I thought I could take over the maintainership of the project was crushed after looking into all the feature requests. Many of which just have nothing to do with the features that I associated Niv with. After going through the issues I sat down for an afternoon and rewrote what I needed from Niv (and more) in Rust. Npins was born. The initial version that did everything I needed was less than 100 lines of Rust and very few lines of nix boilerplate. Now npins supports more than Niv ever provided for pinning my dependencies. One feature I've longed for and never got around to properly implement was pinning based on GitHub releases. Very often I want to track releases of a project and not deal with breaking changes every other day. With this commit the initial migration away from niv is complete.
1 parent b13c543 commit f405bd2

File tree

7 files changed

+249
-433
lines changed

7 files changed

+249
-433
lines changed

.envrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
#unset SSL_CERT_FILE
33
use_nix
44

5-
for file in nix/* tools/*; do
5+
for file in nix/* nix/pins/* tools/*; do
66
watch_file "${file}"
77
done

nix/npins/default.nix

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
let
2+
data = builtins.fromJSON (builtins.readFile ./pins.json);
3+
4+
mkSource = spec:
5+
assert spec ? type;
6+
if spec.type == "Git" then mkGitSource spec
7+
else if spec.type == "GitHub" then mkGitHubSource spec
8+
else if spec.type == "GitHubRelease" then mkGitHubReleaseSource spec
9+
else builtins.throw "Unknown source type ${spec.type}";
10+
11+
mkGitSource = spec:
12+
let
13+
path = builtins.fetchGit (with spec; {
14+
url = repository_url;
15+
ref = "refs/heads/${branch}";
16+
rev = revision;
17+
# hash = hash;
18+
});
19+
in
20+
spec // { outPath = path; }
21+
;
22+
23+
mkGitHubSource = spec:
24+
let
25+
url = with spec; "https://github.com/${owner}/${repository}/archive/${revision}.tar.gz";
26+
path = (builtins.fetchTarball {
27+
inherit url;
28+
sha256 = spec.hash; # FIXME: check nix version & use SRI hashes
29+
});
30+
in
31+
spec // { outPath = path; }
32+
;
33+
34+
mkGitHubReleaseSource = spec:
35+
let
36+
path = builtins.fetchTarball {
37+
url = spec.tarball_url;
38+
sha256 = spec.hash;
39+
};
40+
in
41+
spec // { outPath = path; };
42+
43+
in
44+
builtins.mapAttrs (_: mkSource) data.pins

nix/npins/pins.json

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
{
2+
"pins": {
3+
"ate": {
4+
"type": "GitHub",
5+
"repository": "ate",
6+
"owner": "andir",
7+
"branch": "master",
8+
"revision": "d6e1c1a007f1c9616153e160bcc3ffa5330dac7c",
9+
"hash": "1vil5sq2w6b7z66g87wmsl9vjnvlbwlmzsi4f730zd22dbmm481j"
10+
},
11+
"bertha-nixpkgs": {
12+
"type": "GitHub",
13+
"repository": "nixpkgs",
14+
"owner": "nixos",
15+
"branch": "nixos-unstable",
16+
"revision": "c464dc811babfe316ed4ab7bbc12351122e69dd7",
17+
"hash": "0aij4q6pc99xjqh0inv6z74wiqfdgxnbg7jli6gnjqxg2lcirrc2"
18+
},
19+
"c3schedule": {
20+
"type": "GitHub",
21+
"repository": "c3schedule",
22+
"owner": "andir",
23+
"branch": "master",
24+
"revision": "50e754471953f271d13c07af42f9f1455bda467e",
25+
"hash": "1b5b724d2ggk4cl19kivg99sd2s5i608xpp1j0krzj5j8ksgm39s"
26+
},
27+
"crappy-nixpkgs": {
28+
"type": "GitHub",
29+
"repository": "nixpkgs",
30+
"owner": "nixos",
31+
"branch": "nixos-unstable",
32+
"revision": "c464dc811babfe316ed4ab7bbc12351122e69dd7",
33+
"hash": "0aij4q6pc99xjqh0inv6z74wiqfdgxnbg7jli6gnjqxg2lcirrc2"
34+
},
35+
"dendrite": {
36+
"type": "GitHub",
37+
"repository": "dendrite",
38+
"owner": "matrix-org",
39+
"branch": "master",
40+
"revision": "7a9a2547b337acaa01a911a150871665799147a7",
41+
"hash": "1pw3mr3ibqm8fyisf63ad4vgabpj9i05rj1aid8c8757r3s5g3r2"
42+
},
43+
"dex": {
44+
"type": "GitHub",
45+
"repository": "dex",
46+
"owner": "dexidp",
47+
"branch": "master",
48+
"revision": "3fac2ab6bc3bc3cb56afa6d71adce293d5abbed8",
49+
"hash": "08hapaisikwd8f9zs91r1m3l4yav929hijrwfq4xay3vpq6zvxb7"
50+
},
51+
"dn42-registry": {
52+
"type": "Git",
53+
"repository_url": "https://gitlab.com/andi-/dn42-registry.git",
54+
"branch": "master",
55+
"revision": "10f0c6da92a122b8cb9f9ac9874fa38ecd850bdd",
56+
"hash": "0w0f3rwnq3fwnc32izpjp6wrwj04pfkcc4i2n5n5z26f32yijj0b"
57+
},
58+
"dn42-regparse": {
59+
"type": "GitHub",
60+
"repository": "dn42-regparse",
61+
"owner": "andir",
62+
"branch": "master",
63+
"revision": "455644586b893ff0badb8006aa8f46308438264a",
64+
"hash": "1zx6bi3b87dwzlx8ry0d303dbaxqnq2vz8pdaa8mhra7x13hyyiy"
65+
},
66+
"knot_exporter": {
67+
"type": "GitHub",
68+
"repository": "knot_exporter",
69+
"owner": "andir",
70+
"branch": "master",
71+
"revision": "6f35fc84a14b6cf6641d9b716991ac7581b17e9d",
72+
"hash": "1jibfcsfn3qyz53iyqan8bvzskvb6g55c9ffhic93s98fld86zdy"
73+
},
74+
"matrix-static": {
75+
"type": "GitHub",
76+
"repository": "matrix-static",
77+
"owner": "matrix-org",
78+
"branch": "master",
79+
"revision": "c778780f604b32e6c3603874231e3819789d8241",
80+
"hash": "1n59vv4xjzbs7237b1v8vlgblsdyw2hw8fi8sfjh05mqhxh5panf"
81+
},
82+
"modules": {
83+
"type": "Git",
84+
"repository_url": "https://git.darmstadt.ccc.de/nixos/modules.git",
85+
"branch": "master",
86+
"revision": "bf5329d14ce941e09593c98ba0fc7208ec5a4925",
87+
"hash": "1ylx1qzh4clb7kf7nnnh9y5vdk81r7q325c0smwh20x2dawm5wzs"
88+
},
89+
"morph": {
90+
"type": "GitHub",
91+
"repository": "morph",
92+
"owner": "DBCDK",
93+
"branch": "master",
94+
"revision": "f5a168e995ca72079c86e40ec79f81fc342a1680",
95+
"hash": "09b3gi6z2h06rr75nw5bfias4yrj44mnlad1j10ki2qclz3d9nmj"
96+
},
97+
"nixos-1909": {
98+
"type": "GitHub",
99+
"repository": "nixpkgs",
100+
"owner": "nixos",
101+
"branch": "nixos-19.09",
102+
"revision": "75f4ba05c63be3f147bcc2f7bd4ba1f029cedcb1",
103+
"hash": "157c64220lf825ll4c0cxsdwg7cxqdx4z559fdp7kpz0g6p8fhhr"
104+
},
105+
"nixos-mailserver": {
106+
"type": "Git",
107+
"repository_url": "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver.git",
108+
"branch": "master",
109+
"revision": "42db23553d433646398ca08e9c61071d01d3350f",
110+
"hash": "17za9fi1af10pc7cb16746vf85wclbkdib77wmn3gp05zgnfbbng"
111+
},
112+
"nixos-security-tracker": {
113+
"type": "GitHub",
114+
"repository": "nixos-security-tracker",
115+
"owner": "andir",
116+
"branch": "master",
117+
"revision": "be4a9d82f7b7bf4baf61c288f1f03808a8df72bb",
118+
"hash": "11csfpdqblb9dzqizq33d1ddaz34q2wjhmld2aqdf8z51qdpaw3v"
119+
},
120+
"nixpkgs": {
121+
"type": "GitHub",
122+
"repository": "nixpkgs",
123+
"owner": "nixos",
124+
"branch": "nixos-21.05",
125+
"revision": "d4590d21006387dcb190c516724cb1e41c0f8fdf",
126+
"hash": "17q39hlx1x87xf2rdygyimj8whdbx33nzszf4rxkc6b85wz0l38n"
127+
},
128+
"nixpkgs-esp32": {
129+
"type": "GitHub",
130+
"repository": "nixpkgs",
131+
"owner": "plietar",
132+
"branch": "esp32",
133+
"revision": "56d622f706e9c09331eadd08914464e779fe057d",
134+
"hash": "18m3lry7id4w9dyp8hw5f13nma837cr4y0nx5qz95zfqfii0ckpd"
135+
},
136+
"nixpkgs-unstable": {
137+
"type": "GitHub",
138+
"repository": "nixpkgs",
139+
"owner": "nixos",
140+
"branch": "nixos-unstable",
141+
"revision": "c464dc811babfe316ed4ab7bbc12351122e69dd7",
142+
"hash": "0aij4q6pc99xjqh0inv6z74wiqfdgxnbg7jli6gnjqxg2lcirrc2"
143+
},
144+
"npins": {
145+
"type": "GitHub",
146+
"repository": "npins",
147+
"owner": "andir",
148+
"branch": "master",
149+
"revision": "bf04082df684b2fb00f83e6a2f50f97d362b8b90",
150+
"hash": "0a4svn4qb3f6r8n4k6rwcmbxs3is6adbjni2im1zzb5wi886ij2p"
151+
},
152+
"npmlock2nix": {
153+
"type": "GitHub",
154+
"repository": "npmlock2nix",
155+
"owner": "tweag",
156+
"branch": "master",
157+
"revision": "a84ef095fe899f8a932b753880901d2864cd7350",
158+
"hash": "0bwgsx793zxfyiq5i1bpllchbzdds5znv4qsbj9rj61qbx5j11ai"
159+
},
160+
"photoprism": {
161+
"type": "GitHub",
162+
"repository": "photoprism",
163+
"owner": "photoprism",
164+
"branch": "master",
165+
"revision": "3ce4fddbf36c8023f43784cc8e28da45cab3dd19",
166+
"hash": "0knglyiz9xr2lipk45rcp9cg8xsi8nx0srx2cyynk7w6a4d3vgyv"
167+
},
168+
"pre-commit-hooks.nix": {
169+
"type": "GitHub",
170+
"repository": "pre-commit-hooks.nix",
171+
"owner": "cachix",
172+
"branch": "master",
173+
"revision": "397f0713d007250a2c7a745e555fa16c5dc8cadb",
174+
"hash": "0hjbq4pf8a2qdndx0xdb3yjhx9l3l5grk4mlk78vw4zm32fgyrq2"
175+
},
176+
"publictransport": {
177+
"type": "Git",
178+
"repository_url": "https://git.darmstadt.ccc.de/cda/publictransport.git",
179+
"branch": "master",
180+
"revision": "df632629948513f322b9d58ffb4d4b7e0bc20b7a",
181+
"hash": "0iqccm4ajr28qkiba4fx5fqbgahnrdxqyfjqdd3mcabl8zrp8qhm"
182+
},
183+
"ranz2nix": {
184+
"type": "GitHub",
185+
"repository": "ranz2nix",
186+
"owner": "andir",
187+
"branch": "master",
188+
"revision": "637276c3110716d2a798e737fe62e54b37190d50",
189+
"hash": "0jaxw74srgabzz5sawy6nv27rpghmwxw53m5csnrhgy39a9yaki4"
190+
},
191+
"zigbee2mqtt": {
192+
"type": "GitHub",
193+
"repository": "zigbee2mqtt",
194+
"owner": "Koenkk",
195+
"branch": "dev",
196+
"revision": "a380df4f216a78205bd7452909e0b546773b3d73",
197+
"hash": "0gz2rgc4lxj8p21sl8d1yq8i6y7jigcw3sbb6rpcgh92x6ikld8z"
198+
}
199+
}
200+
}

nix/packages/photoprism/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ buildGo116Module {
6565

6666
inherit src;
6767

68-
sourceRoot = "photoprism-src/frontend";
68+
sourceRoot = "source/frontend";
6969

7070
postUnpack = ''
7171
chmod -R +rw .

0 commit comments

Comments
 (0)