From 99760bac33a120d4a7a07f43ea206c1edd2a665c Mon Sep 17 00:00:00 2001 From: Tom Herbers Date: Sat, 22 Mar 2025 20:39:06 +0100 Subject: [PATCH] npins: simplify src tracking Until now the npins src has been managed via a mechanism similar to how npins would do it itself. This hoewer complicates bumping and maintenance. Therefore dropping that and switching to fetchFromGitHub. --- pkgs/by-name/np/npins/package.nix | 15 +++--- pkgs/by-name/np/npins/source.nix | 76 ------------------------------ pkgs/by-name/np/npins/sources.json | 21 --------- 3 files changed, 9 insertions(+), 103 deletions(-) delete mode 100644 pkgs/by-name/np/npins/source.nix delete mode 100644 pkgs/by-name/np/npins/sources.json diff --git a/pkgs/by-name/np/npins/package.nix b/pkgs/by-name/np/npins/package.nix index dea276b1af31..4b9269f11d14 100644 --- a/pkgs/by-name/np/npins/package.nix +++ b/pkgs/by-name/np/npins/package.nix @@ -1,10 +1,10 @@ { lib, rustPlatform, + fetchFromGitHub, makeWrapper, stdenv, darwin, - callPackage, # runtime dependencies nix, # for nix-prefetch-url @@ -18,12 +18,17 @@ let nix-prefetch-git git ]; - sources = (lib.importJSON ./sources.json).pins; in rustPlatform.buildRustPackage rec { pname = "npins"; - version = src.version; - src = passthru.mkSource sources.npins; + version = "0.3.0"; + + src = fetchFromGitHub { + owner = "andir"; + repo = "npins"; + tag = version; + sha256 = "sha256-nTm6IqCHNFQLU7WR7dJRP7ktBctpE/O2LHbUV25roJA="; + }; useFetchCargoVendor = true; cargoHash = "sha256-HnX7dkWLxa3DARXG8y9OVBRwvwgxwRIs4mWK3VNblG0="; @@ -51,6 +56,4 @@ rustPlatform.buildRustPackage rec { license = licenses.eupl12; maintainers = with maintainers; [ piegames ]; }; - - passthru.mkSource = callPackage ./source.nix { }; } diff --git a/pkgs/by-name/np/npins/source.nix b/pkgs/by-name/np/npins/source.nix deleted file mode 100644 index d7f08ede9c8f..000000000000 --- a/pkgs/by-name/np/npins/source.nix +++ /dev/null @@ -1,76 +0,0 @@ -# Not part of the public API – for use within nixpkgs only -# -# Usage: -# ```nix -# let -# sources = lib.importJSON ./sources.json; -# in mkMyDerivation rec { -# version = src.version; # This obviously only works for releases -# src = pkgs.npins.mkSource sources.mySource; -# } -# ``` - -{ - fetchgit, - fetchzip, - fetchurl, -}: -let - 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 - throw "Unknown source type ${spec.type}"; - in - spec // { outPath = path; }; - - mkGitSource = - { - repository, - revision, - url ? null, - hash, - ... - }: - 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 - (fetchzip { - inherit url; - sha256 = hash; - extension = "tar"; - }) - else - assert repository.type == "Git"; - fetchgit { - url = repository.url; - rev = revision; - }; - - mkPyPiSource = - { url, hash, ... }: - fetchurl { - inherit url; - sha256 = hash; - }; - - mkChannelSource = - { url, hash, ... }: - fetchzip { - inherit url; - sha256 = hash; - extension = "tar"; - }; -in -mkSource diff --git a/pkgs/by-name/np/npins/sources.json b/pkgs/by-name/np/npins/sources.json deleted file mode 100644 index 20fa6f622f80..000000000000 --- a/pkgs/by-name/np/npins/sources.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "pins": { - "npins": { - "type": "GitRelease", - "repository": { - "type": "GitHub", - "owner": "andir", - "repo": "npins" - }, - "pre_releases": false, - "version_upper_bound": null, - "release_prefix": null, - "submodules": false, - "version": "0.3.0", - "revision": "6cc1930e703698487bd703258126435a536ca492", - "url": "https://api.github.com/repos/andir/npins/tarball/0.3.0", - "hash": "1450ddp5gm3n5jvg64v9rc2jvf9za79fv4dmac5m8d47l0iblfcx" - } - }, - "version": 5 -}