loophp / nix-shell Goto Github PK
View Code? Open in Web Editor NEWNix shells for PHP development
License: MIT License
Nix shells for PHP development
License: MIT License
nix shell
as README specifies did not work for me (seemingly nothing happened after executing it), but then I noticed that in GIF you use nix develop
. That correctly changes my terminal to new environment.
Hi, since d2940b4 I've an issue with grep and ohmyzsh.
grep --version
grep: unrecognized option: exclude-dir=.bzr
BusyBox v1.36.1 () multi-call binary.
I think that this issue is due to the new use of minimal-nix-shell, and the caching mecanism used by ohmyszsh https://github.com/ohmyzsh/ohmyzsh/blob/fd219a94ab585fa699a0e842335a9f33dcbb613b/lib/grep.zsh#L4
Busybox grep version has to be used with --exclude option, and nixos grep with --exclude-dir
If the cache file exists and is not older than a day, the right option to be used with grep will not be selected https://github.com/ohmyzsh/ohmyzsh/blob/fd219a94ab585fa699a0e842335a9f33dcbb613b/lib/grep.zsh#L18-L22
I love the idea of inferring default extensions to install from composer.json. I would like to have the same functionality for inferring default PHP version itself as well. At the moment, it's always defaulting to PHP 8.1, no matter what is in composer.json. I suggest to parse require.php
from composer.json
and detect minimum version from there. My initial attempt is
builtins.replaceStrings ["."] [""] (
builtins.head (
builtins.match ".*([[:digit:]]\.[[:digit:]])"
(
builtins.fromJSON (
builtins.readFile "${builtins.getEnv "PWD"}/composer.json"
)
)
.require
.php
)
)
but this ought to be improved, because this doesn't handle values like ^7.4 || ^8.0
github:loophp/nix-shell#env-php82 --impure
I read the new flake.nix and I saw your new modification : .user.ini is no longer used in configuration and the composer.json read is that local to the repository.
What can I do to get back to the old behaviour ? Thanks for your help ๐
Is it possible to add a Laravel Template?
composer.json
:"require-dev": {
"ext-xdebug": "*"
}
composer install
to generate the lock filenix-shell.api.makePhp
in flake.nix
to generate a devShell as per example in READMEnix develop --impure
php --info | grep xdebug
returning xdebug configurationphp --info | grep xdebug
returns nothingI made an example flake: buurro/nix-php-example
nix build github:buurro/nix-php-example/2845332e938b1df94eb4e823b5b10a8399e2b55b#packages.x86_64-linux.php56
error: builder for '/nix/store/9ydf6ry2pnigbwws01fqpiazs33cg0y5-php-5.6.40.drv' failed with exit code 2;
last 10 log lines:
> checking for gawk... gawk
> checking for bison... bison -y
> checking for bison version... 3.8 (ok)
> checking for re2c... re2c
> checking for re2c version... 3.1 (ok)
> checking whether to enable computed goto gcc extension with re2c... no
> checking whether to force non-PIC code in shared modules... no
> checking whether /dev/urandom exists... yes
> ./configure: line 6851: syntax error near unexpected token `fi'
> ./configure: line 6851: `fi'
For full logs, run 'nix log /nix/store/9ydf6ry2pnigbwws01fqpiazs33cg0y5-php-5.6.40.drv'.
error: 1 dependencies of derivation '/nix/store/nb73ngk59ari4azcw6c4v5q1n43ilckk-php-with-extensions-5.6.40.drv' failed to build
Running nix build github:loophp/nix-shell#php56
works, so I don't understand where is the issue.
With a composer.json
where ext-xdebug
is required
{
...
"require": {
"php": "~8.2"
},
"require-dev": {
"ext-xdebug": "*",
}
...
}
nix shell github:loophp/nix-shell#env-php82 --impure
php --version
PHP 8.2.11 (cli) (built: Sep 26 2023 11:11:58) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.11, Copyright (c) Zend Technologies
with Zend OPcache v8.2.11, Copyright (c), by Zend Technologies
with Xdebug v3.2.2, Copyright (c) 2002-2023, by Derick Rethans
(it works with a previous commit nix shell github:loophp/nix-shell/939d9#env-php82 --impure
)
PHP 8.2.11 (cli) (built: Sep 26 2023 11:11:58) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.11, Copyright (c) Zend Technologies
with Zend OPcache v8.2.11, Copyright (c), by Zend Technologies
Running eg. nix develop github:loophp/nix-shell#php74 in folder with composer.json that has no ext- sections takes still quite long time. I can see it compiling things like gd, mysql, iconv and so on which are not needed at all. Is it possible to either improve the speed of installing these (binaries instead of having to compile it? Installing multiple extensions at the same time, or at least each with -J flag?), or skip them? Otherwise amazing feature of this shell, which is auto-installation of extensions from composer.json is quite under-utilized.
Hi,
I have "NAR hash mismatch" errors If I create a new .envrc file in a directory or if I change the php version in an existing .envrc file
direnv: loading /home/dev/DGD/.envrc
direnv: using flake github:loophp/nix-shell#env-php74 --impure
error: NAR hash mismatch in input 'https://www.php.net/releases/active?narHash=sha256-20qIiLPpROWf6onLj1r7dMjt%2fVhUO8%2f%2ffzYYt4KlPYQ=' (/nix/store/3vkk556lnayd123wr6rzjvdw6ambsbcs-source), expected 'sha256-20qIiLPpROWf6onLj1r7dMjt/VhUO8//fzYYt4KlPYQ=', got 'sha256-Omnc2u11Y6CnV3oO1NwrzhB+scKXeOx0tkoAZz7PS3g='
direnv: nix-direnv: renewed cache
direnv: export +CONFIG_SHELL +HOST_PATH +IN_NIX_SHELL +NIX_BUILD_CORES +NIX_CFLAGS_COMPILE +NIX_ENFORCE_NO_NATIVE +NIX_LDFLAGS +NIX_STORE +SOURCE_DATE_EPOCH +__structuredAttrs +buildInputs +buildPhase +builder +cmakeFlags +configureFlags +depsBuildBuild +depsBuildBuildPropagated +depsBuildTarget +depsBuildTargetPropagated +depsHostHost +depsHostHostPropagated +depsTargetTarget +depsTargetTargetPropagated +doCheck +doInstallCheck +dontAddDisableDepTrack +mesonFlags +name +nativeBuildInputs +out +outputs +patches +phases +preferLocalBuild +propagatedBuildInputs +propagatedNativeBuildInputs +shell +shellHook +stdenv +strictDeps +system ~PATH ~XDG_DATA_DIRS
Any ideas how to solve this ?
Thx
nix shell github:loophp/nix-shell#php74
at MacOS without experimental features enabledbuilding php-7.4...
error: experimental Nix feature 'nix-command' is disabled; use '--extra-experimental-features nix-command' to override
On macOS running commands from README would throw an error, it can be fixed by enabling experimental features.
# ~/.config/nix/nix.conf
experimental-features = nix-command flakes
Maybe it would be good to mention this behavior somewhere in the readme?
what if i need mongodb extension
,thank u
flake.nix
as per README example under "You may also use the API to build your own custom version of PHP in your own flake:"nix develop
fails, so I tried replacing makePhp system
with makePhp pkgs
; this worked fine with php81"php81"
with "php56"
nix develop
error: value is a string while a set was expected
at /nix/store/s8427y5ln38zyyya2vgh3hfk0cq414mi-source/src/phps.nix:113:12:
112| if builtins.isString php
113| then pkgs."${php}"
| ^
114| else php;
error: attribute 'php56' missing
at /nix/store/s8427y5ln38zyyya2vgh3hfk0cq414mi-source/src/phps.nix:113:12:
112| if builtins.isString php
113| then pkgs."${php}"
| ^
114| else php;
Did you mean one of php, php73, php74, php80 or php81?
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
This repository currently has no open or pending branches.
.github/workflows/build.yaml
actions/checkout v4
actions/checkout v4
cachix/cachix-action v14
.github/workflows/flakehub-publish-rolling.yaml
actions/checkout v4
.github/workflows/merge.yaml
actions/github-script v7
actions/github-script v7
actions/github-script v7
actions/github-script v7
.github/workflows/nix-fmt-checks.yaml
actions/checkout v4
.github/workflows/publish.yaml
.github/workflows/upgrade-flakes.yaml
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.