nixpkgs/pkgs/tools/package-management/nix-pin/default.nix
Jörg Thalheim dadc7eb329
treewide: use runtimeShell instead of stdenv.shell whenever possible
Whenever we create scripts that are installed to $out, we must use runtimeShell
in order to get the shell that can be executed on the machine we create the
package for. This is relevant for cross-compiling. The only use case for
stdenv.shell are scripts that are executed as part of the build system.
Usages in checkPhase are borderline however to decrease the likelyhood
of people copying the wrong examples, I decided to use runtimeShell as well.
2019-02-26 14:10:49 +00:00

53 lines
1.6 KiB
Nix

{ lib, pkgs, stdenv, fetchFromGitHub, mypy, python3, nix, git, makeWrapper
, runtimeShell }:
let self = stdenv.mkDerivation rec {
name = "nix-pin-${version}";
version = "0.4.0";
src = fetchFromGitHub {
owner = "timbertson";
repo = "nix-pin";
rev = "version-${version}";
sha256 = "1pccvc0iqapms7kidrh09g5fdx44x622r5l9k7bkmssp3v4c68vy";
};
buildInputs = [ python3 mypy makeWrapper ];
checkPhase = ''
mypy bin/*
'';
installPhase = ''
mkdir "$out"
cp -r bin share "$out"
wrapProgram $out/bin/nix-pin \
--prefix PATH : "${lib.makeBinPath [ nix git ]}"
'';
passthru =
let
defaults = import "${self}/share/nix/defaults.nix";
in {
api = { pinConfig ? defaults.pinConfig }:
let impl = import "${self}/share/nix/api.nix" { inherit pkgs pinConfig; }; in
{ inherit (impl) augmentedPkgs pins callPackage; };
updateScript = ''
#!${runtimeShell}
set -e
echo
cd ${toString ./.}
${pkgs.nix-update-source}/bin/nix-update-source \
--prompt version \
--replace-attr version \
--set owner timbertson \
--set repo nix-pin \
--set type fetchFromGitHub \
--set rev 'version-{version}' \
--substitute rev 'version-''${{version}}' \
--modify-nix default.nix
'';
};
meta = with stdenv.lib; {
homepage = "https://github.com/timbertson/nix-pin";
description = "nixpkgs development utility";
license = licenses.mit;
maintainers = [ maintainers.timbertson ];
platforms = platforms.all;
};
}; in self