From 567c248c4c336b176768b81fa4fddee1a399ef6a Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 12 Jun 2026 08:07:18 +0300 Subject: [PATCH] pins: upgrade to v8 Signed-off-by: NotAShelf Change-Id: I424803b1c97c4fbd4db6b2372b79581c6a6a6964 --- npins/default.nix | 49 ++++++++++++++++++++++++++++------------------ npins/sources.json | 3 ++- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/npins/default.nix b/npins/default.nix index 884fc8c..8ec5eca 100644 --- a/npins/default.nix +++ b/npins/default.nix @@ -65,7 +65,9 @@ let if pkgs == null then { inherit (builtins) fetchTarball fetchurl; - # For some fucking reason, fetchGit has a different signature than the other builtin fetchers … + # Frustratingly, due to flakes and `fetchTree`, `fetchGit` + # has a different signature than the other builtin + # fetchers fetchGit = args: (builtins.fetchGit args).outPath; } else @@ -95,7 +97,6 @@ let }; }; - # Dispatch to the correct code path based on the type path = if spec.type == "Git" then mkGitSource fetchers spec @@ -105,8 +106,8 @@ let mkPyPiSource fetchers spec else if spec.type == "Channel" then mkChannelSource fetchers spec - else if spec.type == "Tarball" then - mkTarballSource fetchers spec + else if spec.type == "Url" || spec.type == "MutableUrl" then + mkUrlSource fetchers spec else if spec.type == "Container" then mkContainerSource pkgs spec else @@ -192,16 +193,20 @@ let sha256 = hash; }; - mkTarballSource = - { fetchTarball, ... }: + mkUrlSource = { - url, - locked_url ? url, - hash, + fetchTarball, + fetchurl, ... }: - fetchTarball { - url = locked_url; + { + url, + hash, + unpack, + ... + }: + (if unpack then fetchTarball else fetchurl) { + inherit url; sha256 = hash; }; @@ -211,16 +216,22 @@ let image_name, image_tag, image_digest, + hash, ... - }: + }@args: 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; - }; + pkgs.dockerTools.pullImage ( + { + imageName = image_name; + imageDigest = image_digest; + finalImageTag = image_tag; + hash = hash; + } + // (if args.arch or null != null then { arch = args.arch; } else { }) + ); + in mkFunctor ( { @@ -231,7 +242,7 @@ mkFunctor ( 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* + # See: if builtins.pathExists input then builtins.fromJSON (builtins.readFile input) else @@ -242,7 +253,7 @@ mkFunctor ( throw "Unsupported input type ${builtins.typeOf input}, must be a path or an attrset"; version = data.version; in - if version == 7 then + if version == 8 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 9efc3b6..17bd20a 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -107,6 +107,7 @@ "nixpkgs": { "type": "Channel", "name": "nixpkgs-unstable", + "artifact": "nixexprs.tar.xz", "url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.11pre1006943.e9a7635a5759/nixexprs.tar.xz", "hash": "sha256-j1JL8PtaAVdH84cV+Scicmrck1tX0CM60F31md5C/MM=" }, @@ -159,5 +160,5 @@ "hash": "sha256-Amaz+83mSPue+pjZq/pJiCxu5QczYvmJk6f96eraaK8=" } }, - "version": 7 + "version": 8 }