diff --git a/.user.ini b/.user.ini new file mode 100644 index 0000000..b0fe7fe --- /dev/null +++ b/.user.ini @@ -0,0 +1 @@ +memory_limit=-1 diff --git a/default.nix b/default.nix index 873ece4..6466507 100644 --- a/default.nix +++ b/default.nix @@ -1,13 +1,9 @@ -(import - ( - let - lock = builtins.fromJSON (builtins.readFile ./flake.lock); - in - fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; - sha256 = lock.nodes.flake-compat.locked.narHash; - } - ) - { - src = ./.; - }).defaultNix +(import ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } +) { src = ./.; }).defaultNix diff --git a/flake.nix b/flake.nix index e38f61a..a985003 100644 --- a/flake.nix +++ b/flake.nix @@ -10,75 +10,104 @@ systems.url = "github:nix-systems/default"; }; - outputs = inputs @ { self, flake-parts, systems, ... }: flake-parts.lib.mkFlake { inherit inputs; } { - systems = import systems; + outputs = + inputs@{ + self, + flake-parts, + systems, + ... + }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = import systems; - flake = { - templates = { - basic = { - path = ./templates/basic; - description = "A basic template for getting started with PHP development"; - welcomeText = builtins.readFile ./templates/basic/README.md; - }; - }; + imports = [ + ./src/imports/formatter.nix + ./src/imports/overlay.nix + ./src/imports/templates.nix + ]; - overlays.default = import ./src/overlay inputs; - }; + flake = { + overlays.default = import ./src/overlay inputs; + }; - perSystem = { self', inputs', config, pkgs, system, lib, ... }: - let - buildPhpFromComposer = pkgs.callPackage ./src/build-support/build-php-from-composer.nix { }; + perSystem = + { + self', + inputs', + config, + pkgs, + system, + lib, + ... + }: + let + buildPhpFromComposer = pkgs.callPackage ./src/build-support/build-php-from-composer.nix { }; - phps = lib.mapAttrs - # To fix: Why using this while it is already in use in the overlay? - (name: value: buildPhpFromComposer { php = value; src = self; }) - (lib.filterAttrs (k: v: lib.isDerivation v) (inputs.self.overlays.default null pkgs)); + phps = + lib.mapAttrs + # To fix: Why using this while it is already in use in the overlay? + ( + name: value: + buildPhpFromComposer { + php = value; + src = self; + } + ) + (lib.filterAttrs (k: v: lib.isDerivation v) (inputs.self.overlays.default null pkgs)); - envPackages = [ - pkgs.symfony-cli - pkgs.sqlite - ]; + envPackages = [ + pkgs.symfony-cli + pkgs.sqlite + ]; - packages = lib.foldlAttrs - ( - carry: name: php: - carry // { - "${name}" = php; - "env-${name}" = pkgs.buildEnv { name = "env-${name}"; paths = [ php php.packages.composer ] ++ envPackages; }; + packages = + lib.foldlAttrs + ( + carry: name: php: + carry + // { + "${name}" = php; + "env-${name}" = pkgs.buildEnv { + name = "env-${name}"; + paths = [ + php + php.packages.composer + ] ++ envPackages; + }; + } + ) + { + "default" = self'.packages.env-php81; + "env-default" = self'.packages.env-php81; } - ) - { - "default" = self'.packages.env-php81; - "env-default" = self'.packages.env-php81; - } - phps; + phps; - devShells = lib.foldlAttrs - ( - carry: name: php: + devShells = + lib.foldlAttrs + ( + carry: name: php: + { + "${name}" = pkgs.mkShellNoCC { + name = "${name}"; + buildInputs = [ + php + php.packages.composer + ]; + }; + "env-${name}" = self'.devShells."${name}".overrideAttrs (oldAttrs: { + buildInputs = oldAttrs.buildInputs ++ envPackages; + }); + } + // carry + ) { - "${name}" = pkgs.mkShellNoCC { name = "${name}"; buildInputs = [ php php.packages.composer ]; }; - "env-${name}" = self'.devShells."${name}".overrideAttrs (oldAttrs: { buildInputs = oldAttrs.buildInputs ++ envPackages; }); - } // carry - ) - { - "default" = self'.devShells.env-php81; - "env-default" = self'.devShells.env-php81; - } - phps; - in - { - _module.args.pkgs = import self.inputs.nixpkgs { - inherit system; - overlays = [ - self.overlays.default - ]; - config.allowUnfree = true; + "default" = self'.devShells.env-php81; + "env-default" = self'.devShells.env-php81; + } + phps; + in + { + inherit packages devShells; }; - - formatter = pkgs.nixpkgs-fmt; - - inherit packages devShells; - }; - }; + }; } diff --git a/shell.nix b/shell.nix index 9eb132a..493783d 100644 --- a/shell.nix +++ b/shell.nix @@ -1,13 +1,9 @@ -(import - ( - let - lock = builtins.fromJSON (builtins.readFile ./flake.lock); - in - fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; - sha256 = lock.nodes.flake-compat.locked.narHash; - } - ) - { - src = ./.; - }).shellNix +(import ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } +) { src = ./.; }).shellNix diff --git a/src/build-support/build-php-from-composer.nix b/src/build-support/build-php-from-composer.nix index cba66c7..4314390 100644 --- a/src/build-support/build-php-from-composer.nix +++ b/src/build-support/build-php-from-composer.nix @@ -1,41 +1,50 @@ -{ lib -, php -, pkgs +{ + lib, + php, + pkgs, }@inputs: let getExtensionsFromSection = - { composerJson - , section - , default ? { } - } @ args: + { + composerJson, + section, + default ? { }, + }@args: let - readJsonSectionFromFile = file: section: default: + readJsonSectionFromFile = + file: section: default: let filecontent = - if builtins.pathExists composerJson - then builtins.fromJSON (builtins.readFile composerJson) - else { }; + if builtins.pathExists composerJson then + builtins.fromJSON (builtins.readFile composerJson) + else + { }; in - filecontent.${section} or default; + filecontent.${section} or default; # Get "require" section to extract extensions later require = readJsonSectionFromFile args.composerJson args.section args.default; # Copy keys into values composerRequiresKeys = map (p: lib.attrsets.mapAttrs' (k: v: lib.nameValuePair k k) p) [ require ]; # Convert sets into lists - composerRequiresMap = map (package: (map (key: builtins.getAttr key package) (builtins.attrNames package))) composerRequiresKeys; + composerRequiresMap = map ( + package: (map (key: builtins.getAttr key package) (builtins.attrNames package)) + ) composerRequiresKeys; in # Convert the set into a list, filter out values not starting with "ext-", get rid of the first 4 characters from the name - map (x: builtins.substring 4 (builtins.stringLength x) x) (builtins.filter (x: (builtins.substring 0 4 x) == "ext-") (lib.flatten composerRequiresMap)); + map (x: builtins.substring 4 (builtins.stringLength x) x) ( + builtins.filter (x: (builtins.substring 0 4 x) == "ext-") (lib.flatten composerRequiresMap) + ); in -{ src -, php ? inputs.php -, extensions ? [ ] -, withExtensions ? [ ] -, withoutExtensions ? [ ] -, extraConfig ? null -, flags ? { } +{ + src, + php ? inputs.php, + extensions ? [ ], + withExtensions ? [ ], + withoutExtensions ? [ ], + extraConfig ? null, + flags ? { }, }: let # Normalize the php parameter(string or drv) into a derivation. @@ -45,23 +54,33 @@ in extraConfig = lib.concatStrings [ (lib.optionalString (extraConfig != null) extraConfig) (lib.optionalString (builtins.pathExists "${src}/.user.ini") (builtins.readFile "${src}/.user.ini")) - (lib.optionalString (builtins.pathExists "${builtins.getEnv "PWD"}/.user.ini") (builtins.readFile "${builtins.getEnv "PWD"}/.user.ini")) + (lib.optionalString (builtins.pathExists "${builtins.getEnv "PWD"}/.user.ini") ( + builtins.readFile "${builtins.getEnv "PWD"}/.user.ini" + )) ]; - extensions = extensions@{ all, enabled, ... }: + extensions = + extensions@{ all, enabled, ... }: let buildExtensions = - { all - , enabled - , withExtensions - , withoutExtensions - , composerExtensions ? [ ] + { + all, + enabled, + withExtensions, + withoutExtensions, + composerExtensions ? [ ], }: let - filterStringExtensions = extList: - builtins.filter - (ext: (builtins.isString ext) && (lib.warnIf (!(all ? "${ext}")) "The ${ext} extension does not exist or is enabled by default in PHP ${phpDrv.version}, ignoring." (all ? "${ext}"))) - extList; + filterStringExtensions = + extList: + builtins.filter ( + ext: + (builtins.isString ext) + && (lib.warnIf (!(all ? "${ext}")) + "The ${ext} extension does not exist or is enabled by default in PHP ${phpDrv.version}, ignoring." + (all ? "${ext}") + ) + ) extList; filterDrvExtensions = builtins.filter lib.isDerivation; @@ -70,37 +89,37 @@ in userExtensionsAsStringToRemove = filterStringExtensions (withoutExtensions); # Display a warning when trying to build an extension that is already enabled or does not build - e0 = builtins.map - (ext: lib.warnIf ((builtins.tryEval all."${ext}".outPath).success == false) "The ${ext} extension is enabled in PHP ${phpDrv.version} but failed to build, ignoring." ext) - userExtensionAsStringToAdd; + e0 = builtins.map ( + ext: + lib.warnIf ( + (builtins.tryEval all."${ext}".outPath).success == false + ) "The ${ext} extension is enabled in PHP ${phpDrv.version} but failed to build, ignoring." ext + ) userExtensionAsStringToAdd; # Remove extensions that does not build - e1 = builtins.filter - (ext: (builtins.tryEval all."${ext}".outPath).success) - e0; + e1 = builtins.filter (ext: (builtins.tryEval all."${ext}".outPath).success) e0; # Remove extensions provided as derivation to avoid duplicates # 1. Convert withExtensions to a list of strings # 2. Remove extensions that are in `enabled` and `e1` if they are in that list - e2 = builtins.filter - (ext: !builtins.elem (ext.pname) (builtins.map (e: e.pname) (filterDrvExtensions withExtensions))) - (enabled ++ (builtins.map (ext: all."${ext}") e1)); + e2 = builtins.filter ( + ext: !builtins.elem (ext.pname) (builtins.map (e: e.pname) (filterDrvExtensions withExtensions)) + ) (enabled ++ (builtins.map (ext: all."${ext}") e1)); # Consolidate the list of extensions as derivations e3 = e2 ++ (filterDrvExtensions withExtensions); # Remove unwanted extensions provided as strings - e4 = builtins.filter - (ext: - !((builtins.elem (ext.pname) (builtins.map (e: "php-${e}") userExtensionsAsStringToRemove)) || - (builtins.elem (ext.pname) userExtensionsAsStringToRemove)) + e4 = builtins.filter ( + ext: + !( + (builtins.elem (ext.pname) (builtins.map (e: "php-${e}") userExtensionsAsStringToRemove)) + || (builtins.elem (ext.pname) userExtensionsAsStringToRemove) ) - e3; + ) e3; # Remove unwanted extensions provided as derivations - e5 = builtins.filter - (ext: !builtins.elem ext (filterDrvExtensions withoutExtensions)) - e4; + e5 = builtins.filter (ext: !builtins.elem ext (filterDrvExtensions withoutExtensions)) e4; in e5; in @@ -108,9 +127,25 @@ in inherit (extensions) all enabled; inherit withExtensions withoutExtensions; composerExtensions = - (getExtensionsFromSection { composerJson = "${src}/composer.json"; section = "require"; default = { }; }) ++ - (getExtensionsFromSection { composerJson = "${src}/composer.json"; section = "require-dev"; default = { }; }) ++ - (getExtensionsFromSection { composerJson = "${builtins.getEnv "PWD"}/composer.json"; section = "require"; default = { }; }) ++ - (getExtensionsFromSection { composerJson = "${builtins.getEnv "PWD"}/composer.json"; section = "require-dev"; default = { }; }); + (getExtensionsFromSection { + composerJson = "${src}/composer.json"; + section = "require"; + default = { }; + }) + ++ (getExtensionsFromSection { + composerJson = "${src}/composer.json"; + section = "require-dev"; + default = { }; + }) + ++ (getExtensionsFromSection { + composerJson = "${builtins.getEnv "PWD"}/composer.json"; + section = "require"; + default = { }; + }) + ++ (getExtensionsFromSection { + composerJson = "${builtins.getEnv "PWD"}/composer.json"; + section = "require-dev"; + default = { }; + }); }); }) diff --git a/src/imports/formatter.nix b/src/imports/formatter.nix new file mode 100644 index 0000000..9bd90c9 --- /dev/null +++ b/src/imports/formatter.nix @@ -0,0 +1,9 @@ +{ ... }: + +{ + perSystem = + { pkgs, ... }: + { + formatter = pkgs.nixfmt-rfc-style; + }; +} diff --git a/src/imports/overlay.nix b/src/imports/overlay.nix new file mode 100644 index 0000000..b0a85b2 --- /dev/null +++ b/src/imports/overlay.nix @@ -0,0 +1,20 @@ +{ inputs, ... }: + +{ + perSystem = + { + config, + self', + inputs', + pkgs, + system, + ... + }: + { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ inputs.self.overlays.default ]; + config.allowUnfree = true; + }; + }; +} diff --git a/src/imports/templates.nix b/src/imports/templates.nix new file mode 100644 index 0000000..e0e8eac --- /dev/null +++ b/src/imports/templates.nix @@ -0,0 +1,13 @@ +{ ... }: + +{ + flake = { + templates = { + basic = { + path = ../../templates/basic; + description = "A basic template for getting started with PHP development"; + welcomeText = builtins.readFile ./templates/basic/README.md; + }; + }; + }; +} diff --git a/src/overlay/api.nix b/src/overlay/api.nix index 5516e6e..3c03667 100644 --- a/src/overlay/api.nix +++ b/src/overlay/api.nix @@ -1,7 +1,6 @@ inputs: -final: -prev: +final: prev: let buildPhpFromComposer = prev.callPackage ../build-support/build-php-from-composer.nix { }; diff --git a/src/overlay/default.nix b/src/overlay/default.nix index 0eafdb6..f4db263 100644 --- a/src/overlay/default.nix +++ b/src/overlay/default.nix @@ -1,7 +1,6 @@ inputs: -final: -prev: +final: prev: let phps = import ./phps.nix inputs final prev; diff --git a/src/overlay/phps.nix b/src/overlay/phps.nix index da6d875..a9fad6f 100644 --- a/src/overlay/phps.nix +++ b/src/overlay/phps.nix @@ -1,13 +1,17 @@ inputs: -final: -prev: +final: prev: let buildPhpFromComposer = (inputs.self.overlays.default final prev).api.buildPhpFromComposer; nix-phps = inputs.nix-phps.overlays.default final prev; php-src-nix-snapshot = inputs.php-src-nix.overlays.snapshot final prev; in -builtins.mapAttrs - (name: value: buildPhpFromComposer { php = value; src = inputs.self; }) - php-src-nix-snapshot // nix-phps +builtins.mapAttrs ( + name: value: + buildPhpFromComposer { + php = value; + src = inputs.self; + } +) php-src-nix-snapshot +// nix-phps diff --git a/templates/basic/flake.nix b/templates/basic/flake.nix index 5e4a55e..bfd1873 100644 --- a/templates/basic/flake.nix +++ b/templates/basic/flake.nix @@ -7,293 +7,315 @@ systems.url = "github:nix-systems/default"; }; - outputs = inputs@{ self, flake-parts, systems, ... }: flake-parts.lib.mkFlake { inherit inputs; } { - systems = import systems; - - perSystem = { config, self', inputs', pkgs, system, lib, ... }: - let - php = pkgs.api.buildPhpFromComposer { - src = inputs.self; - php = pkgs.php81; # Change to php56, php70, ..., php81, php82, php83 etc. - }; - in - { - _module.args.pkgs = import self.inputs.nixpkgs { - inherit system; - overlays = [ - inputs.nix-shell.overlays.default - ]; - config.allowUnfree = true; - }; + outputs = + inputs@{ + self, + flake-parts, + systems, + ... + }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = import systems; + + perSystem = + { + config, + self', + inputs', + pkgs, + system, + lib, + ... + }: + let + php = pkgs.api.buildPhpFromComposer { + src = inputs.self; + php = pkgs.php81; # Change to php56, php70, ..., php81, php82, php83 etc. + }; + in + { + _module.args.pkgs = import self.inputs.nixpkgs { + inherit system; + overlays = [ inputs.nix-shell.overlays.default ]; + config.allowUnfree = true; + }; - devShells.default = pkgs.mkShellNoCC { - name = "php-devshell"; - buildInputs = [ - php - php.packages.composer - php.packages.phpstan - php.packages.psalm - pkgs.phpunit - self'.packages.satis - ]; - }; + devShells.default = pkgs.mkShellNoCC { + name = "php-devshell"; + buildInputs = [ + php + php.packages.composer + php.packages.phpstan + php.packages.psalm + pkgs.phpunit + self'.packages.satis + ]; + }; - checks = { - inherit (self'.packages) drupal satis symfony-demo; - }; + checks = { + inherit (self'.packages) drupal satis symfony-demo; + }; - packages = { - satis = php.buildComposerProject { - pname = "satis"; - version = "3.0.0-dev"; + packages = { + satis = php.buildComposerProject { + pname = "satis"; + version = "3.0.0-dev"; - src = pkgs.fetchFromGitHub { - owner = "composer"; - repo = "satis"; - rev = "23fdf4c1893567c6e46a2cc7fcc868b913f03b28"; - hash = "sha256-UMf9/UQl7lK+AG58lBBFkJMpklooWJ4vpAX5ibciFJI="; - }; + src = pkgs.fetchFromGitHub { + owner = "composer"; + repo = "satis"; + rev = "23fdf4c1893567c6e46a2cc7fcc868b913f03b28"; + hash = "sha256-UMf9/UQl7lK+AG58lBBFkJMpklooWJ4vpAX5ibciFJI="; + }; - vendorHash = "sha256-YA5UIlGhRVdkz+NFiujGRkb9Zx8Up4IEOmco1rEOkGk="; + vendorHash = "sha256-YA5UIlGhRVdkz+NFiujGRkb9Zx8Up4IEOmco1rEOkGk="; - meta.mainProgram = "satis"; - }; + meta.mainProgram = "satis"; + }; + + drupal = php.buildComposerProject { + pname = "drupal"; + version = "11.0.0-dev"; - drupal = php.buildComposerProject { - pname = "drupal"; - version = "11.0.0-dev"; + src = pkgs.fetchFromGitHub { + owner = "drupal"; + repo = "drupal"; + rev = "72e7c019993f7d8491de277c66f40354a0967b00"; + hash = "sha256-nrR+jj8wCTN2RLWxik19emEGyVqzoBiUo6aAfNQZG8Q="; + }; - src = pkgs.fetchFromGitHub { - owner = "drupal"; - repo = "drupal"; - rev = "72e7c019993f7d8491de277c66f40354a0967b00"; - hash = "sha256-nrR+jj8wCTN2RLWxik19emEGyVqzoBiUo6aAfNQZG8Q="; + vendorHash = "sha256-39cCLG4x8/C9XZG2sOCpxO1HUsqt3DduCMMIxPCursw="; }; - vendorHash = "sha256-39cCLG4x8/C9XZG2sOCpxO1HUsqt3DduCMMIxPCursw="; - }; + symfony-demo-image = pkgs.dockerTools.buildLayeredImage { + name = self'.packages.symfony-demo.pname; + tag = "latest"; + + contents = + let + caddyFile = pkgs.writeText "Caddyfile" '' + { + email youremail@domain.com + } + + :80 { + root * /app/public + log + encode gzip + php_fastcgi 127.0.0.1:9000 + file_server + } + + :443 { + root * /app/public + log + encode gzip + php_fastcgi 127.0.0.1:9000 + file_server + tls internal { + on_demand + } + } + ''; + in + [ + php + pkgs.caddy + pkgs.fakeNss + (pkgs.writeScriptBin "start-server" '' + #!${pkgs.runtimeShell} + php-fpm -D -y /etc/php-fpm.d/www.conf.default + caddy run --adapter caddyfile --config ${caddyFile} + '') + ]; - symfony-demo-image = pkgs.dockerTools.buildLayeredImage { - name = self'.packages.symfony-demo.pname; - tag = "latest"; - - contents = - let - caddyFile = pkgs.writeText "Caddyfile" '' - { - email youremail@domain.com - } - - :80 { - root * /app/public - log - encode gzip - php_fastcgi 127.0.0.1:9000 - file_server - } - - :443 { - root * /app/public - log - encode gzip - php_fastcgi 127.0.0.1:9000 - file_server - tls internal { - on_demand - } - } - ''; - in - [ - php - pkgs.caddy - pkgs.fakeNss - (pkgs.writeScriptBin "start-server" '' - #!${pkgs.runtimeShell} - php-fpm -D -y /etc/php-fpm.d/www.conf.default - caddy run --adapter caddyfile --config ${caddyFile} - '') - ]; - - extraCommands = '' - ln -s ${self'.packages.symfony-demo}/share/php/${self'.packages.symfony-demo.pname}/ app - mkdir -p tmp - chmod -R 777 tmp - cp ${self'.packages.symfony-demo}/share/php/${self'.packages.symfony-demo.pname}/data/database.sqlite tmp/database.sqlite - chmod +w tmp/database.sqlite - ''; - - config = { - Cmd = [ "start-server" ]; - ExposedPorts = { - "80/tcp" = { }; - "443/tcp" = { }; + extraCommands = '' + ln -s ${self'.packages.symfony-demo}/share/php/${self'.packages.symfony-demo.pname}/ app + mkdir -p tmp + chmod -R 777 tmp + cp ${self'.packages.symfony-demo}/share/php/${self'.packages.symfony-demo.pname}/data/database.sqlite tmp/database.sqlite + chmod +w tmp/database.sqlite + ''; + + config = { + Cmd = [ "start-server" ]; + ExposedPorts = { + "80/tcp" = { }; + "443/tcp" = { }; + }; }; }; - }; - symfony-demo = php.buildComposerProject { - pname = "symfony-demo"; - version = "1.0.0"; + symfony-demo = php.buildComposerProject { + pname = "symfony-demo"; + version = "1.0.0"; - src = pkgs.fetchFromGitHub { - owner = "symfony"; - repo = "demo"; - rev = "e8a754777bd400ecf87e8c6eeea8569d4846d357"; - hash = "sha256-ZG0O8O4X5t/GkAVKhcedd3P7WXYiZ0asMddX1XfUVR4="; - }; + src = pkgs.fetchFromGitHub { + owner = "symfony"; + repo = "demo"; + rev = "e8a754777bd400ecf87e8c6eeea8569d4846d357"; + hash = "sha256-ZG0O8O4X5t/GkAVKhcedd3P7WXYiZ0asMddX1XfUVR4="; + }; - composerNoDev = false; - composerNoPlugins = false; + composerNoDev = false; + composerNoPlugins = false; - preInstall = '' - ls -la - ''; + preInstall = '' + ls -la + ''; - vendorHash = "sha256-Nv9pRQJ2Iij1IxPNcCk732Q79FWB/ARJRvjPVVyLMEc="; + vendorHash = "sha256-Nv9pRQJ2Iij1IxPNcCk732Q79FWB/ARJRvjPVVyLMEc="; + }; }; apps = { mezzio-skeleton = { type = "app"; - program = lib.getExe (pkgs.writeShellApplication { - name = "mezzio-skeleton-demo"; + program = lib.getExe ( + pkgs.writeShellApplication { + name = "mezzio-skeleton-demo"; - runtimeInputs = [ - php - ]; + runtimeInputs = [ php ]; - text = '' - ${lib.getExe php} -S 0.0.0.0:8080 -t ${self'.packages.mezzio}/share/php/${self'.packages.mezzio.pname}/public/ - ''; - }); + text = '' + ${lib.getExe php} -S 0.0.0.0:8080 -t ${self'.packages.mezzio}/share/php/${self'.packages.mezzio.pname}/public/ + ''; + } + ); }; symfony-demo = { type = "app"; - program = lib.getExe (pkgs.writeShellApplication { - name = "php-symfony-demo"; + program = lib.getExe ( + pkgs.writeShellApplication { + name = "php-symfony-demo"; - runtimeInputs = [ - php - ]; + runtimeInputs = [ php ]; - text = '' - APP_CACHE_DIR=$(mktemp -u)/cache - APP_LOG_DIR=$APP_CACHE_DIR/log - DATABASE_URL=sqlite:///$APP_CACHE_DIR/database.sqlite + text = '' + APP_CACHE_DIR=$(mktemp -u)/cache + APP_LOG_DIR=$APP_CACHE_DIR/log + DATABASE_URL=sqlite:///$APP_CACHE_DIR/database.sqlite - export APP_CACHE_DIR - export APP_LOG_DIR - export DATABASE_URL + export APP_CACHE_DIR + export APP_LOG_DIR + export DATABASE_URL - mkdir -p "$APP_CACHE_DIR" - mkdir -p "$APP_LOG_DIR" + mkdir -p "$APP_CACHE_DIR" + mkdir -p "$APP_LOG_DIR" - cp -f ${self'.packages.symfony-demo}/share/php/symfony-demo/data/database.sqlite "$APP_CACHE_DIR"/database.sqlite - chmod +w "$APP_CACHE_DIR"/database.sqlite + cp -f ${self'.packages.symfony-demo}/share/php/symfony-demo/data/database.sqlite "$APP_CACHE_DIR"/database.sqlite + chmod +w "$APP_CACHE_DIR"/database.sqlite - ${lib.getExe pkgs.symfony-cli} serve --document-root ${self'.packages.symfony-demo}/share/php/symfony-demo/public --allow-http - ''; - }); + ${lib.getExe pkgs.symfony-cli} serve --document-root ${self'.packages.symfony-demo}/share/php/symfony-demo/public --allow-http + ''; + } + ); }; # nix run .#satis -- --version satis = { type = "app"; - program = lib.getExe (pkgs.writeShellApplication { - name = "satis"; - - text = '' - ${lib.getExe self'.packages.satis} "$@" - ''; - }); + program = lib.getExe ( + pkgs.writeShellApplication { + name = "satis"; + + text = '' + ${lib.getExe self'.packages.satis} "$@" + ''; + } + ); }; # nix run .#composer -- --version composer = { type = "app"; - program = lib.getExe (pkgs.writeShellApplication { - name = "composer"; - - runtimeInputs = [ - php - php.packages.composer - ]; - - text = '' - ${lib.getExe php.packages.composer} "$@" - ''; - }); + program = lib.getExe ( + pkgs.writeShellApplication { + name = "composer"; + + runtimeInputs = [ + php + php.packages.composer + ]; + + text = '' + ${lib.getExe php.packages.composer} "$@" + ''; + } + ); }; # nix run .#grumphp -- --version grumphp = { type = "app"; - program = lib.getExe (pkgs.writeShellApplication { - name = "grumphp"; + program = lib.getExe ( + pkgs.writeShellApplication { + name = "grumphp"; - runtimeInputs = [ - php - ]; + runtimeInputs = [ php ]; - text = '' - ${lib.getExe php.packages.grumphp} "$@" - ''; - }); + text = '' + ${lib.getExe php.packages.grumphp} "$@" + ''; + } + ); }; # nix run .#phpunit -- --version phpunit = { type = "app"; - program = lib.getExe (pkgs.writeShellApplication { - name = "phpunit"; + program = lib.getExe ( + pkgs.writeShellApplication { + name = "phpunit"; - runtimeInputs = [ - php - ]; + runtimeInputs = [ php ]; - text = '' - ${lib.getExe pkgs.phpunit} "$@" - ''; - }); + text = '' + ${lib.getExe pkgs.phpunit} "$@" + ''; + } + ); }; # nix run .#phpstan -- --version phpstan = { type = "app"; - program = lib.getExe (pkgs.writeShellApplication { - name = "phpstan"; - - runtimeInputs = [ - php - php.packages.phpstan - ]; - - text = '' - ${lib.getExe php.packages.phpstan} "$@" - ''; - }); + program = lib.getExe ( + pkgs.writeShellApplication { + name = "phpstan"; + + runtimeInputs = [ + php + php.packages.phpstan + ]; + + text = '' + ${lib.getExe php.packages.phpstan} "$@" + ''; + } + ); }; # nix run .#psalm -- --version psalm = { type = "app"; - program = lib.getExe (pkgs.writeShellApplication { - name = "psalm"; - - runtimeInputs = [ - php - php.packages.psalm - ]; - - text = '' - ${lib.getExe php.packages.psalm} "$@" - ''; - }); + program = lib.getExe ( + pkgs.writeShellApplication { + name = "psalm"; + + runtimeInputs = [ + php + php.packages.psalm + ]; + + text = '' + ${lib.getExe php.packages.psalm} "$@" + ''; + } + ); }; }; }; - }; - }; + }; }