Skip to content

Instantly share code, notes, and snippets.

@drupol
Created March 18, 2022 12:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
flake.nix for PHP apps
{
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;
}
);
}
@Osamasemsem
Copy link

Nic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment