2022-09-11 15:47:08 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch, installShellFiles, makeWrapper, asciidoc
|
2020-04-24 23:36:52 +00:00
|
|
|
, docbook_xml_dtd_45, git, docbook_xsl, libxml2, libxslt, coreutils, gawk
|
2021-07-21 07:28:18 +00:00
|
|
|
, gnugrep, gnused, jq, nix }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-07-21 07:28:18 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "nix-prefetch";
|
2021-07-21 07:28:18 +00:00
|
|
|
version = "0.4.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "msteen";
|
|
|
|
repo = "nix-prefetch";
|
|
|
|
rev = version;
|
2021-07-21 07:28:18 +00:00
|
|
|
sha256 = "0bwv6x651gyq703pywrhb7lfby6xwnd1iwnrzzjihipn7x3v2hz9";
|
2020-04-24 23:36:52 +00:00
|
|
|
# the stat call has to be in a subshell or we get the current date
|
2022-06-16 17:23:12 +00:00
|
|
|
postFetch = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
echo $(stat -c %Y $out) > $out/.timestamp
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-09-11 15:47:08 +00:00
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fix-prefetching-hash-key.patch";
|
2022-09-14 18:05:37 +00:00
|
|
|
url = "https://github.com/msteen/nix-prefetch/commit/508237f48f7e2d8496ce54f38abbe57f44d0cbca.patch";
|
|
|
|
hash = "sha256-9SYPcRFZaVyNjMUVdXbef5eGvLp/kr379eU9lG5GgE0=";
|
2022-09-11 15:47:08 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
postPatch = ''
|
|
|
|
lib=$out/lib/${pname}
|
|
|
|
|
|
|
|
substituteInPlace doc/nix-prefetch.1.asciidoc \
|
|
|
|
--subst-var-by version $version
|
|
|
|
|
|
|
|
substituteInPlace src/main.sh \
|
|
|
|
--subst-var-by lib $lib \
|
|
|
|
--subst-var-by version $version
|
|
|
|
|
|
|
|
substituteInPlace src/tests.sh \
|
|
|
|
--subst-var-by bin $out/bin
|
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
asciidoc
|
|
|
|
docbook_xml_dtd_45
|
|
|
|
docbook_xsl
|
|
|
|
installShellFiles
|
|
|
|
libxml2
|
|
|
|
libxslt
|
|
|
|
makeWrapper
|
|
|
|
];
|
|
|
|
|
|
|
|
dontConfigure = true;
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
a2x -a revdate=$(date --utc --date=@$(cat $src/.timestamp) +%d/%m/%Y) \
|
|
|
|
-f manpage doc/nix-prefetch.1.asciidoc
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
install -Dm555 -t $lib src/*.sh
|
|
|
|
install -Dm444 -t $lib lib/*
|
|
|
|
makeWrapper $lib/main.sh $out/bin/${pname} \
|
2021-07-21 07:28:18 +00:00
|
|
|
--prefix PATH : ${lib.makeBinPath [ coreutils gawk git gnugrep gnused jq nix ]}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
installManPage doc/nix-prefetch.?
|
|
|
|
|
|
|
|
installShellCompletion --name ${pname} contrib/nix-prefetch-completion.{bash,zsh}
|
|
|
|
|
|
|
|
mkdir -p $out/share/doc/${pname}/contrib
|
|
|
|
cp -r contrib/hello_rs $out/share/doc/${pname}/contrib
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Prefetch any fetcher function call, e.g. package sources";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ msteen ];
|
2021-07-21 07:28:18 +00:00
|
|
|
homepage = "https://github.com/msteen/nix-prefetch";
|
|
|
|
platforms = platforms.all;
|
2024-01-02 11:29:13 +00:00
|
|
|
mainProgram = "nix-prefetch";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|