2020-04-17 14:10:24 +01:00
|
|
|
{ stdenv, fetchFromGitHub, installShellFiles, makeWrapper, asciidoc
|
|
|
|
, docbook_xml_dtd_45, git, docbook_xsl, libxml2, libxslt, coreutils, gawk
|
2020-08-11 05:36:38 +01:00
|
|
|
, gnugrep, gnused, jq, nix, fetchpatch }:
|
2019-02-19 17:46:33 +00:00
|
|
|
|
2020-04-17 14:10:24 +01:00
|
|
|
let
|
|
|
|
binPath = stdenv.lib.makeBinPath [ coreutils gawk git gnugrep gnused jq nix ];
|
|
|
|
|
|
|
|
in stdenv.mkDerivation rec {
|
2019-02-19 17:46:33 +00:00
|
|
|
pname = "nix-prefetch";
|
2020-04-17 14:10:24 +01:00
|
|
|
version = "0.3.1";
|
2019-02-19 17:46:33 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "msteen";
|
|
|
|
repo = "nix-prefetch";
|
2020-01-16 09:17:00 +00:00
|
|
|
rev = version;
|
2020-04-17 14:10:24 +01:00
|
|
|
sha256 = "15h6f743nn6sdq8l771sjxh92cyzqznkcs7szrc7nm066xvx8rd4";
|
|
|
|
# the stat call has to be in a subshell or we get the current date
|
|
|
|
extraPostFetch = ''
|
|
|
|
echo $(stat -c %Y $out) > $out/.timestamp
|
|
|
|
'';
|
2019-02-19 17:46:33 +00:00
|
|
|
};
|
|
|
|
|
2020-08-11 05:36:38 +01:00
|
|
|
patches = [
|
2020-09-21 13:03:33 +01:00
|
|
|
# Fix compatibility with nixUnstable
|
|
|
|
# https://github.com/msteen/nix-prefetch/pull/9
|
2020-08-11 05:36:38 +01:00
|
|
|
(fetchpatch {
|
2020-09-21 13:03:33 +01:00
|
|
|
url = "https://github.com/msteen/nix-prefetch/commit/2722cda48ab3f4795105578599b29fc99518eff4.patch";
|
|
|
|
sha256 = "037m388sbl72kyqnk86mw7lhjhj9gzfglw3ri398ncfmmkq8b7r4";
|
|
|
|
})
|
|
|
|
# https://github.com/msteen/nix-prefetch/pull/12
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/msteen/nix-prefetch/commit/de96564e9f28df82bccd0584953094e7dbe87e20.patch";
|
|
|
|
sha256 = "0mxai6w8cfs7k8wfbsrpg5hwkyb0fj143nm0v142am0ky8ahn0d9";
|
2020-08-11 05:36:38 +01:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2020-04-17 14:10:24 +01: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
|
|
|
|
'';
|
|
|
|
|
2019-02-19 17:46:33 +00:00
|
|
|
nativeBuildInputs = [
|
2020-04-17 14:10:24 +01:00
|
|
|
asciidoc
|
|
|
|
docbook_xml_dtd_45
|
|
|
|
docbook_xsl
|
|
|
|
installShellFiles
|
|
|
|
libxml2
|
|
|
|
libxslt
|
2019-02-19 17:46:33 +00:00
|
|
|
makeWrapper
|
|
|
|
];
|
|
|
|
|
2020-04-17 14:10:24 +01:00
|
|
|
dontConfigure = true;
|
2019-02-19 17:46:33 +00:00
|
|
|
|
|
|
|
buildPhase = ''
|
2020-04-17 14:10:24 +01:00
|
|
|
a2x -a revdate=$(date --utc --date=@$(cat $src/.timestamp) +%d/%m/%Y) \
|
|
|
|
-f manpage doc/nix-prefetch.1.asciidoc
|
2019-02-19 17:46:33 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2020-04-17 14:10:24 +01:00
|
|
|
install -Dm555 -t $lib src/*.sh
|
|
|
|
install -Dm444 -t $lib lib/*
|
2019-02-19 17:46:33 +00:00
|
|
|
makeWrapper $lib/main.sh $out/bin/${pname} \
|
2020-04-17 14:10:24 +01:00
|
|
|
--prefix PATH : ${binPath}
|
2019-02-19 17:46:33 +00:00
|
|
|
|
2020-04-17 14:10:24 +01:00
|
|
|
installManPage doc/nix-prefetch.?
|
2019-02-19 17:46:33 +00:00
|
|
|
|
2020-04-17 14:10:24 +01:00
|
|
|
installShellCompletion --name ${pname} contrib/nix-prefetch-completion.{bash,zsh}
|
2019-02-19 17:46:33 +00:00
|
|
|
|
2020-01-16 09:17:00 +00:00
|
|
|
mkdir -p $out/share/doc/${pname}/contrib
|
2020-04-17 14:10:24 +01:00
|
|
|
cp -r contrib/hello_rs $out/share/doc/${pname}/contrib
|
2019-02-19 17:46:33 +00:00
|
|
|
'';
|
|
|
|
|
2020-01-16 09:17:00 +00:00
|
|
|
meta = with stdenv.lib; {
|
2019-02-19 17:46:33 +00:00
|
|
|
description = "Prefetch any fetcher function call, e.g. package sources";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ msteen ];
|
2020-04-17 14:10:24 +01:00
|
|
|
inherit (src.meta) homepage;
|
2019-02-19 17:46:33 +00:00
|
|
|
};
|
|
|
|
}
|