!jngDrdMgndWibPCYsR:nixos.org

Nix PHP

76 Members
A room for PHP developers running on Nix22 Servers

Load older messages


SenderMessageTime
29 Mar 2023
@drupol:matrix.orgPol *

Hey PHPers,
I checked how a Rust package is packaged in NixOS.
Rust packages are similar to PHP, it contains Cargo files. One of those two files is Cargo.lock which is used to lock the dependencies, just like composer.lock.
Look how easy it is to package a Rust app: https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/typesetting/typst/default.nix

Do you think we can do something similar but for PHP ?

This is the file handling the import of the Cargo.lock: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/rust/import-cargo-lock.nix

07:23:31
@philipp:xndr.dephilipphttps://github.com/NixOS/nixpkgs/blob/nixos-22.11/pkgs/tools/networking/rustcat/default.nix This is an example of usage of this, right? What I really don't like about this method is that it completely hides all dependencies from the rest of the system.07:32:25
@ma27:nicht-so.sexyma27 AFAIU Pol was specifically talking about the approach where you import the Cargo.lock rather than using a FOD and this method doesn't have this flaw, correct? 07:35:28
@philipp:xndr.dephilippOh, that would be cool.07:35:51
@philipp:xndr.dephilippIs there an example of it's usage in nixpkgs somewhere?07:37:59
@ma27:nicht-so.sexyma27 Regarding the original question: without having taken a close look I think that this should be possible and I'd really like it (especially because I could get rid of at least one occurrence of composer2nix in my employer's deployment I guess). 07:38:43
@ma27:nicht-so.sexyma27in other words, congrats you got the job :P07:38:50
@philipp:xndr.dephilippYeah, if it works like that, I'd delighted to have it.07:40:00
@tgerbet:matrix.orgtgerbetI do not think it's possible, we do not always have the shasum in the composer lockfile07:43:34
@ma27:nicht-so.sexyma27
In reply to @tgerbet:matrix.org
I do not think it's possible, we do not always have the shasum in the composer lockfile
Doesn't each dependency in the lockfile have a source field with a content hash? But I may be missing your point :)
07:44:41
@tgerbet:matrix.orgtgerbet I remember correctly no, Composer does not set shasum for "Git" packages (even if it uses the GitHub API to download the package...) 07:52:56
@tgerbet:matrix.orgtgerbet * If I remember correctly no, Composer does not set shasum for "Git" packages (even if it uses the GitHub API to download the package...) 07:53:02
@philipp:xndr.dephilippSeems so, at least from the lock files I just checked.07:53:46
@philipp:xndr.dephilippBut builtins.fetchgit also doesn't require a shasum, right?07:54:54
@ma27:nicht-so.sexyma27 that won't be doable in nixpkgs then, tl;dr for why we use e.g. pkgs.fetchgit rather than builtins.fetchgit: https://discourse.nixos.org/t/replace-nixpkgs-fetchers-with-nix-builtins-fetchers/26106 08:14:37
@ma27:nicht-so.sexyma27
In reply to @tgerbet:matrix.org
If I remember correctly no, Composer does not set shasum for "Git" packages (even if it uses the GitHub API to download the package...)
oof, I looked at the wrong key, namely content and not shasum... good morning ma27 (and sorry for the confusion!) 🙃
08:15:52
@ma27:nicht-so.sexyma27unless we manage to sneak this into composer somehow I doubt that it'll be feasible (as it is with Rust for instance)08:18:13
@drupol:matrix.orgPol changed their profile picture.08:34:02
@drupol:matrix.orgPolCatching up the backlog, got in a meeting. Reading your messages.08:37:31
@drupol:matrix.orgPol
In reply to @philipp:xndr.de
Is there an example of it's usage in nixpkgs somewhere?
here? https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/typesetting/typst/default.nix
08:38:56
@drupol:matrix.orgPol
In reply to @tgerbet:matrix.org
I do not think it's possible, we do not always have the shasum in the composer lockfile
We can ask Jordi to add it :)
08:39:18
@tgerbet:matrix.orgtgerbet Hum yes but it would take a while to propagate to the whole ecosystem and it is likely on purpose. You do not get the same content if you --prefer-dist or --prefer-source 08:41:28
@drupol:matrix.orgPolAh ?!08:42:23
@philipp:xndr.dephilipp Oh, it's even documented! https://nixos.org/manual/nixpkgs/stable/#rust They seem to have the same problem with git hashes and solve it by providing them in the call tho cargoLock. 08:42:53
@drupol:matrix.orgPol Therefore, buildRustPackage also supports vendoring dependencies directly from a Cargo.lock file using the cargoLock argument. This will retrieve the dependencies using fixed-output derivations from the specified lockfile. 08:45:02
@drupol:matrix.orgPolWe should do that for PHP :)08:45:10
@philipp:xndr.dephilipp * Oh, it's even documented! https://nixos.org/manual/nixpkgs/stable/#rust They seem to have the same problem with git hashes and solve it by providing them in the call to cargoLock. 08:48:40
@tgerbet:matrix.orgtgerbet
In reply to @drupol:matrix.org
Ah ?!
Yes, when using prefer-dist Composer will try to get the tarball directly from GH/GL/whatever which will use the export-ignorethat the dep might have set in .gitattributes. When using prefer-source it will do a git clone directly
08:50:17
@drupol:matrix.orgPol
In reply to @tgerbet:matrix.org
Yes, when using prefer-dist Composer will try to get the tarball directly from GH/GL/whatever which will use the export-ignorethat the dep might have set in .gitattributes. When using prefer-source it will do a git clone directly
We could imagine to have rules. If we want to have Nix to build a PHP library or app, the composer.json must have been built using --prefer-source (or whatever). Since this lock file must be in Nix, it's fine.
08:51:42
@drupol:matrix.orgPol See here, the Cargo.lock is inside nixpkgs: https://github.com/NixOS/nixpkgs/tree/master/pkgs/tools/typesetting/typst 08:52:18

Show newer messages


Back to Room ListRoom Version: 6