mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-22 05:33:23 +00:00
4a7f99d55d
Part of: https://github.com/NixOS/nixpkgs/issues/108938 meta = with stdenv.lib; is a widely used pattern. We want to slowly remove the `stdenv.lib` indirection and encourage people to use `lib` directly. Thus let’s start with the meta field. This used a rewriting script to mostly automatically replace all occurances of this pattern, and add the `lib` argument to the package header if it doesn’t exist yet. The script in its current form is available at https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
67 lines
1.9 KiB
Nix
67 lines
1.9 KiB
Nix
{lib, stdenv, fetchFromGitHub, git, mercurial, makeWrapper}:
|
|
|
|
stdenv.mkDerivation rec {
|
|
pname = "fast-export";
|
|
version = "200213";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "frej";
|
|
repo = pname;
|
|
rev = "v${version}";
|
|
sha256 = "0hzyh66rlawxip4n2pvz7pbs0cq82clqv1d6c7hf60v1drjxw287";
|
|
};
|
|
|
|
buildInputs = [mercurial.python mercurial makeWrapper];
|
|
|
|
installPhase = ''
|
|
binPath=$out/bin
|
|
libexecPath=$out/libexec/${pname}
|
|
sitepackagesPath=$out/${mercurial.python.sitePackages}
|
|
mkdir -p $binPath $libexecPath $sitepackagesPath
|
|
|
|
# Patch shell scripts so they can execute the Python scripts
|
|
sed -i "s|ROOT=.*|ROOT=$libexecPath|" *.sh
|
|
|
|
mv hg-fast-export.sh hg-reset.sh $binPath
|
|
mv hg-fast-export.py hg-reset.py $libexecPath
|
|
mv hg2git.py pluginloader plugins $sitepackagesPath
|
|
|
|
for script in $out/bin/*.sh; do
|
|
wrapProgram $script \
|
|
--prefix PATH : "${git}/bin":"${mercurial.python}/bin":$libexec \
|
|
--prefix PYTHONPATH : "${mercurial}/${mercurial.python.sitePackages}":$sitepackagesPath
|
|
done
|
|
'';
|
|
|
|
doInstallCheck = true;
|
|
# deliberately not adding git or hg into installCheckInputs - package should
|
|
# be able to work without them in runtime env
|
|
installCheckPhase = ''
|
|
mkdir repo-hg
|
|
pushd repo-hg
|
|
${mercurial}/bin/hg init
|
|
echo foo > bar
|
|
${mercurial}/bin/hg add bar
|
|
${mercurial}/bin/hg commit --message "baz"
|
|
popd
|
|
|
|
mkdir repo-git
|
|
pushd repo-git
|
|
${git}/bin/git init
|
|
${git}/bin/git config core.ignoreCase false # for darwin
|
|
$out/bin/hg-fast-export.sh -r ../repo-hg/ --hg-hash
|
|
for s in "foo" "bar" "baz" ; do
|
|
(${git}/bin/git show | grep $s > /dev/null) && echo $s found
|
|
done
|
|
popd
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "Import mercurial into git";
|
|
homepage = "https://repo.or.cz/w/fast-export.git";
|
|
license = licenses.gpl2;
|
|
maintainers = [ maintainers.koral ];
|
|
platforms = platforms.unix;
|
|
};
|
|
}
|