From 5837ef17b381539fcdccb9dbb73ec0d904091e14 Mon Sep 17 00:00:00 2001 From: Samuel Shuert Date: Wed, 5 Nov 2025 15:38:24 +0000 Subject: [PATCH] chore(npins): upgrade & update Change-Id: lsovxmttznrtuqlswrwvqwkuxmopluyp --- packetmix/npins/default.nix | 141 ++++++++++++++++++++++++++++++----- packetmix/npins/sources.json | 98 ++++++++++++------------ 2 files changed, 170 insertions(+), 69 deletions(-) diff --git a/packetmix/npins/default.nix b/packetmix/npins/default.nix index fc9ebc56..b844b313 100644 --- a/packetmix/npins/default.nix +++ b/packetmix/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,39 +54,85 @@ 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; + # For some fucking reason, 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; + }; + }; + + # Dispatch to the correct code path based on the type 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 spec // { outPath = mayOverride name path; }; 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; } @@ -107,7 +159,7 @@ let "${if matched == null then "source" else builtins.head matched}${appendShort}"; name = urlToName url revision; in - builtins.fetchGit { + fetchGit { rev = revision; narHash = hash; @@ -115,32 +167,81 @@ let }; 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, + ... + }: + 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; + }; in -if version == 6 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 + # *piegames sighs* + 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/packetmix/npins/sources.json b/packetmix/npins/sources.json index f6321cac..98c293ee 100644 --- a/packetmix/npins/sources.json +++ b/packetmix/npins/sources.json @@ -61,9 +61,9 @@ }, "branch": "main", "submodules": false, - "revision": "c518cf4f62659d9cf585da6f29b67f8a77d0fbc0", - "url": "https://github.com/bluesky-social/atproto/archive/c518cf4f62659d9cf585da6f29b67f8a77d0fbc0.tar.gz", - "hash": "sha256-fW9BKtG9vptNYzCh/AWf8m9QoPEGX6najSFlAekElHA=" + "revision": "94ddc8219c144475df622137ab88895255136eda", + "url": "https://github.com/bluesky-social/atproto/archive/94ddc8219c144475df622137ab88895255136eda.tar.gz", + "hash": "sha256-Hs6ZhzahfAIgyTOqD3QahQi6URx0FdDCp9T+lj/sK1k=" }, "catppuccin": { "type": "Git", @@ -88,9 +88,9 @@ }, "branch": "master", "submodules": false, - "revision": "8395ec4576cf54411d974675d26f64208acdcee0", - "url": "https://gitlab.collabora.com/api/v4/projects/collabora%2Fgtimelog/repository/archive.tar.gz?sha=8395ec4576cf54411d974675d26f64208acdcee0", - "hash": "sha256-M9pCF+XVf5ylxgq0BSUn5Vkg1HZ6i88LDiUDM4Y1Ghs=" + "revision": "1be9d9f7e844831f221b67a46a55fc47a164e416", + "url": "https://gitlab.collabora.com/api/v4/projects/collabora%2Fgtimelog/repository/archive.tar.gz?sha=1be9d9f7e844831f221b67a46a55fc47a164e416", + "hash": "sha256-v5WEa7M0mmrxdU1l7nIqyrMaVy2jiJNnXHLiHnw2xIc=" }, "copyparty": { "type": "GitRelease", @@ -103,10 +103,10 @@ "version_upper_bound": null, "release_prefix": null, "submodules": false, - "version": "v1.19.17", - "revision": "e2a15a3a922514efe97afc4afa043cd7c4619ad1", - "url": "https://api.github.com/repos/9001/copyparty/tarball/refs/tags/v1.19.17", - "hash": "sha256-Rb6Lq2CW+LrIH8M4sCPA8k12GX7xNUWK4I+xeByLl+M=" + "version": "v1.19.20", + "revision": "450cd86dc1e98b98ab131fc9417c83289165a507", + "url": "https://api.github.com/repos/9001/copyparty/tarball/refs/tags/v1.19.20", + "hash": "sha256-/Wm8hZvdGfYWdTOF+dgTPX8DGuSKLhGw4qC4crf1dAo=" }, "headscale": { "type": "Git", @@ -117,9 +117,9 @@ }, "branch": "main", "submodules": false, - "revision": "8010cc574ea309728f5c7d3fd1cb08252f0111f5", - "url": "https://github.com/juanfont/headscale/archive/8010cc574ea309728f5c7d3fd1cb08252f0111f5.tar.gz", - "hash": "sha256-lQhaw7SVV+qBEZnH8u+gsEwqIByFlZQyjDJ3RbW7uzM=" + "revision": "2024219bd10adbb5c0d29f900ed0961ace8cc15c", + "url": "https://github.com/juanfont/headscale/archive/2024219bd10adbb5c0d29f900ed0961ace8cc15c.tar.gz", + "hash": "sha256-fWpOvGq+/0Wk1bBELw0CfW1qGffzEK5Dp408fIkr43o=" }, "home-manager": { "type": "Git", @@ -143,9 +143,9 @@ }, "branch": "master", "submodules": false, - "revision": "189c21cf879669008ccf06e78a553f17e88d8ef0", - "url": "https://github.com/nix-community/home-manager/archive/189c21cf879669008ccf06e78a553f17e88d8ef0.tar.gz", - "hash": "sha256-nZh6uvc71nVNaf/y+wesnjwsmJ6IZZUnP2EzpZe48To=" + "revision": "b959c67241cae17fc9e4ee7eaf13dfa8512477ea", + "url": "https://github.com/nix-community/home-manager/archive/b959c67241cae17fc9e4ee7eaf13dfa8512477ea.tar.gz", + "hash": "sha256-0ptUDbYwxv1kk/uzEX4+NJjY2e16MaAhtzAOJ6K0TG0=" }, "impermanence": { "type": "Git", @@ -171,10 +171,10 @@ "version_upper_bound": null, "release_prefix": null, "submodules": false, - "version": "v0.4.2", - "revision": "f0212638a2ec787a7841882f4477d40ae24f0a5d", - "url": "https://api.github.com/repos/nix-community/lanzaboote/tarball/refs/tags/v0.4.2", - "hash": "sha256-AEEDktApTEZ5PZXNDkry2YV2k6t0dTgLPEmAZbnigXU=" + "version": "v0.4.3", + "revision": "65a4aa3d4dccf50f22c0190c7ee660de51c586f2", + "url": "https://api.github.com/repos/nix-community/lanzaboote/tarball/refs/tags/v0.4.3", + "hash": "sha256-If6vQ+KvtKs3ARBO9G3l+4wFSCYtRBrwX1z+I+B61wQ=" }, "lix": { "type": "Git", @@ -186,9 +186,9 @@ }, "branch": "main", "submodules": false, - "revision": "2d2cd7ac03311bddb9645a7ab82c7e78edccbaa0", - "url": "https://git.lix.systems/lix-project/lix/archive/2d2cd7ac03311bddb9645a7ab82c7e78edccbaa0.tar.gz", - "hash": "sha256-jUn34QOaXqguaH+WwB2xWRHlmelvzJfFuEcQrC1cwK0=" + "revision": "24054c110787d725ac0bbdafd40c71c83bf1f9a0", + "url": "https://git.lix.systems/lix-project/lix/archive/24054c110787d725ac0bbdafd40c71c83bf1f9a0.tar.gz", + "hash": "sha256-vFSL9+KvrckyLJB4AEgbAEyKgkaBYBVN6ZDUAa+4Yps=" }, "lix-module": { "type": "Git", @@ -200,9 +200,9 @@ }, "branch": "main", "submodules": false, - "revision": "7c31a18259b8358ac196cf803a26967c0fa1d3e4", - "url": "https://git.lix.systems/lix-project/nixos-module/archive/7c31a18259b8358ac196cf803a26967c0fa1d3e4.tar.gz", - "hash": "sha256-n5dRAIC3/78drQtFxmQRrBLd6TKfotUnX7GWu0mAcSg=" + "revision": "c47f62187601ea2991b79a9bacdbfdf76cd29fbe", + "url": "https://git.lix.systems/lix-project/nixos-module/archive/c47f62187601ea2991b79a9bacdbfdf76cd29fbe.tar.gz", + "hash": "sha256-FvuAw56NIVJpS3Kr8Wv9PpU4eehZMcdIVkxjStuYmqc=" }, "lua-multipart": { "type": "GitRelease", @@ -245,9 +245,9 @@ }, "branch": "main", "submodules": false, - "revision": "6c6c42eaae3d095de6d1b47396c8b74ea57cb442", - "url": "https://github.com/nilla-nix/cli/archive/6c6c42eaae3d095de6d1b47396c8b74ea57cb442.tar.gz", - "hash": "sha256-0+d6LZfofBG+4OxnZcFaNg2ycgj1zcOJQUcPL1TEaSc=" + "revision": "aa042dbd9152c99e5a8db51bcf87306737423b9e", + "url": "https://github.com/nilla-nix/cli/archive/aa042dbd9152c99e5a8db51bcf87306737423b9e.tar.gz", + "hash": "sha256-cPdYYXhCsDllVgq+gs5Wqhb41bFtKWHlkTvjOJv7its=" }, "nilla-home": { "type": "GitRelease", @@ -287,9 +287,9 @@ }, "branch": "main", "submodules": false, - "revision": "f851a923137c0a54719412146fd63d24b3214e60", - "url": "https://github.com/sodiboo/niri-flake/archive/f851a923137c0a54719412146fd63d24b3214e60.tar.gz", - "hash": "sha256-E2ySTu/oK7cYBdAI3tlGP9zVjF4mZgWJ1OZInBCMb00=" + "revision": "20aadad64b8b8cbebc71371713c141d91d7f8172", + "url": "https://github.com/sodiboo/niri-flake/archive/20aadad64b8b8cbebc71371713c141d91d7f8172.tar.gz", + "hash": "sha256-zx7UxreMz646qikxw+So7eGRQeWccKFZxuMvJowJuFs=" }, "nix-index-database": { "type": "Git", @@ -300,9 +300,9 @@ }, "branch": "main", "submodules": false, - "revision": "5024e1901239a76b7bf94a4cd27f3507e639d49e", - "url": "https://github.com/nix-community/nix-index-database/archive/5024e1901239a76b7bf94a4cd27f3507e639d49e.tar.gz", - "hash": "sha256-xmU8kAsRprJiTGBTaGrwmjBP3AMA9ltlrxHKFuy5JWc=" + "revision": "359ff6333a7b0b60819d4c20ed05a3a1f726771f", + "url": "https://github.com/nix-community/nix-index-database/archive/359ff6333a7b0b60819d4c20ed05a3a1f726771f.tar.gz", + "hash": "sha256-Pu1v3mlFhRzZiSxVHb2/i/f5yeYyRNqr0RvEUJ4UgHo=" }, "nix-monitored": { "type": "Git", @@ -320,14 +320,14 @@ "nixos-unstable": { "type": "Channel", "name": "nixos-unstable", - "url": "https://releases.nixos.org/nixos/unstable/nixos-25.11pre880095.5e2a59a5b1a8/nixexprs.tar.xz", - "hash": "sha256-u0JUo46QSoXnjLaezAM75wRNuxVMVbm5OxHH122TeTY=" + "url": "https://releases.nixos.org/nixos/unstable/nixos-25.11pre888552.b3d51a0365f6/nixexprs.tar.xz", + "hash": "sha256-pCUTlk1qNASgSdrvMh02uYO4dERbDE9S0cYwa1PIPN8=" }, "nixpkgs": { "type": "Channel", "name": "nixos-25.05", - "url": "https://releases.nixos.org/nixos/25.05/nixos-25.05.811497.33c6dca0c0cb/nixexprs.tar.xz", - "hash": "sha256-Z7kbKnORypPkJ74r6sHA2RQH1XATHLWiGgZVrli0scY=" + "url": "https://releases.nixos.org/nixos/25.05/nixos-25.05.812378.ca534a76c4af/nixexprs.tar.xz", + "hash": "sha256-QO3VRw67TY1pCtXqhHu0eCplqe1EOq6f4A635euuEmk=" }, "npins": { "type": "Git", @@ -363,9 +363,9 @@ }, "branch": "master", "submodules": false, - "revision": "7d1888abf8c5b82692476a9de2137a024d484771", + "revision": "dd1bcee8c99bf799130645f32c94d1693f812f0d", "url": null, - "hash": "sha256-WD/UFUMcXMV/3tqD4h2tPaQH1KDlsJ00M+T4N/xkAGs=" + "hash": "sha256-1PGiDLrx1hNGNoUCnmc1Np2t48r7nIxxiTO8JHvaTws=" }, "treefmt-nix": { "type": "Git", @@ -376,9 +376,9 @@ }, "branch": "main", "submodules": false, - "revision": "f56b1934f5f8fcab8deb5d38d42fd692632b47c2", - "url": "https://github.com/numtide/treefmt-nix/archive/f56b1934f5f8fcab8deb5d38d42fd692632b47c2.tar.gz", - "hash": "sha256-ZRVs8UqikBa4Ki3X4KCnMBtBW0ux1DaT35tgsnB1jM4=" + "revision": "4ef3dfdbb5ddfb9e39999a2f2b0c2637277859d4", + "url": "https://github.com/numtide/treefmt-nix/archive/4ef3dfdbb5ddfb9e39999a2f2b0c2637277859d4.tar.gz", + "hash": "sha256-hOP4GxAmeXI43U1lIrKbWI2k35M1/T/i8iJrO9m/GzY=" }, "walker": { "type": "GitRelease", @@ -391,11 +391,11 @@ "version_upper_bound": null, "release_prefix": null, "submodules": false, - "version": "v2.5.5", - "revision": "ff292cb12c4816ce21dab47cd9894b8046b16a93", - "url": "https://api.github.com/repos/abenz1267/walker/tarball/refs/tags/v2.5.5", - "hash": "sha256-xc0yW9OhLTppjkaWWCWG9q4BVJZbhnLqLniLeMkcTvM=" + "version": "v2.9.2", + "revision": "dcd17c1150a16641e058cf58f30eaa6a78956db8", + "url": "https://api.github.com/repos/abenz1267/walker/tarball/refs/tags/v2.9.2", + "hash": "sha256-HElg/cm99rtBbLuJRUrrfQ4xJeUZJQgzyc+GORT08xI=" } }, - "version": 6 + "version": 7 } -- 2.43.0