nixpkgs/pkgs/tools/package-management/nix-prefetch/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

73 lines
1.9 KiB
Nix
Raw Normal View History

{ lib, stdenv, fetchFromGitHub, installShellFiles, makeWrapper, asciidoc
, docbook_xml_dtd_45, git, docbook_xsl, libxml2, libxslt, coreutils, gawk
2021-07-17 23:28:02 +01:00
, gnugrep, gnused, jq, nix }:
2019-02-19 17:46:33 +00:00
2021-07-20 12:22:52 +01:00
stdenv.mkDerivation rec {
2019-02-19 17:46:33 +00:00
pname = "nix-prefetch";
2021-07-17 23:28:02 +01:00
version = "0.4.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;
2021-07-17 23:28:02 +01:00
sha256 = "0bwv6x651gyq703pywrhb7lfby6xwnd1iwnrzzjihipn7x3v2hz9";
# the stat call has to be in a subshell or we get the current date
2022-05-17 20:10:33 +01:00
postFetch = ''
echo $(stat -c %Y $out) > $out/.timestamp
'';
2019-02-19 17:46:33 +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
'';
2019-02-19 17:46:33 +00:00
nativeBuildInputs = [
asciidoc
docbook_xml_dtd_45
docbook_xsl
installShellFiles
libxml2
libxslt
2019-02-19 17:46:33 +00:00
makeWrapper
];
dontConfigure = true;
2019-02-19 17:46:33 +00:00
buildPhase = ''
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 = ''
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} \
2021-07-20 12:22:52 +01:00
--prefix PATH : ${lib.makeBinPath [ coreutils gawk git gnugrep gnused jq nix ]}
2019-02-19 17:46:33 +00:00
installManPage doc/nix-prefetch.?
2019-02-19 17:46:33 +00: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
cp -r contrib/hello_rs $out/share/doc/${pname}/contrib
2019-02-19 17:46:33 +00:00
'';
meta = with 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 ];
2021-07-20 12:22:52 +01:00
homepage = "https://github.com/msteen/nix-prefetch";
2021-07-17 23:28:02 +01:00
platforms = platforms.all;
2019-02-19 17:46:33 +00:00
};
}