diff options
Diffstat (limited to '')
| -rw-r--r-- | npins/default.nix | 158 | ||||
| -rw-r--r-- | npins/sources.json | 126 |
2 files changed, 194 insertions, 90 deletions
diff --git a/npins/default.nix b/npins/default.nix index 8955703..b7f402e 100644 --- a/npins/default.nix +++ b/npins/default.nix @@ -9,8 +9,15 @@ */ # Generated by npins. Do not modify; will be overwritten regularly let - data = builtins.fromJSON (builtins.readFile ./sources.json); - version = data.version; + # Backwards-compatibly make something that previously didn't take any arguments take some + # The function must return an attrset, and will unfortunately be eagerly evaluated + # Same thing, but it catches eval errors on the default argument so that one may still call it with other arguments + mkFunctor = + fn: + let + e = builtins.tryEval (fn { }); + in + (if e.success then e.value else { error = fn { }; }) // { __functor = _self: fn; }; # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 range = @@ -21,7 +28,6 @@ let # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); - concatMapStrings = f: list: concatStrings (map f list); concatStrings = builtins.concatStringsSep ""; # If the environment variable NPINS_OVERRIDE_${name} is set, then use @@ -48,19 +54,62 @@ let mkSource = name: spec: + { + pkgs ? null, + }: assert spec ? type; let + # Unify across builtin and pkgs fetchers. + # `fetchGit` requires a wrapper because of slight API differences. + fetchers = + if pkgs == null then + { + inherit (builtins) fetchTarball fetchurl; + # Frustratingly, due to flakes and `fetchTree`, `fetchGit` + # has a different signature than the other builtin + # fetchers + fetchGit = args: (builtins.fetchGit args).outPath; + } + else + { + fetchTarball = + { + url, + sha256, + }: + pkgs.fetchzip { + inherit url sha256; + extension = "tar"; + }; + inherit (pkgs) fetchurl; + fetchGit = + { + url, + submodules, + rev, + name, + narHash, + }: + pkgs.fetchgit { + inherit url rev name; + fetchSubmodules = submodules; + hash = narHash; + }; + }; + path = if spec.type == "Git" then - mkGitSource spec + mkGitSource fetchers spec else if spec.type == "GitRelease" then - mkGitSource spec + mkGitSource fetchers spec else if spec.type == "PyPi" then - mkPyPiSource spec + mkPyPiSource fetchers spec else if spec.type == "Channel" then - mkChannelSource spec + mkChannelSource fetchers spec else if spec.type == "Tarball" then - mkTarballSource spec + mkTarballSource fetchers spec + else if spec.type == "Container" then + mkContainerSource pkgs spec else builtins.throw "Unknown source type ${spec.type}"; in @@ -68,21 +117,25 @@ let mkGitSource = { + fetchTarball, + fetchGit, + ... + }: + { repository, revision, url ? null, submodules, 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 && !submodules then - builtins.fetchTarball { + fetchTarball { inherit url; - sha256 = hash; # FIXME: check nix version & use SRI hashes + sha256 = hash; } else let @@ -93,6 +146,8 @@ let "https://github.com/${repository.owner}/${repository.repo}.git" else if repository.type == "GitLab" then "${repository.server}/${repository.repo_path}.git" + else if repository.type == "Forgejo" then + "${repository.server}/${repository.owner}/${repository.repo}.git" else throw "Unrecognized repository type ${repository.type}"; urlToName = @@ -107,42 +162,91 @@ let "${if matched == null then "source" else builtins.head matched}${appendShort}"; name = urlToName url revision; in - builtins.fetchGit ({ + fetchGit { rev = revision; - inherit name; - # hash = hash; - inherit url submodules; - } // (if branch != null then { - ref = "refs/heads/${branch}"; - } else {})); + narHash = hash; + + inherit name submodules url; + }; mkPyPiSource = - { url, hash, ... }: - builtins.fetchurl { + { fetchurl, ... }: + { + url, + hash, + ... + }: + fetchurl { inherit url; sha256 = hash; }; mkChannelSource = - { url, hash, ... }: - builtins.fetchTarball { + { fetchTarball, ... }: + { + url, + hash, + ... + }: + fetchTarball { inherit url; sha256 = hash; }; mkTarballSource = + { fetchTarball, ... }: { url, locked_url ? url, hash, ... }: - builtins.fetchTarball { + fetchTarball { url = locked_url; sha256 = hash; }; + + mkContainerSource = + pkgs: + { + image_name, + image_tag, + image_digest, + hash, + ... + }: + if pkgs == null then + builtins.throw "container sources require passing in a Nixpkgs value: https://github.com/andir/npins/blob/master/README.md#using-the-nixpkgs-fetchers" + else + pkgs.dockerTools.pullImage { + imageName = image_name; + imageDigest = image_digest; + finalImageTag = image_tag; + hash = hash; + }; in -if version == 5 then - builtins.mapAttrs mkSource data.pins -else - throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`" +mkFunctor ( + { + input ? ./sources.json, + }: + let + data = + if builtins.isPath input then + # while `readFile` will throw an error anyways if the path doesn't exist, + # we still need to check beforehand because *our* error can be caught but not the one from the builtin + # See: <https://git.lix.systems/lix-project/lix/issues/1098> + if builtins.pathExists input then + builtins.fromJSON (builtins.readFile input) + else + throw "Input path ${toString input} does not exist" + else if builtins.isAttrs input then + input + else + throw "Unsupported input type ${builtins.typeOf input}, must be a path or an attrset"; + version = data.version; + in + if version == 7 then + builtins.mapAttrs (name: spec: mkFunctor (mkSource name spec)) 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 index 46e2f0d..516d6e7 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -9,9 +9,9 @@ }, "branch": "main", "submodules": false, - "revision": "f420408eee6c6a8c4eaf3536d6f9c926c9b01fa4", - "url": "https://github.com/ai-robots-txt/ai.robots.txt/archive/f420408eee6c6a8c4eaf3536d6f9c926c9b01fa4.tar.gz", - "hash": "0b9sv1y3bkpy29fh35kam7zirvx2kdwf8yngfn1zx7qwm6ylxr0a" + "revision": "7cd4c923433eded951ca535c33d9a56fa5c5d58e", + "url": "https://github.com/ai-robots-txt/ai.robots.txt/archive/7cd4c923433eded951ca535c33d9a56fa5c5d58e.tar.gz", + "hash": "sha256-X8pIqZgpSJUILptc1B4evccRM7vX2mWP5qCUovbIAj8=" }, "almanac": { "type": "Git", @@ -23,7 +23,7 @@ "submodules": false, "revision": "cdd82b013777324f146c4961b866154a9287110b", "url": null, - "hash": "0804k1zcnyhfdgjxmpgyg9l537j6p4ajrjgzz9svxka6acc1l85h" + "hash": "sha256-sCAaGFNGzb51+v/JLBW5Rp5RaHr+3drlaw56y36YBCA=" }, "bahnhof-name": { "type": "Git", @@ -33,9 +33,9 @@ }, "branch": "rnv", "submodules": false, - "revision": "7f690b4f530c368ec0074bb6fc4b1c35155a7615", + "revision": "250be698ace92026668f08ada962e6e517717d92", "url": null, - "hash": "10zmb0dhr124ad8ssrg9h017hp459diyp7xl015l2hs6r15y6si4" + "hash": "sha256-tN7pdV5CrMcSW3+8iifKS2of3BUcJL77f4HB3xw+y6A=" }, "blog": { "type": "Git", @@ -45,9 +45,9 @@ }, "branch": "main", "submodules": false, - "revision": "bc81eb5833227b97bda1d7c35c5feefab539d1f4", + "revision": "9758e92c4786f28d59a4b4bee90410142095097d", "url": null, - "hash": "0c1ndlha08n5m34gmkd6kq9m9f5nc2f7qzxijadwjs2gnqkni31z" + "hash": "sha256-mr2Pn7cXM4qr0XuXcHYCdWWoORo8QtsVGv/r0KgDltA=" }, "deploy-rs": { "type": "Git", @@ -59,7 +59,7 @@ "submodules": false, "revision": "9001480e03ab8c957716e2bf164bbde605472399", "url": null, - "hash": "1iiplqa731ldha728xk2fi36n87p20hnzf35g21jli1dlknw388f" + "hash": "sha256-DqHB7aQtRCqDeGW4byEQ9yBrRnRidiSOgo2GcRSmN8Y=" }, "flake-compat": { "type": "GitRelease", @@ -75,7 +75,7 @@ "version": "v1.1.0", "revision": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", "url": "https://api.github.com/repos/edolstra/flake-compat/tarball/v1.1.0", - "hash": "19d2z6xsvpxm184m41qrpi1bplilwipgnzv9jy17fgw421785q1m" + "hash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=" }, "flake-utils": { "type": "GitRelease", @@ -91,7 +91,7 @@ "version": "v1.0.0", "revision": "04c1b180862888302ddfb2e3ad9eaa63afc60cf8", "url": "https://api.github.com/repos/numtide/flake-utils/tarball/v1.0.0", - "hash": "0hynd4rbkbplxzl2a8wb3r8z0h17z2alhhdsam78g3vgzpzg0d43" + "hash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=" }, "gtfsBooks": { "type": "Git", @@ -101,9 +101,9 @@ }, "branch": "main", "submodules": false, - "revision": "2a9d4fcf48b872aef1343f71dfddf44946fd8eb5", + "revision": "51ac2f45a806496e384a2a58b8a8604afb687759", "url": null, - "hash": "077xjxaisjqcnqwjpq8cfg34y27cv5aidvzwv4d5736rz9v96bak" + "hash": "sha256-q7VOIz2j+1Q9bChwpFme5F+D2l62bckixabUNQeJOjs=" }, "home-manager": { "type": "Git", @@ -112,11 +112,11 @@ "owner": "nix-community", "repo": "home-manager" }, - "branch": "release-25.11", + "branch": "release-26.05", "submodules": false, - "revision": "3ee51fbdac8c8bdfe1e7e1fcaba6520a563f394f", - "url": "https://github.com/nix-community/home-manager/archive/3ee51fbdac8c8bdfe1e7e1fcaba6520a563f394f.tar.gz", - "hash": "13fmry1jd0na71fxhzms9qf3ybj6shgvnphq4p1akxxmv44gzq20" + "revision": "65258d5c65a250189fde2e35f490d15e064c4c62", + "url": "https://github.com/nix-community/home-manager/archive/65258d5c65a250189fde2e35f490d15e064c4c62.tar.gz", + "hash": "sha256-Sxu1NLTD/Ern6hFGLlZmtKCSct3YQXZI/lls8RE1XeM=" }, "isabelle-utils": { "type": "Git", @@ -128,7 +128,7 @@ "submodules": false, "revision": "a44e60333135d9c10b1a0579693ea4c7a655fb05", "url": null, - "hash": "1rksv96izbzcpg74lbix9lw3rxjcy1hs1f4kd8xf4nzclq439931" + "hash": "sha256-YaQ0CKbsW+I6apO4oGHwTPY8OE09LkrOu+yvH03aeuY=" }, "lix": { "type": "Git", @@ -138,9 +138,9 @@ }, "branch": "main", "submodules": false, - "revision": "daa2bc82bc0ddc17fd2b72781f1c740a5a7b264c", + "revision": "d432fa438caa5a0017ec6f3e1212fcfd5b4bf249", "url": null, - "hash": "0agd9vizn0lqvpz2fzdricry8kbbg2zw6aj2hyg80ibg732bcw2j" + "hash": "sha256-oB8a1/s9Q+u4QqvpLUzdL5DICksc94UEAOo/vCJWUIw=" }, "lix-nixos-module": { "type": "Git", @@ -150,9 +150,9 @@ }, "branch": "main", "submodules": false, - "revision": "727d859b6f5f3289ce49fe26146b3f006387d457", + "revision": "c5b8d8576206ddce31b86e336476c2f9b8361085", "url": null, - "hash": "0zzhvi2zy5764pwck1rjwdbrzpgs8k64jvd8j1632ngdvpkmyir2" + "hash": "sha256-Ikdf593tWTFMkKhtScxE+t2fV+Myh8n4JeYU/0Xc8H8=" }, "mirage-opam-overlays": { "type": "Git", @@ -163,9 +163,9 @@ }, "branch": "main", "submodules": false, - "revision": "eddcd1bc7e035392596b603d23dde67a88e6f6bc", - "url": "https://github.com/dune-universe/mirage-opam-overlays/archive/eddcd1bc7e035392596b603d23dde67a88e6f6bc.tar.gz", - "hash": "09cwhnnmphicm4j6figds2ckagbnypdmcqmbgcszjn6zzll5fymx" + "revision": "5ae850a5cb00d570dc7c1c2d7c2995c1b50e674f", + "url": "https://github.com/dune-universe/mirage-opam-overlays/archive/5ae850a5cb00d570dc7c1c2d7c2995c1b50e674f.tar.gz", + "hash": "sha256-2Kovi4lacyRIz9lZrc9pFvinVhLxopDGzlIZXOEMe18=" }, "nixos-mailserver": { "type": "Git", @@ -174,11 +174,11 @@ "repo_path": "simple-nixos-mailserver/nixos-mailserver", "server": "https://gitlab.com/" }, - "branch": "nixos-25.11", + "branch": "nixos-26.05", "submodules": false, - "revision": "25e6dbb8fca3b6e779c5a46fd03bd760b2165bb5", - "url": "https://gitlab.com/api/v4/projects/simple-nixos-mailserver%2Fnixos-mailserver/repository/archive.tar.gz?sha=25e6dbb8fca3b6e779c5a46fd03bd760b2165bb5", - "hash": "0f1mq2gdmx9wd0k89f6w61sbfzpd1wwz857l2xvyp1x0msmd2z20" + "revision": "d357b9f048c5532ec81b0e0034c0b8463d5ddd46", + "url": "https://gitlab.com/api/v4/projects/simple-nixos-mailserver%2Fnixos-mailserver/repository/archive.tar.gz?sha=d357b9f048c5532ec81b0e0034c0b8463d5ddd46", + "hash": "sha256-falBPi+PJtMx0vwII8L24wjDGXNZMwRiVXsw8WTXLEo=" }, "nixpkgs": { "type": "Git", @@ -187,11 +187,11 @@ "owner": "NixOS", "repo": "nixpkgs" }, - "branch": "nixos-25.11", + "branch": "nixos-26.05", "submodules": false, - "revision": "535f3e6942cb1cead3929c604320d3db54b542b9", - "url": "https://github.com/NixOS/nixpkgs/archive/535f3e6942cb1cead3929c604320d3db54b542b9.tar.gz", - "hash": "0f9137a4dggpm5p6ikzh5zvigjnlyfwpi3ssskhx5rwsii7nbzys" + "revision": "5dfba6236110080a54247d6460bc2ff5dda939cc", + "url": "https://github.com/NixOS/nixpkgs/archive/5dfba6236110080a54247d6460bc2ff5dda939cc.tar.gz", + "hash": "sha256-bu1QxmXKmPuvBLN7bHP355OV9Qo13x9WCiRDH62CqRM=" }, "nixpkgs-unstable": { "type": "Git", @@ -202,9 +202,9 @@ }, "branch": "nixpkgs-unstable", "submodules": false, - "revision": "cbb5cf358f50aa6acc9efd6113b7bcfbc352cd73", - "url": "https://github.com/NixOS/nixpkgs/archive/cbb5cf358f50aa6acc9efd6113b7bcfbc352cd73.tar.gz", - "hash": "005lz0rdsj188j63zyim4pkxadqcq276x7w9727ymb2av7awczi1" + "revision": "e8be7818e19ada32105a8af937a6a473b38167ca", + "url": "https://github.com/NixOS/nixpkgs/archive/e8be7818e19ada32105a8af937a6a473b38167ca.tar.gz", + "hash": "sha256-0N9nghg3nwzX6b6qc77EzjR9cu/Z+UR66FlfsCqiURs=" }, "ntfy-matrix-bot": { "type": "Git", @@ -216,7 +216,7 @@ "submodules": false, "revision": "c4bedb1756c96db3f7d01feedc6587f7b0c3dc0f", "url": null, - "hash": "1kq34zk7k6rg9k8frvx51hl1ldqqbfgvhm9f827b5a4c0rx28dah" + "hash": "sha256-UDUkegaMqLKOQC5VuJ9bGDcaKAyl7+zQTC+beeYnA88=" }, "ocaml-forester": { "type": "GitRelease", @@ -231,7 +231,7 @@ "version": "5.0", "revision": "5ceee0e7d20febc0552caad0f71aa01750574d43", "url": null, - "hash": "1ajajlg1yksk666mp5xf0ipy0c2r4pz650mrcprm45rf76xxjmj9" + "hash": "sha256-SVbZuzkuF1LzZbmCYv4lWTDgbwSul1uNMVNPHx6VSqo=" }, "opam-nix": { "type": "Git", @@ -242,9 +242,9 @@ }, "branch": "main", "submodules": false, - "revision": "2e20bbbe8130d1880338291446fd4e710a4db9a1", - "url": "https://github.com/tweag/opam-nix/archive/2e20bbbe8130d1880338291446fd4e710a4db9a1.tar.gz", - "hash": "150swry9dsix1w727rg89r6yv4vh6xx51nxvg2xbyxi409skqb2x" + "revision": "edd1b7bc8574f2242b759b0c4def186af2ab4a70", + "url": "https://github.com/tweag/opam-nix/archive/edd1b7bc8574f2242b759b0c4def186af2ab4a70.tar.gz", + "hash": "sha256-lY9ceaXFru4OWlp6wyJTYaJbXyB4yPvmAOgHiI73pDI=" }, "opam-overlays": { "type": "Git", @@ -255,9 +255,9 @@ }, "branch": "master", "submodules": false, - "revision": "efd742d67b0d49b2d6f491ffbbf205ca42977a6e", - "url": "https://github.com/dune-universe/opam-overlays/archive/efd742d67b0d49b2d6f491ffbbf205ca42977a6e.tar.gz", - "hash": "1f41bfr187kv8r3my41a56czlpj34b3yxl1wlbg4m37yhxns4yyd" + "revision": "d3aca134ac032e7522e95a18f1ef72c63f45459b", + "url": "https://github.com/dune-universe/opam-overlays/archive/d3aca134ac032e7522e95a18f1ef72c63f45459b.tar.gz", + "hash": "sha256-Do6VnAFQm+LTUfpQsHwnP0Efp2AOqhwPMjBU7vQFSDY=" }, "opam-repository": { "type": "GitRelease", @@ -273,7 +273,7 @@ "version": "1.2.0", "revision": "62aabc825803c9dbf126488219524e68d74cd41c", "url": "https://api.github.com/repos/ocaml/opam-repository/tarball/1.2.0", - "hash": "1rk665nzczykyxxs7c7kp2hgy49sn3alvcw15n7gsxm9qyxw0agz" + "hash": "sha256-/ynAu8epdv2OLYGzTdWwOhH/oLjzsKN799N/9m0xZuY=" }, "opam2json": { "type": "GitRelease", @@ -286,10 +286,10 @@ "version_upper_bound": null, "release_prefix": null, "submodules": false, - "version": "v0.4", - "revision": "562752a30aaff8985890ef5a2049a82247fc4b0f", - "url": "https://api.github.com/repos/tweag/opam2json/tarball/v0.4", - "hash": "00z4iqyl1x27nhkn89y771jl0iyqi2kfk8mq55nh0m798xnxz5g6" + "version": "v0.5", + "revision": "03f27d131c97327ed7db91c6dc903101bec08fec", + "url": "https://api.github.com/repos/tweag/opam2json/tarball/v0.5", + "hash": "sha256-rBGN9TERADPXiehNe1/9emO6QqYPrTwSoMdB+BVEWpM=" }, "playground": { "type": "Git", @@ -301,7 +301,7 @@ "submodules": false, "revision": "19144f12772063b1c6f00ad186dabbf53ea25985", "url": null, - "hash": "1ss0n237f0dmw0akw2q0qp8nvnijcg35f9qgy3i27m4ib3gl4ybk" + "hash": "sha256-c3lC31iR1CPi8A8nV8ZjMtpt0cUACz4V4LUBd4awQOs=" }, "rust-overlay": { "type": "Git", @@ -312,9 +312,9 @@ }, "branch": "master", "submodules": false, - "revision": "7d5f8d75fc195a236b46633d7679139698aeb35f", - "url": "https://github.com/oxalica/rust-overlay/archive/7d5f8d75fc195a236b46633d7679139698aeb35f.tar.gz", - "hash": "02m17jzmpym1gh7rj94pf4fsb4ma90sdjz334xd464145cb0yi1i" + "revision": "6a84c41e705533dcc5569ac0731f18406b4cdf86", + "url": "https://github.com/oxalica/rust-overlay/archive/6a84c41e705533dcc5569ac0731f18406b4cdf86.tar.gz", + "hash": "sha256-siCQqLbY7AbZ9V3oyc65K8bhNr7QgZTXoqLTws3pv0s=" }, "showrt": { "type": "Git", @@ -326,7 +326,7 @@ "submodules": false, "revision": "7de36af3c6ffcc25832a6ff2303ba6c4c1101de5", "url": null, - "hash": "09shk9b3969gmbmh8mavgss6f90zb51rsfby5n1d924agxzl93d6" + "hash": "sha256-po1Ef3+KiNSCLX45nUNZHyRntH5bVQTrqi+ZNFaaUCc=" }, "sops-nix": { "type": "Git", @@ -337,9 +337,9 @@ }, "branch": "master", "submodules": false, - "revision": "9ed65852b6257fbeae4355bc24ecfea307ca759a", - "url": "https://github.com/Mic92/sops-nix/archive/9ed65852b6257fbeae4355bc24ecfea307ca759a.tar.gz", - "hash": "0jm1xzqp508avayvnx2q7qiw7wj1kqz6m2g1vr0i1vj03qvhmbqs" + "revision": "a8627b21b9107c5711c96b84f32a9a4b3d45295f", + "url": "https://github.com/Mic92/sops-nix/archive/a8627b21b9107c5711c96b84f32a9a4b3d45295f.tar.gz", + "hash": "sha256-gkig4nPi1CWc4Z50GBsjE4ygSE7hMpl/TwID2an2Cck=" }, "tracktrain": { "type": "Git", @@ -351,19 +351,19 @@ "submodules": false, "revision": "dbb5c4b6b882cd99981eb854386586854a23fdec", "url": null, - "hash": "1ridckbs4pwj9na3nq6dmvqjgyfr40cp05p4f9cxv8way8frkdik" + "hash": "sha256-M7aZHfKKo91ZcuQWcBkg2fkn8a7NYDuUTZJfotdkLeY=" }, "traveltext": { "type": "Git", "repository": { "type": "Git", - "url": "https://stuebinm.eu/git/traveltext" + "url": "ssh://cgit/~/public/traveltext" }, "branch": "main", "submodules": false, - "revision": "d876202506621eb76012c12cbb0e91fd2bb0ada0", + "revision": "3a3fe4e9d140dff030d06e45fd6981d14cf97d16", "url": null, - "hash": "0886l3r4fnnd6pc699n9l7kzh1y00y6bbdalab90gjqccviwv9cd" + "hash": "sha256-qDQgZOWBM123WRNs5ddBT6ohQyNKEat3ilWTfEQ6cf8=" }, "uplcg": { "type": "Git", @@ -375,8 +375,8 @@ "submodules": false, "revision": "b61c0b191578d6ed39a6038cca7b436764a1f9f1", "url": null, - "hash": "0675z5gvw0chx3hrr7bpiqxiwcykxhgw8qws17yazi071i8jgl29" + "hash": "sha256-SdAnUQwHxK/8CZpjxB/s0zMeO453nZzh6JABvl/55Rg=" } }, - "version": 5 + "version": 7 } |
