Skip to content

Commit

Permalink
fix: nix run command isn't able to execute php files
Browse files Browse the repository at this point in the history
  • Loading branch information
Sironheart committed Apr 18, 2024
1 parent fb148da commit 6ee1130
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions template/php/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
inputs',
pkgs,
system,
lib,
...
}: let
inherit (pkgs) dockerTools php83;
inherit (pkgs) dockerTools php83 mkShell writeShellApplication;
inherit (lib) getExe;
inherit (dockerTools) buildImage;
inherit (php83) buildComposerProject;
inherit (php83) buildComposerProject buildEnv;
name = "example";
version = "0.1.0";
phpEnvironment = php83.buildEnv {
phpEnvironment = buildEnv {
extensions = {
enabled,
all,
Expand All @@ -35,11 +37,26 @@
};
in {
devShells = {
default = pkgs.mkShell {
default = mkShell {
inputsFrom = [self'.packages.default];
};
};

apps.default = {
type = "app";
program = getExe (writeShellApplication {
inherit name;

runtimeInputs = [
phpEnvironment
];

text = ''
${getExe phpEnvironment} ${self'.packages.default}/share/php/${name}/src/index.php
'';
});
};

packages = {
default = buildComposerProject {
inherit version;
Expand All @@ -50,16 +67,18 @@
php = phpEnvironment;

composerLock = ./composer.lock;
composerNoDev = false;

preInstall = ''
ls -la
'';
};

docker = buildImage {
inherit name;
tag = version;
config = {
Cmd = ["${self'.packages.default}/bin/${name}"];
Env = [
"SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
];
Cmd = ["${self'.apps.default.program}"];
};
};
};
Expand Down

0 comments on commit 6ee1130

Please sign in to comment.