1# Need to get the mkShellNoCC function 2let 3 nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-24.11"; 4 # config and overlays are set to avoid them to being overridden by global configuration. 5 pkgs = import nixpkgs { config = {}; overlays = []; }; 6in 7 8# Needed to get the php 7.4.29 version (does not have mkShellNoCC) 9# 7.4.32 was not available 10# https://lazamar.co.uk/nix-versions/?package=php-with-extensions&version=7.4.29&fullName=php-with-extensions-7.4.29&keyName=php74&revision=6e3a86f2f73a466656a401302d3ece26fba401d9&channel=nixpkgs-unstable#instructions 11let 12 nixpkgsWithPhp74 = fetchTarball "https://github.com/NixOS/nixpkgs/archive/6e3a86f2f73a466656a401302d3ece26fba401d9.tar.gz"; 13 pkgsWithPhp74 = import nixpkgsWithPhp74 { config = {}; overlays = []; }; 14 php74 = pkgsWithPhp74.php74.buildEnv { 15 extensions = { enabled, all }: enabled ++ (with all; [ opcache ]); 16 }; 17in 18 19# mkShellNoCC: a shell but without a compiler toolchain. 20# https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-mkShell 21pkgs.mkShellNoCC { 22 packages = [ 23 # Php package 24 # https://nixos.org/manual/nixpkgs/stable/#sec-php 25 # https://wiki.nixos.org/wiki/PHP 26 php74 27 ]; 28 # ShellHook: run some commands before entering the shell environment 29 shellHook = '' 30 echo "PHP version: $(php --version | head -n 1)" 31 ''; 32}