summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ni/nix-script/package.nix
blob: 5e1e472bea72cc9dcb88840dcd8f02df7cffa99a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{
  lib,
  stdenv,
  haskellPackages,
  fetchFromGitHub,
}:

stdenv.mkDerivation {
  pname = "nix-script";
  version = "2020-03-23";

  src = fetchFromGitHub {
    owner = "bennofs";
    repo = "nix-script";
    rev = "7706b45429ff22c35bab575734feb2926bf8840b";
    sha256 = "0yiqljamcj9x8z801bwj7r30sskrwv4rm6sdf39j83jqql1fyq7y";
  };

  strictDeps = true;
  nativeBuildInputs = [
    (haskellPackages.ghcWithPackages (hs: with hs; [ posix-escape ]))
  ];

  buildPhase = ''
    runHook preBuild

    mkdir -p $out/bin
    ghc -O2 $src/nix-script.hs -o $out/bin/nix-script -odir . -hidir .

    runHook postBuild
  '';
  installPhase = ''
    runHook preInstall

    ln -s $out/bin/nix-script $out/bin/nix-scripti

    runHook postInstall
  '';

  meta = {
    description = "Shebang for running inside nix-shell";
    homepage = "https://github.com/bennofs/nix-script";
    license = lib.licenses.bsd3;
    maintainers = with lib.maintainers; [
      bennofs
      rnhmjoj
    ];
    platforms = haskellPackages.ghc.meta.platforms;
  };
}