Created
July 4, 2023 07:30
-
-
Save drupol/6129de86ee13d3184a328c2e2b57464a to your computer and use it in GitHub Desktop.
Flake for Symfony app
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 | |
export TMPDIR=$(dirname $(mktemp -u)) | |
export APP_CACHE_DIR=$TMPDIR/${name} | |
export APP_LOG_DIR=$APP_CACHE_DIR/log | |
${php}/bin/php -S 0.0.0.0:${port} -t ${phpProject}/libexec/source/${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