depot/third_party/nixpkgs/pkgs/tools/package-management/nix-prefetch/default.nix
Default email 0eaa97ffad Project import generated by Copybara.
GitOrigin-RevId: c59ea8b8a0e7f927e7291c14ea6cd1bd3a16ff38
2020-08-20 19:08:02 +02:00

82 lines
2.2 KiB
Nix

{ stdenv, fetchFromGitHub, installShellFiles, makeWrapper, asciidoc
, docbook_xml_dtd_45, git, docbook_xsl, libxml2, libxslt, coreutils, gawk
, gnugrep, gnused, jq, nix, fetchpatch }:
let
binPath = stdenv.lib.makeBinPath [ coreutils gawk git gnugrep gnused jq nix ];
in stdenv.mkDerivation rec {
pname = "nix-prefetch";
version = "0.3.1";
src = fetchFromGitHub {
owner = "msteen";
repo = "nix-prefetch";
rev = version;
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
'';
};
patches = [
# Fix compatibility with nixUnstable: https://github.com/msteen/nix-prefetch/pull/8
(fetchpatch {
url = "https://github.com/msteen/nix-prefetch/commit/817a7695d98663386fa27a6c04d1617e0a83e1ab.patch";
sha256 = "1zfgvafg30frwrh56k2wj4g76cljyjylm47ll60ms0yfx55spa7x";
})
];
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} \
--prefix PATH : ${binPath}
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
'';
meta = with stdenv.lib; {
description = "Prefetch any fetcher function call, e.g. package sources";
license = licenses.mit;
maintainers = with maintainers; [ msteen ];
inherit (src.meta) homepage;
};
}