My nixos configuration
1# Generated by npins. Do not modify; will be overwritten regularly
2let
3 data = builtins.fromJSON (builtins.readFile ./sources.json);
4 version = data.version;
5
6 mkSource = spec:
7 assert spec ? type; let
8 path =
9 if spec.type == "Git"
10 then mkGitSource spec
11 else if spec.type == "GitRelease"
12 then mkGitSource spec
13 else if spec.type == "PyPi"
14 then mkPyPiSource spec
15 else if spec.type == "Channel"
16 then mkChannelSource spec
17 else builtins.throw "Unknown source type ${spec.type}";
18 in
19 spec // {outPath = path;};
20
21 mkGitSource = {
22 repository,
23 revision,
24 url ? null,
25 hash,
26 ...
27 }:
28 assert repository ? type;
29 # At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
30 # In the latter case, there we will always be an url to the tarball
31 if url != null
32 then
33 (builtins.fetchTarball {
34 inherit url;
35 sha256 = hash; # FIXME: check nix version & use SRI hashes
36 })
37 else
38 assert repository.type == "Git";
39 builtins.fetchGit {
40 url = repository.url;
41 rev = revision;
42 # hash = hash;
43 };
44
45 mkPyPiSource = {
46 url,
47 hash,
48 ...
49 }:
50 builtins.fetchurl {
51 inherit url;
52 sha256 = hash;
53 };
54
55 mkChannelSource = {
56 url,
57 hash,
58 ...
59 }:
60 builtins.fetchTarball {
61 inherit url;
62 sha256 = hash;
63 };
64in
65 if version == 3
66 then builtins.mapAttrs (_: mkSource) data.pins
67 else throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"