about summary refs log tree commit diff
path: root/pkgs/development/interpreters/janet
diff options
context:
space:
mode:
authorPeter Hoeg <peter@hoeg.com>2022-02-03 13:56:17 +0800
committerPeter Hoeg <peter@hoeg.com>2022-02-11 15:43:49 +0800
commit74340842783beb0e0aff491680e77afe24f47d71 (patch)
treed89fb675255932d9e706ffb543426644d7b5a6e1 /pkgs/development/interpreters/janet
parent58f134bc3777e3bac94aee058add2f17bed6111b (diff)
jpm: init at 0.0.2
Diffstat (limited to 'pkgs/development/interpreters/janet')
-rw-r--r--pkgs/development/interpreters/janet/jpm.nix59
1 files changed, 59 insertions, 0 deletions
diff --git a/pkgs/development/interpreters/janet/jpm.nix b/pkgs/development/interpreters/janet/jpm.nix
new file mode 100644
index 0000000000000..7089308512554
--- /dev/null
+++ b/pkgs/development/interpreters/janet/jpm.nix
@@ -0,0 +1,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 = "0.0.2";
+
+  src = fetchFromGitHub {
+    owner = "janet-lang";
+    repo = pname;
+    rev = version;
+    sha256 = "sha256-nv+vkDjEY711L+C5ibw48DUSNqq2UJiFC2i5LntuBNM=";
+  };
+
+  # `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;
+  };
+}