summary refs log tree commit diff stats
path: root/npins
diff options
context:
space:
mode:
Diffstat (limited to 'npins')
-rw-r--r--npins/default.nix80
-rw-r--r--npins/sources.json95
2 files changed, 175 insertions, 0 deletions
diff --git a/npins/default.nix b/npins/default.nix
new file mode 100644
index 00000000..5e7d086e
--- /dev/null
+++ b/npins/default.nix
@@ -0,0 +1,80 @@
+# Generated by npins. Do not modify; will be overwritten regularly
+let
+  data = builtins.fromJSON (builtins.readFile ./sources.json);
+  version = data.version;
+
+  mkSource =
+    spec:
+    assert spec ? type;
+    let
+      path =
+        if spec.type == "Git" then
+          mkGitSource spec
+        else if spec.type == "GitRelease" then
+          mkGitSource spec
+        else if spec.type == "PyPi" then
+          mkPyPiSource spec
+        else if spec.type == "Channel" then
+          mkChannelSource spec
+        else
+          builtins.throw "Unknown source type ${spec.type}";
+    in
+    spec // { outPath = path; };
+
+  mkGitSource =
+    {
+      repository,
+      revision,
+      url ? null,
+      hash,
+      branch ? null,
+      ...
+    }:
+    assert repository ? type;
+    # At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
+    # In the latter case, there we will always be an url to the tarball
+    if url != null then
+      (builtins.fetchTarball {
+        inherit url;
+        sha256 = hash; # FIXME: check nix version & use SRI hashes
+      })
+    else
+      assert repository.type == "Git";
+      let
+        urlToName =
+          url: rev:
+          let
+            matched = builtins.match "^.*/([^/]*)(\\.git)?$" repository.url;
+
+            short = builtins.substring 0 7 rev;
+
+            appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else "";
+          in
+          "${if matched == null then "source" else builtins.head matched}${appendShort}";
+        name = urlToName repository.url revision;
+      in
+      builtins.fetchGit {
+        url = repository.url;
+        rev = revision;
+        inherit name;
+        # hash = hash;
+      };
+
+  mkPyPiSource =
+    { url, hash, ... }:
+    builtins.fetchurl {
+      inherit url;
+      sha256 = hash;
+    };
+
+  mkChannelSource =
+    { url, hash, ... }:
+    builtins.fetchTarball {
+      inherit url;
+      sha256 = hash;
+    };
+in
+if version == 3 then
+  builtins.mapAttrs (_: mkSource) data.pins
+else
+  throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"
diff --git a/npins/sources.json b/npins/sources.json
new file mode 100644
index 00000000..b1d9dab9
--- /dev/null
+++ b/npins/sources.json
@@ -0,0 +1,95 @@
+{
+  "pins": {
+    "agenix": {
+      "type": "Git",
+      "repository": {
+        "type": "GitHub",
+        "owner": "ryantm",
+        "repo": "agenix"
+      },
+      "branch": "main",
+      "revision": "c2fc0762bbe8feb06a2e59a364fa81b3a57671c9",
+      "url": "https://github.com/ryantm/agenix/archive/c2fc0762bbe8feb06a2e59a364fa81b3a57671c9.tar.gz",
+      "hash": "1lpkwinlax40b7xgzspbkm9rsi4a1x48hxhixnni4irxxwnav0ah"
+    },
+    "darwin": {
+      "type": "Git",
+      "repository": {
+        "type": "GitHub",
+        "owner": "lnl7",
+        "repo": "nix-darwin"
+      },
+      "branch": "master",
+      "revision": "0bea8222f6e83247dd13b055d83e64bce02ee532",
+      "url": "https://github.com/lnl7/nix-darwin/archive/0bea8222f6e83247dd13b055d83e64bce02ee532.tar.gz",
+      "hash": "1df3yr784x0jg6wna3hdri2z0fyzdxf7amaz6b216cigd06bymz4"
+    },
+    "emacs-overlay": {
+      "type": "Git",
+      "repository": {
+        "type": "GitHub",
+        "owner": "nix-community",
+        "repo": "emacs-overlay"
+      },
+      "branch": "master",
+      "revision": "929e09706815a9e10cc749393eaa5895761de32a",
+      "url": "https://github.com/nix-community/emacs-overlay/archive/929e09706815a9e10cc749393eaa5895761de32a.tar.gz",
+      "hash": "00g9sb3f0d32jq38aq02bx9glysgkdjs7y906hx9rwzmm2bvd9q4"
+    },
+    "home-manager": {
+      "type": "Git",
+      "repository": {
+        "type": "GitHub",
+        "owner": "nix-community",
+        "repo": "home-manager"
+      },
+      "branch": "master",
+      "revision": "05e6ba83eb3585ce0aff7b41e4bd0e317d05ad4a",
+      "url": "https://github.com/nix-community/home-manager/archive/05e6ba83eb3585ce0aff7b41e4bd0e317d05ad4a.tar.gz",
+      "hash": "0jmwyln74bmq8q0q7bkhw3dz36dcnb1iqhk7ws9vqp8g4i748xjf"
+    },
+    "nix-index-database": {
+      "type": "Git",
+      "repository": {
+        "type": "GitHub",
+        "owner": "Mic92",
+        "repo": "nix-index-database"
+      },
+      "branch": "main",
+      "revision": "6e4a2b3b7c60aae5dac8c21117a134a4a56648da",
+      "url": "https://github.com/Mic92/nix-index-database/archive/6e4a2b3b7c60aae5dac8c21117a134a4a56648da.tar.gz",
+      "hash": "0r3lgbhk74r7795l14yn9g5yvm5izygzx0w309zdg6drns4d8gc3"
+    },
+    "nixos-hardware": {
+      "type": "Git",
+      "repository": {
+        "type": "GitHub",
+        "owner": "NixOS",
+        "repo": "nixos-hardware"
+      },
+      "branch": "master",
+      "revision": "2e7d6c568063c83355fe066b8a8917ee758de1b8",
+      "url": "https://github.com/NixOS/nixos-hardware/archive/2e7d6c568063c83355fe066b8a8917ee758de1b8.tar.gz",
+      "hash": "0z6b44w1sxlxqir7pprs3d26zkim39kqwqlf9jwanzjvgbgrkvkx"
+    },
+    "nixpkgs": {
+      "type": "Channel",
+      "name": "nixos-unstable",
+      "url": "https://releases.nixos.org/nixos/unstable/nixos-24.11pre630835.bfb7a882678e/nixexprs.tar.xz",
+      "hash": "04qn48v4vjpxsk00x407v558p3f1x8blwjppk2sswzbjhyn2vgxw"
+    },
+    "nur": {
+      "type": "Git",
+      "repository": {
+        "type": "GitHub",
+        "owner": "nix-community",
+        "repo": "NUR"
+      },
+      "branch": "master",
+      "revision": "ccb21d26b4f6f574561c3d7139960228f7051bd2",
+      "url": "https://github.com/nix-community/NUR/archive/ccb21d26b4f6f574561c3d7139960228f7051bd2.tar.gz",
+      "hash": "1lnddszkdgbj8vn143b1gv654wjxx31gkfja17cic8r0fxwzzv41"
+    }
+  },
+  "version": 3
+}
\ No newline at end of file