!jngDrdMgndWibPCYsR:nixos.org

Nix PHP

76 Members
A room for PHP developers running on Nix22 Servers

Load older messages


SenderMessageTime
17 May 2023
@drupol:matrix.orgPolIt is doing what we want to do13:44:27
@drupol:matrix.orgPolIt builds a local packagist repo 13:44:38
@drupol:matrix.orgPolThis is basically what the python script is doing13:44:53
@Zevran:matrix.orgGaël Reyroltrue13:46:05
@drupol:matrix.orgPolRedacted or Malformed Event14:07:14
@drupol:matrix.orgPolRedacted or Malformed Event14:07:16
@jtojnar:matrix.orgJan Tojnar
In reply to @Zevran:matrix.org
For now I edited the composer-setup-hook.sh but I get an error at the execution of the script nix-repl> :b pkgs.phpPackages.psalm error: builder for '/nix/store/953mghp1rkxh37m7rka61pfxglijq53f-composer-2.5.5-composer-cache.drv' failed with exit code 127; last 3 log lines: > /nix/store/qxn0wmvji49mawyyr0p7hq2gch965454-composer-create-repository-python: line 2: from: command not found > /nix/store/mciym69qni8j8rzdndkcqjgh8apk8sxw-stdenv-linux/setup: line 703: pop_var_context: head of shell_variables not a function context > /nix/store/mciym69qni8j8rzdndkcqjgh8apk8sxw-stdenv-linux/setup: line 710: pop_var_context: head of shell_variables not a function context For full logs, run 'nix log /nix/store/953mghp1rkxh37m7rka61pfxglijq53f-composer-2.5.5-composer-cache.drv'.

I was thinking something like

diff --git a/pkgs/build-support/php/hooks/composer-setup-hook.sh b/pkgs/build-support/php/hooks/composer-setup-hook.sh
index f74ee293b7c..2e59d341e0d 100644
--- a/pkgs/build-support/php/hooks/composer-setup-hook.sh
+++ b/pkgs/build-support/php/hooks/composer-setup-hook.sh
@@ -62,7 +62,7 @@ composerSetupBuildHook() {
     COMPOSER_CACHE_DIR=".composer" \
     COMPOSER_HTACCESS_PROTECT=0 \
     COMPOSER_ROOT_VERSION="${version}" \
-    composer install ${argstr[@]}
+    @python@ @composerCreateRepo@ composer.lock "$out"
 
     echo "Finished composerSetupBuildHook"
 }
diff --git a/pkgs/build-support/php/hooks/default.nix b/pkgs/build-support/php/hooks/default.nix
index a3be5e80f61..5d1d4a55d81 100644
--- a/pkgs/build-support/php/hooks/default.nix
+++ b/pkgs/build-support/php/hooks/default.nix
@@ -8,6 +8,7 @@
 , unzip
 , xz
 , git
+, python311
 }:
 
 {
@@ -15,6 +16,8 @@
       name = "composer-setup-hook.sh";
       propagatedBuildInputs = [ php unzip xz git jq ];
       substitutions = {
+        python = python311;
+        composerCreateRepo = ./composer-create-repository.py;
       };
     } ./composer-setup-hook.sh;
 
14:13:19
@jtojnar:matrix.orgJan Tojnar
In reply to @Zevran:matrix.org
For now I edited the composer-setup-hook.sh but I get an error at the execution of the script nix-repl> :b pkgs.phpPackages.psalm error: builder for '/nix/store/953mghp1rkxh37m7rka61pfxglijq53f-composer-2.5.5-composer-cache.drv' failed with exit code 127; last 3 log lines: > /nix/store/qxn0wmvji49mawyyr0p7hq2gch965454-composer-create-repository-python: line 2: from: command not found > /nix/store/mciym69qni8j8rzdndkcqjgh8apk8sxw-stdenv-linux/setup: line 703: pop_var_context: head of shell_variables not a function context > /nix/store/mciym69qni8j8rzdndkcqjgh8apk8sxw-stdenv-linux/setup: line 710: pop_var_context: head of shell_variables not a function context For full logs, run 'nix log /nix/store/953mghp1rkxh37m7rka61pfxglijq53f-composer-2.5.5-composer-cache.drv'.
*

I was thinking something like

diff --git a/pkgs/build-support/php/hooks/composer-setup-hook.sh b/pkgs/build-support/php/hooks/composer-setup-hook.sh
index f74ee293b7c..2e59d341e0d 100644
--- a/pkgs/build-support/php/hooks/composer-setup-hook.sh
+++ b/pkgs/build-support/php/hooks/composer-setup-hook.sh
@@ -62,7 +62,7 @@ composerSetupBuildHook() {
     COMPOSER_CACHE_DIR=".composer" \
     COMPOSER_HTACCESS_PROTECT=0 \
     COMPOSER_ROOT_VERSION="${version}" \
-    composer install ${argstr[@]}
+    @python@ @composerCreateRepo@ composer.lock "$out"
 
     echo "Finished composerSetupBuildHook"
 }
diff --git a/pkgs/build-support/php/hooks/default.nix b/pkgs/build-support/php/hooks/default.nix
index a3be5e80f61..5d1d4a55d81 100644
--- a/pkgs/build-support/php/hooks/default.nix
+++ b/pkgs/build-support/php/hooks/default.nix
@@ -8,6 +8,7 @@
 , unzip
 , xz
 , git
+, python311
 }:
 
 {
@@ -15,6 +16,8 @@
       name = "composer-setup-hook.sh";
       propagatedBuildInputs = [ php unzip xz git jq ];
       substitutions = {
+        python = python311.interpreter;
+        composerCreateRepo = ./composer-create-repository.py;
       };
     } ./composer-setup-hook.sh;
 
14:13:47
@jtojnar:matrix.orgJan Tojnarsince there are no third party dependencies14:14:56
@Zevran:matrix.orgGaël ReyrolOh I see, I like that fact that I can use it as an extra package, to run it and maybe test it independently 14:17:38
@jtojnar:matrix.orgJan Tojnar yeah, separate derivation is definitely nicer, ideally it would also have passthru.tests with mypy & black 14:20:56
@Zevran:matrix.orgGaël ReyrolWell I am still stuck on the error with the hook executing the script from bash instead of python ... 14:33:32
@Zevran:matrix.orgGaël Reyrolhttps://github.com/gaelreyrol/nixpkgs/commit/d80b5eccf7191768fa18c2e917d3fba984f1aab114:33:33
@jtojnar:matrix.orgJan Tojnar
In reply to @Zevran:matrix.org
https://github.com/gaelreyrol/nixpkgs/commit/d80b5eccf7191768fa18c2e917d3fba984f1aab1
well, you are using writeScript without a shebang
14:50:59
@jtojnar:matrix.orgJan Tojnar you need writeShellScript 14:51:08
@Zevran:matrix.orgGaël Reyrol Mhhh I am using composerCreateRepositoryPythonScript not composerCreatreRepositoryScript 14:56:28
@jtojnar:matrix.orgJan Tojnar Gaël Reyrol: also you need to put the script into /bin/ otherwise stdenv will think it is a setup hook and try to run it or something 14:56:33
@jtojnar:matrix.orgJan Tojnarbut it is probably better to use substitutions rather than propagation anyway14:57:59
@jtojnar:matrix.orgJan Tojnarsince propagation will pollute the closure of dependents14:58:21
@jtojnar:matrix.orgJan Tojnar

Something like this:

diff --git a/pkgs/build-support/php/hooks/composer-setup-hook.sh b/pkgs/build-support/php/hooks/composer-setup-hook.sh
index 90e51c3659a..1bbc0991f3f 100644
--- a/pkgs/build-support/php/hooks/composer-setup-hook.sh
+++ b/pkgs/build-support/php/hooks/composer-setup-hook.sh
@@ -44,6 +44,8 @@ composerSetupConfigureHook() {
 
 composerSetupBuildHook() {
     echo "Executing composerSetupBuildHook"
+    PATH_original="$PATH"
+    export PATH="@path@"
 
     # argstr=("--no-interaction" "--download-only")
 
@@ -73,6 +75,7 @@ composerSetupBuildHook() {
     composer-create-repository-python ${argstr[@]}
 
     echo "Finished composerSetupBuildHook"
+    export PATH="$PATH_original"
 }
 
 composerSetupInstallHook() {
diff --git a/pkgs/build-support/php/hooks/default.nix b/pkgs/build-support/php/hooks/default.nix
index 5f51c77b75a..02fa8ca3421 100644
--- a/pkgs/build-support/php/hooks/default.nix
+++ b/pkgs/build-support/php/hooks/default.nix
@@ -12,7 +12,7 @@
 
 let
   # Can be call with composer-create-repository-python [-h] [--include-dev] lockfile_path output_path
-  composerCreateRepositoryPythonScript = writers.makePythonWriter python311 python3Packages buildPackages.python3Packages "composer-create-repository-python" {
+  composerCreateRepositoryPythonScript = writers.makePythonWriter python311 python3Packages buildPackages.python3Packages "/bin/composer-create-repository-python" {
     flakeIgnore = ["E501"];
   } ./composer-create-repository.py;
 
@@ -24,7 +24,16 @@ in
 {
   composerSetupHook = makeSetupHook {
       name = "composer-setup-hook.sh";
-      propagatedBuildInputs = [ php unzip xz git jq composerCreateRepositoryPythonScript ];
+      substitutions = {
+        path = lib.makeBinPath [
+          php
+          unzip
+          xz
+          git
+          jq
+          composerCreateRepositoryPythonScript
+        ];
+      }
     } ./composer-setup-hook.sh;
 
   composerInstallHook = makeSetupHook {
15:05:14
@Zevran:matrix.orgGaël ReyrolLike this? https://github.com/gaelreyrol/nixpkgs/commit/350cb0132980494f4bc174db4f0e6f3f5bdc23f315:22:51
@Zevran:matrix.orgGaël Reyrol It seems to work but then I get an SSL error while the script execute git fetch origin $rev : atal: unable to access 'https://github.com/composer/ca-bundle.git/': OpenSSL/3.0.8: error:16000069:STORE routines::unregistered scheme 15:25:09
@Zevran:matrix.orgGaël Reyrol I think I need pkgs.cacert 😅 15:28:23
@Zevran:matrix.orgGaël ReyrolYep :P15:29:56
@drupol:matrix.orgPolAllright15:30:02
@drupol:matrix.orgPolI stand here: https://github.com/NixOS/nixpkgs/pull/23245015:30:08
@drupol:matrix.orgPolI'm looking for a bit of help15:30:14
@drupol:matrix.orgPolThe composer plugin is hooked in, 15:30:19
@drupol:matrix.orgPolI just can't use it's output for some unknown Nix reasons15:30:30
@drupol:matrix.orgPol When I try to do ls -la ${composerVendorCache}, it breaks 15:30:49

Show newer messages


Back to Room ListRoom Version: 6