flake.nix for PHP apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
description = "PHP App demo"; | |
inputs.nixpkgs.url = "nixpkgs/nixpkgs-unstable"; | |
inputs.flake-utils.url = "github:numtide/flake-utils"; | |
inputs.phps.url = "github:loophp/nix-shell"; | |
outputs = { self, nixpkgs, flake-utils, phps }: flake-utils.lib.eachDefaultSystem | |
(system: | |
let | |
name = "PHPApp"; | |
port = "8000"; # Must be a string | |
public = "public"; | |
revision = "${self.lastModifiedDate}-${self.shortRev or "dirty"}"; | |
pkgs = nixpkgs.legacyPackages.${system}; | |
src = self; | |
php = phps.packages.${system}.php81-nts; | |
phpProject = pkgs.callPackage ./composer-project.nix { | |
inherit php; | |
} src; | |
wrapper = pkgs.writeScriptBin name '' | |
#!${pkgs.bash}/bin/bash | |
${php}/bin/php -S 0.0.0.0:${port} -t ${public} | |
''; | |
phpApp = pkgs.stdenv.mkDerivation { | |
inherit name; | |
src = self; | |
buildInputs = [ | |
phpProject | |
wrapper | |
]; | |
installPhase = '' | |
mkdir -p $out/bin | |
cp -r ${wrapper}/bin/* $out/bin/ | |
''; | |
}; | |
in | |
{ | |
defaultApp = phpApp; | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nic