diff options
Diffstat (limited to '')
| -rw-r--r-- | npins/default.nix | 158 | ||||
| -rw-r--r-- | npins/sources.json | 136 |
2 files changed, 205 insertions, 89 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 3a74c0a..8540f90 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -9,9 +9,9 @@ }, "branch": "main", "submodules": false, - "revision": "aa8519ec107d7cfa29b03005c9176708e1269965", - "url": "https://github.com/ai-robots-txt/ai.robots.txt/archive/aa8519ec107d7cfa29b03005c9176708e1269965.tar.gz", - "hash": "01injirgqzzhd7sqarhlf54b994b70c7f8g88xrkqsy4gs0vzx9v" + "revision": "0e111dcc24cbcdf4e609edde70f9f9184eac8b02", + "url": "https://github.com/ai-robots-txt/ai.robots.txt/archive/0e111dcc24cbcdf4e609edde70f9f9184eac8b02.tar.gz", + "hash": "sha256-JBN4kvpilklvgpI7mWsWc7+2ww16ZYdoiqJT4gZFePg=" }, "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": "83031c010be0ed73f45ba5975d16cb05a1638ff1", + "revision": "250be698ace92026668f08ada962e6e517717d92", "url": null, - "hash": "19kfjrndg5xvspwqljgsiyadi4fjnq99zfpr9k6bnx3z2g2m1rk8" + "hash": "sha256-tN7pdV5CrMcSW3+8iifKS2of3BUcJL77f4HB3xw+y6A=" }, "blog": { "type": "Git", @@ -45,9 +45,9 @@ }, "branch": "main", "submodules": false, - "revision": "61d865b1cb837f059bcd0b215d6f83ae33393e32", + "revision": "9758e92c4786f28d59a4b4bee90410142095097d", "url": null, - "hash": "0076rfb3fzb8j9mbi0xlv1fx8l0v9rvba6gfn6xydds75ahmf0bj" + "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": "0d782ee42c86b196acff08acfbf41bb7d13eed5b", - "url": "https://github.com/nix-community/home-manager/archive/0d782ee42c86b196acff08acfbf41bb7d13eed5b.tar.gz", - "hash": "1kqxy6r4ahnbazmpa4pncdp62najdikdaw8hvrv8nl6qxvbmf9fy" + "revision": "ec172013fa62135f58fb58dd17ae9651e8f39727", + "url": "https://github.com/nix-community/home-manager/archive/ec172013fa62135f58fb58dd17ae9651e8f39727.tar.gz", + "hash": "sha256-LWiBv9yAYFi2LPbUhDGHPGKYskJQjj2fw12OlyO1uQo=" }, "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": "95ac829cf361035d8d8ee46eb3540d21f7bac842", + "revision": "f04a78f6871e0ccf8404b3cdcd68bbd63f16a2c1", "url": null, - "hash": "0ncnlyyhbrk24xvjzv3wlab50qx3pqqfsrp06a5088rq355kpilc" + "hash": "sha256-rI6ESsiP8BOMz7P2FZYblrMv4sMwkCqM34bKepsMzO8=" }, "lix-nixos-module": { "type": "Git", @@ -150,9 +150,9 @@ }, "branch": "main", "submodules": false, - "revision": "1688100bba140492658d597f6b307c327f35c780", + "revision": "c5b8d8576206ddce31b86e336476c2f9b8361085", "url": null, - "hash": "0pyzj0rdq62fz2i06ldwf9ridp195p6vvsp8yb1pii8h2q81v9lp" + "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": "23f0a53ca6e58e61e1ea2b86791c69b79c91656d", - "url": "https://gitlab.com/api/v4/projects/simple-nixos-mailserver%2Fnixos-mailserver/repository/archive.tar.gz?sha=23f0a53ca6e58e61e1ea2b86791c69b79c91656d", - "hash": "0pqc7bay9v360x2b7irqaz4ly63gp4z859cgg5c04imknv0pwjqw" + "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": "23d72dabcb3b12469f57b37170fcbc1789bd7457", - "url": "https://github.com/NixOS/nixpkgs/archive/23d72dabcb3b12469f57b37170fcbc1789bd7457.tar.gz", - "hash": "0dhpsdghgajfkbq8d00p9x4nbnzgl4wmkz7h77zvgc3h40ylk4yg" + "revision": "c3eea5b2156db11c7eeeada3dc737711255b253e", + "url": "https://github.com/NixOS/nixpkgs/archive/c3eea5b2156db11c7eeeada3dc737711255b253e.tar.gz", + "hash": "sha256-vdhpDJ3Lr24lkZ+fDCjmBRRtw9/vcSzkqGJOJyF5h2U=" }, "nixpkgs-unstable": { "type": "Git", @@ -202,9 +202,9 @@ }, "branch": "nixpkgs-unstable", "submodules": false, - "revision": "fef9403a3e4d31b0a23f0bacebbec52c248fbb51", - "url": "https://github.com/NixOS/nixpkgs/archive/fef9403a3e4d31b0a23f0bacebbec52c248fbb51.tar.gz", - "hash": "1fzknmnvbfj8bxkw7bqcyjvxy3v2vz11vkp3r8nwihmrf6wnlpd4" + "revision": "c7def046b9a883d46974757852106483d741586f", + "url": "https://github.com/NixOS/nixpkgs/archive/c7def046b9a883d46974757852106483d741586f.tar.gz", + "hash": "sha256-6RSEDHIWQtesQKWSu5qRai8L2h4KgCgMEfJHstW99G4=" }, "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": "1f373ef8c4cc1237a74c681b47bbdbdf7ab185a6", - "url": "https://github.com/tweag/opam-nix/archive/1f373ef8c4cc1237a74c681b47bbdbdf7ab185a6.tar.gz", - "hash": "1n1xzxrzypxr7wr3ij0yf13fsrx6xac9jd3m06pk4d2icpq0lmrv" + "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": "12731a6f86d7c452a94c72106fa9d3327988582d", - "url": "https://github.com/dune-universe/opam-overlays/archive/12731a6f86d7c452a94c72106fa9d3327988582d.tar.gz", - "hash": "0zhgcn5j5aygxqkzsfdsfafw17pr9f2fcs7175kiwyrfj2wzsdmn" + "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": "11a396520bf911e4ed01e78e11633d3fc63b350e", - "url": "https://github.com/oxalica/rust-overlay/archive/11a396520bf911e4ed01e78e11633d3fc63b350e.tar.gz", - "hash": "1wxy14xdw29z144vmp90iai8k5zq3ppq5p1bvbvnnbbg9kx5z4mf" + "revision": "89e99bf0778a8f2cd18c9360c3f19c1ee47fc739", + "url": "https://github.com/oxalica/rust-overlay/archive/89e99bf0778a8f2cd18c9360c3f19c1ee47fc739.tar.gz", + "hash": "sha256-Aggle++fTyAifBy+QBPxjM+obO5iepKW/8MDxQtgGvI=" }, "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,21 +337,33 @@ }, "branch": "master", "submodules": false, - "revision": "d6e0e666048a5395d6ea4283143b7c9ac704720d", - "url": "https://github.com/Mic92/sops-nix/archive/d6e0e666048a5395d6ea4283143b7c9ac704720d.tar.gz", - "hash": "0f2l5w6af84skfmy051s5727n2wc3bq2fvdjf34jkliyi7jdgfy5" + "revision": "13616fff713a9f94055c66f15687ebdc17a335df", + "url": "https://github.com/Mic92/sops-nix/archive/13616fff713a9f94055c66f15687ebdc17a335df.tar.gz", + "hash": "sha256-4GuMPW90JSxXWDPUB9M+1m7fYbe3H0apOd86/zBQ2Kw=" + }, + "tracktrain": { + "type": "Git", + "repository": { + "type": "Git", + "url": "https://stuebinm.eu/git/tracktrain" + }, + "branch": "main", + "submodules": false, + "revision": "dbb5c4b6b882cd99981eb854386586854a23fdec", + "url": null, + "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", @@ -363,8 +375,8 @@ "submodules": false, "revision": "b61c0b191578d6ed39a6038cca7b436764a1f9f1", "url": null, - "hash": "0675z5gvw0chx3hrr7bpiqxiwcykxhgw8qws17yazi071i8jgl29" + "hash": "sha256-SdAnUQwHxK/8CZpjxB/s0zMeO453nZzh6JABvl/55Rg=" } }, - "version": 5 + "version": 7 } |
