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.
This commit is contained in:
@@ -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 { };
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user