btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / development / interpreters / janet / jpm.nix
blob31ed1e2fc1ff50787fb5c7b47bc87e77866e9040
1 { lib, stdenv, fetchFromGitHub, janet }:
3 let
4   platformFiles = {
5     aarch64-darwin = "macos_config.janet";
6     aarch64-linux = "linux_config.janet";
7     x86_64-darwin = "macos_config.janet";
8     x86_64-linux = "linux_config.janet";
9   };
11   platformFile = platformFiles.${stdenv.hostPlatform.system};
14 stdenv.mkDerivation rec {
15   pname = "jpm";
16   version = "1.1.0";
18   src = fetchFromGitHub {
19     owner = "janet-lang";
20     repo = pname;
21     rev = "v${version}";
22     sha256 = "sha256-lPB4jew6RkJlDp8xOQ4YA9MkgLBImaBHcvv4WF/sLRc=";
23   };
25   # `auto-shebangs true` gives us a shebang line that points to janet inside the
26   # jpm bin folder
27   postPatch = ''
28     substituteInPlace configs/${platformFile} \
29       --replace 'auto-shebang true' 'auto-shebang false' \
30       --replace /usr/local $out
31   '';
33   dontConfigure = true;
35   buildInputs = [ janet ];
37   dontBuild = true;
39   installPhase = ''
40     runHook preInstall
42     mkdir -p $out/{lib/janet,share/man/man1}
44     janet bootstrap.janet configs/${platformFile}
46     runHook postInstall
47   '';
49   doInstallCheck = true;
51   installCheckPhase = ''
52     $out/bin/jpm help
53   '';
55   meta = janet.meta // {
56     description = "Janet Project Manager for the Janet programming language";
57     mainProgram = "jpm";
58     platforms = lib.attrNames platformFiles;
59   };