about summary refs log tree commit diff
path: root/pkgs/development/php-packages
diff options
context:
space:
mode:
authorElis Hirwing <elis@hirwing.se>2023-09-17 20:43:27 +0200
committerElis Hirwing <elis@hirwing.se>2023-09-24 18:26:04 +0200
commit2ed6ebe0f993bcb11af6ea1768a2ccc6fc6fada5 (patch)
treedbdb5478e0daf5ca4ef6e48e09336cf2a2a086a9 /pkgs/development/php-packages
parent60c81d33d786d2a23c9eb3f353551f6973170248 (diff)
downloadnixlib-2ed6ebe0f993bcb11af6ea1768a2ccc6fc6fada5.tar
nixlib-2ed6ebe0f993bcb11af6ea1768a2ccc6fc6fada5.tar.gz
nixlib-2ed6ebe0f993bcb11af6ea1768a2ccc6fc6fada5.tar.bz2
nixlib-2ed6ebe0f993bcb11af6ea1768a2ccc6fc6fada5.tar.lz
nixlib-2ed6ebe0f993bcb11af6ea1768a2ccc6fc6fada5.tar.xz
nixlib-2ed6ebe0f993bcb11af6ea1768a2ccc6fc6fada5.tar.zst
nixlib-2ed6ebe0f993bcb11af6ea1768a2ccc6fc6fada5.zip
php.packages.castor: Build from source
Diffstat (limited to 'pkgs/development/php-packages')
-rw-r--r--pkgs/development/php-packages/castor/default.nix52
1 files changed, 21 insertions, 31 deletions
diff --git a/pkgs/development/php-packages/castor/default.nix b/pkgs/development/php-packages/castor/default.nix
index ed6ce2ba33f4..b2bf7da5c2c7 100644
--- a/pkgs/development/php-packages/castor/default.nix
+++ b/pkgs/development/php-packages/castor/default.nix
@@ -1,60 +1,50 @@
 { lib
-, stdenv
-, fetchurl
-, makeBinaryWrapper
+, fetchFromGitHub
 , installShellFiles
 , php
 , nix-update-script
 , testers
-, castor
 }:
 
-stdenv.mkDerivation (finalAttrs: {
+php.buildComposerProject (finalAttrs: {
   pname = "castor";
   version = "0.8.0";
 
-
-  src = fetchurl {
-    url = "https://github.com/jolicode/castor/releases/download/v${finalAttrs.version}/castor.linux-amd64.phar";
-    hash = "sha256-0lnn4mS1/DgUoRoMFvCjwQ0j9CX9XWlskbtX9roFCfc=";
+  src = fetchFromGitHub {
+    owner = "jolicode";
+    repo = "castor";
+    rev = "v${finalAttrs.version}";
+    hash = "sha256-rJz4BY74BI8gyT4ZlABc4PA+SCsd8guM0m2MTej350g=";
   };
 
-  dontUnpack = true;
-
-  nativeBuildInputs = [ makeBinaryWrapper installShellFiles ];
+  vendorHash = "sha256-Jh4mNNYEM9sy0Dp+dZtD+xrMICjAuspe9D9BDXcfUPM=";
 
-  installPhase = ''
-    runHook preInstall
-    mkdir -p $out/bin
-    install -D $src $out/libexec/castor/castor.phar
-    makeWrapper ${php}/bin/php $out/bin/castor \
-      --add-flags "$out/libexec/castor/castor.phar"
-    runHook postInstall
-  '';
+  nativeBuildInputs = [ installShellFiles ];
 
-  # castor requires to be initialized to generate completion files
+  # install shell completions
   postInstall = ''
-    echo "yes" | ${php}/bin/php $src
+    echo "yes" | ${php}/bin/php $out/share/php/castor/bin/castor
     installShellCompletion --cmd castor \
-      --bash <($out/bin/castor completion bash) \
-      --fish <($out/bin/castor completion fish) \
-      --zsh <($out/bin/castor completion zsh)
+      --bash <(${php}/bin/php $out/share/php/castor/bin/castor completion bash) \
+      --fish <(${php}/bin/php $out/share/php/castor/bin/castor completion fish) \
+      --zsh <(${php}/bin/php $out/share/php/castor/bin/castor completion zsh)
   '';
 
   passthru = {
     updateScript = nix-update-script { };
     tests.version = testers.testVersion {
-      inherit (finalAttrs) version;
-      package = castor;
       command = "castor --version";
+      package = php.packages.castor;
+      version = "v${finalAttrs.version}";
     };
   };
 
-  meta = with lib; {
+  meta = {
+    changelog = "https://github.com/jolicode/castor/blob/v${finalAttrs.version}/CHANGELOG.md";
     description = "DX oriented task runner and command launcher built with PHP";
     homepage = "https://github.com/jolicode/castor";
-    changelog = "https://github.com/jolicode/castor/blob/v${finalAttrs.version}/CHANGELOG.md";
-    license = licenses.mit;
-    maintainers = with maintainers; [ gaelreyrol ];
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ gaelreyrol ];
+    mainProgram = "castor";
   };
 })