about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/interpreters/janet/jpm.nix
blob: 050a035e066677bc0aa2a62de3b2a776d010c049 (plain) (blame)
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
51
52
53
54
55
56
57
58
59
{ lib, stdenv, fetchFromGitHub, janet }:

let
  platformFiles = {
    aarch64-darwin = "macos_config.janet";
    aarch64-linux = "linux_config.janet";
    x86_64-darwin = "macos_config.janet";
    x86_64-linux = "linux_config.janet";
  };

  platformFile = platformFiles.${stdenv.hostPlatform.system};

in
stdenv.mkDerivation rec {
  pname = "jpm";
  version = "1.1.0";

  src = fetchFromGitHub {
    owner = "janet-lang";
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-lPB4jew6RkJlDp8xOQ4YA9MkgLBImaBHcvv4WF/sLRc=";
  };

  # `auto-shebangs true` gives us a shebang line that points to janet inside the
  # jpm bin folder
  postPatch = ''
    substituteInPlace configs/${platformFile} \
      --replace 'auto-shebang true' 'auto-shebang false' \
      --replace /usr/local $out
  '';

  dontConfigure = true;

  buildInputs = [ janet ];

  dontBuild = true;

  installPhase = ''
    runHook preInstall

    mkdir -p $out/{lib/janet,share/man/man1}

    janet bootstrap.janet configs/${platformFile}

    runHook postInstall
  '';

  doInstallCheck = true;

  installCheckPhase = ''
    $out/bin/jpm help
  '';

  meta = janet.meta // {
    description = "Janet Project Manager for the Janet programming language";
    platforms = lib.attrNames platformFiles;
  };
}