workflows/check-nix-format: enforce for build-support/php
This commit is contained in:
parent
c759efa5e7
commit
75ae762133
7 changed files with 229 additions and 143 deletions
1
.github/workflows/check-nix-format.yml
vendored
1
.github/workflows/check-nix-format.yml
vendored
|
@ -40,6 +40,7 @@ jobs:
|
|||
pkgs/top-level/cuda-packages.nix
|
||||
NIX_FMT_PATHS_VSCODE_EXTS: pkgs/applications/editors/vscode/extensions
|
||||
NIX_FMT_PATHS_PHP_PACKAGES: pkgs/development/php-packages
|
||||
NIX_FMT_PATHS_BUILD_SUPPORT_PHP: pkgs/build-support/php
|
||||
# Iterate over all environment variables beginning with NIX_FMT_PATHS_.
|
||||
run: |
|
||||
for env_var in "${!NIX_FMT_PATHS_@}"; do
|
||||
|
|
|
@ -1,7 +1,17 @@
|
|||
{ callPackage, stdenvNoCC, lib, writeTextDir, php, makeBinaryWrapper, fetchFromGitHub, fetchurl }:
|
||||
{
|
||||
callPackage,
|
||||
stdenvNoCC,
|
||||
lib,
|
||||
writeTextDir,
|
||||
php,
|
||||
makeBinaryWrapper,
|
||||
fetchFromGitHub,
|
||||
fetchurl,
|
||||
}:
|
||||
|
||||
let
|
||||
buildComposerProjectOverride = finalAttrs: previousAttrs:
|
||||
buildComposerProjectOverride =
|
||||
finalAttrs: previousAttrs:
|
||||
|
||||
let
|
||||
phpDrv = finalAttrs.php or php;
|
||||
|
@ -22,49 +32,58 @@ let
|
|||
phpDrv.composerHooks.composerInstallHook
|
||||
];
|
||||
|
||||
buildInputs = (previousAttrs.buildInputs or [ ]) ++ [
|
||||
phpDrv
|
||||
];
|
||||
buildInputs = (previousAttrs.buildInputs or [ ]) ++ [ phpDrv ];
|
||||
|
||||
patches = previousAttrs.patches or [ ];
|
||||
strictDeps = previousAttrs.strictDeps or true;
|
||||
|
||||
# Should we keep these empty phases?
|
||||
configurePhase = previousAttrs.configurePhase or ''
|
||||
runHook preConfigure
|
||||
configurePhase =
|
||||
previousAttrs.configurePhase or ''
|
||||
runHook preConfigure
|
||||
|
||||
runHook postConfigure
|
||||
'';
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
buildPhase = previousAttrs.buildPhase or ''
|
||||
runHook preBuild
|
||||
buildPhase =
|
||||
previousAttrs.buildPhase or ''
|
||||
runHook preBuild
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
doCheck = previousAttrs.doCheck or true;
|
||||
checkPhase = previousAttrs.checkPhase or ''
|
||||
runHook preCheck
|
||||
checkPhase =
|
||||
previousAttrs.checkPhase or ''
|
||||
runHook preCheck
|
||||
|
||||
runHook postCheck
|
||||
'';
|
||||
runHook postCheck
|
||||
'';
|
||||
|
||||
installPhase = previousAttrs.installPhase or ''
|
||||
runHook preInstall
|
||||
installPhase =
|
||||
previousAttrs.installPhase or ''
|
||||
runHook preInstall
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
doInstallCheck = previousAttrs.doInstallCheck or false;
|
||||
installCheckPhase = previousAttrs.installCheckPhase or ''
|
||||
runHook preInstallCheck
|
||||
installCheckPhase =
|
||||
previousAttrs.installCheckPhase or ''
|
||||
runHook preInstallCheck
|
||||
|
||||
runHook postInstallCheck
|
||||
'';
|
||||
runHook postInstallCheck
|
||||
'';
|
||||
|
||||
composerRepository = phpDrv.mkComposerRepository {
|
||||
inherit composer composer-local-repo-plugin;
|
||||
inherit (finalAttrs) patches pname src vendorHash version;
|
||||
inherit (finalAttrs)
|
||||
patches
|
||||
pname
|
||||
src
|
||||
vendorHash
|
||||
version
|
||||
;
|
||||
|
||||
composerLock = previousAttrs.composerLock or null;
|
||||
composerNoDev = previousAttrs.composerNoDev or true;
|
||||
|
@ -73,9 +92,9 @@ let
|
|||
composerStrictValidation = previousAttrs.composerStrictValidation or true;
|
||||
};
|
||||
|
||||
COMPOSER_CACHE_DIR="/dev/null";
|
||||
COMPOSER_DISABLE_NETWORK="1";
|
||||
COMPOSER_MIRROR_PATH_REPOS="1";
|
||||
COMPOSER_CACHE_DIR = "/dev/null";
|
||||
COMPOSER_DISABLE_NETWORK = "1";
|
||||
COMPOSER_MIRROR_PATH_REPOS = "1";
|
||||
|
||||
meta = previousAttrs.meta or { } // {
|
||||
platforms = lib.platforms.all;
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
{ callPackage, stdenvNoCC, lib, writeTextDir, fetchFromGitHub, php }:
|
||||
{
|
||||
callPackage,
|
||||
stdenvNoCC,
|
||||
lib,
|
||||
writeTextDir,
|
||||
fetchFromGitHub,
|
||||
php,
|
||||
}:
|
||||
|
||||
let
|
||||
mkComposerRepositoryOverride =
|
||||
|
@ -22,12 +29,24 @@ let
|
|||
composer-local-repo-plugin = callPackage ./pkgs/composer-local-repo-plugin.nix { };
|
||||
in
|
||||
assert (lib.assertMsg (previousAttrs ? src) "mkComposerRepository expects src argument.");
|
||||
assert (lib.assertMsg (previousAttrs ? vendorHash) "mkComposerRepository expects vendorHash argument.");
|
||||
assert (
|
||||
lib.assertMsg (previousAttrs ? vendorHash) "mkComposerRepository expects vendorHash argument."
|
||||
);
|
||||
assert (lib.assertMsg (previousAttrs ? version) "mkComposerRepository expects version argument.");
|
||||
assert (lib.assertMsg (previousAttrs ? pname) "mkComposerRepository expects pname argument.");
|
||||
assert (lib.assertMsg (previousAttrs ? composerNoDev) "mkComposerRepository expects composerNoDev argument.");
|
||||
assert (lib.assertMsg (previousAttrs ? composerNoPlugins) "mkComposerRepository expects composerNoPlugins argument.");
|
||||
assert (lib.assertMsg (previousAttrs ? composerNoScripts) "mkComposerRepository expects composerNoScripts argument.");
|
||||
assert (
|
||||
lib.assertMsg (previousAttrs ? composerNoDev) "mkComposerRepository expects composerNoDev argument."
|
||||
);
|
||||
assert (
|
||||
lib.assertMsg (
|
||||
previousAttrs ? composerNoPlugins
|
||||
) "mkComposerRepository expects composerNoPlugins argument."
|
||||
);
|
||||
assert (
|
||||
lib.assertMsg (
|
||||
previousAttrs ? composerNoScripts
|
||||
) "mkComposerRepository expects composerNoScripts argument."
|
||||
);
|
||||
{
|
||||
composerNoDev = previousAttrs.composerNoDev or true;
|
||||
composerNoPlugins = previousAttrs.composerNoPlugins or true;
|
||||
|
@ -51,37 +70,42 @@ let
|
|||
strictDeps = previousAttrs.strictDeps or true;
|
||||
|
||||
# Should we keep these empty phases?
|
||||
configurePhase = previousAttrs.configurePhase or ''
|
||||
runHook preConfigure
|
||||
configurePhase =
|
||||
previousAttrs.configurePhase or ''
|
||||
runHook preConfigure
|
||||
|
||||
runHook postConfigure
|
||||
'';
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
buildPhase = previousAttrs.buildPhase or ''
|
||||
runHook preBuild
|
||||
buildPhase =
|
||||
previousAttrs.buildPhase or ''
|
||||
runHook preBuild
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
doCheck = previousAttrs.doCheck or true;
|
||||
checkPhase = previousAttrs.checkPhase or ''
|
||||
runHook preCheck
|
||||
checkPhase =
|
||||
previousAttrs.checkPhase or ''
|
||||
runHook preCheck
|
||||
|
||||
runHook postCheck
|
||||
'';
|
||||
runHook postCheck
|
||||
'';
|
||||
|
||||
installPhase = previousAttrs.installPhase or ''
|
||||
runHook preInstall
|
||||
installPhase =
|
||||
previousAttrs.installPhase or ''
|
||||
runHook preInstall
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
doInstallCheck = previousAttrs.doInstallCheck or false;
|
||||
installCheckPhase = previousAttrs.installCheckPhase or ''
|
||||
runHook preInstallCheck
|
||||
installCheckPhase =
|
||||
previousAttrs.installCheckPhase or ''
|
||||
runHook preInstallCheck
|
||||
|
||||
runHook postInstallCheck
|
||||
'';
|
||||
runHook postInstallCheck
|
||||
'';
|
||||
|
||||
COMPOSER_CACHE_DIR = "/dev/null";
|
||||
COMPOSER_MIRROR_PATH_REPOS = "1";
|
||||
|
@ -89,7 +113,8 @@ let
|
|||
COMPOSER_DISABLE_NETWORK = "0";
|
||||
|
||||
outputHashMode = "recursive";
|
||||
outputHashAlgo = if (finalAttrs ? vendorHash && finalAttrs.vendorHash != "") then null else "sha256";
|
||||
outputHashAlgo =
|
||||
if (finalAttrs ? vendorHash && finalAttrs.vendorHash != "") then null else "sha256";
|
||||
outputHash = finalAttrs.vendorHash or "";
|
||||
};
|
||||
in
|
||||
|
|
|
@ -1,45 +1,69 @@
|
|||
{ stdenv, lib, php, autoreconfHook, fetchurl, re2c, nix-update-script }:
|
||||
{
|
||||
stdenv,
|
||||
lib,
|
||||
php,
|
||||
autoreconfHook,
|
||||
fetchurl,
|
||||
re2c,
|
||||
nix-update-script,
|
||||
}:
|
||||
|
||||
{ pname
|
||||
, version
|
||||
, internalDeps ? [ ]
|
||||
, peclDeps ? [ ]
|
||||
, buildInputs ? [ ]
|
||||
, nativeBuildInputs ? [ ]
|
||||
, postPhpize ? ""
|
||||
, makeFlags ? [ ]
|
||||
, src ? fetchurl ({
|
||||
url = "https://pecl.php.net/get/${pname}-${version}.tgz";
|
||||
} // lib.filterAttrs (attrName: _: lib.elem attrName [ "sha256" "hash" ]) args)
|
||||
, passthru ? { }
|
||||
, ...
|
||||
{
|
||||
pname,
|
||||
version,
|
||||
internalDeps ? [ ],
|
||||
peclDeps ? [ ],
|
||||
buildInputs ? [ ],
|
||||
nativeBuildInputs ? [ ],
|
||||
postPhpize ? "",
|
||||
makeFlags ? [ ],
|
||||
src ? fetchurl (
|
||||
{
|
||||
url = "https://pecl.php.net/get/${pname}-${version}.tgz";
|
||||
}
|
||||
// lib.filterAttrs (
|
||||
attrName: _:
|
||||
lib.elem attrName [
|
||||
"sha256"
|
||||
"hash"
|
||||
]
|
||||
) args
|
||||
),
|
||||
passthru ? { },
|
||||
...
|
||||
}@args:
|
||||
|
||||
stdenv.mkDerivation (args // {
|
||||
name = "php-${pname}-${version}";
|
||||
extensionName = pname;
|
||||
stdenv.mkDerivation (
|
||||
args
|
||||
// {
|
||||
name = "php-${pname}-${version}";
|
||||
extensionName = pname;
|
||||
|
||||
inherit src;
|
||||
inherit src;
|
||||
|
||||
nativeBuildInputs = [ autoreconfHook re2c ] ++ nativeBuildInputs;
|
||||
buildInputs = [ php ] ++ peclDeps ++ buildInputs;
|
||||
nativeBuildInputs = [
|
||||
autoreconfHook
|
||||
re2c
|
||||
] ++ nativeBuildInputs;
|
||||
buildInputs = [ php ] ++ peclDeps ++ buildInputs;
|
||||
|
||||
makeFlags = [ "EXTENSION_DIR=$(out)/lib/php/extensions" ] ++ makeFlags;
|
||||
makeFlags = [ "EXTENSION_DIR=$(out)/lib/php/extensions" ] ++ makeFlags;
|
||||
|
||||
autoreconfPhase = ''
|
||||
phpize
|
||||
${postPhpize}
|
||||
${lib.concatMapStringsSep "\n"
|
||||
(dep: "mkdir -p ext; ln -s ${dep.dev}/include ext/${dep.extensionName}")
|
||||
internalDeps}
|
||||
'';
|
||||
checkPhase = "NO_INTERACTON=yes make test";
|
||||
autoreconfPhase = ''
|
||||
phpize
|
||||
${postPhpize}
|
||||
${lib.concatMapStringsSep "\n" (
|
||||
dep: "mkdir -p ext; ln -s ${dep.dev}/include ext/${dep.extensionName}"
|
||||
) internalDeps}
|
||||
'';
|
||||
checkPhase = "NO_INTERACTON=yes make test";
|
||||
|
||||
passthru = passthru // {
|
||||
# Thes flags were introduced for `nix-update` so that it can update
|
||||
# PHP extensions correctly.
|
||||
# See the corresponding PR: https://github.com/Mic92/nix-update/pull/123
|
||||
isPhpExtension = true;
|
||||
updateScript = nix-update-script {};
|
||||
};
|
||||
})
|
||||
passthru = passthru // {
|
||||
# Thes flags were introduced for `nix-update` so that it can update
|
||||
# PHP extensions correctly.
|
||||
# See the corresponding PR: https://github.com/Mic92/nix-update/pull/123
|
||||
isPhpExtension = true;
|
||||
updateScript = nix-update-script { };
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
{ lib
|
||||
, makeSetupHook
|
||||
, diffutils
|
||||
, jq
|
||||
, writeShellApplication
|
||||
, moreutils
|
||||
, cacert
|
||||
, buildPackages
|
||||
{
|
||||
lib,
|
||||
makeSetupHook,
|
||||
diffutils,
|
||||
jq,
|
||||
writeShellApplication,
|
||||
moreutils,
|
||||
cacert,
|
||||
buildPackages,
|
||||
}:
|
||||
|
||||
let
|
||||
|
@ -16,24 +17,30 @@ let
|
|||
};
|
||||
in
|
||||
{
|
||||
composerRepositoryHook = makeSetupHook
|
||||
{
|
||||
name = "composer-repository-hook.sh";
|
||||
propagatedBuildInputs = [ jq moreutils cacert ];
|
||||
substitutions = {
|
||||
phpScriptUtils = lib.getExe php-script-utils;
|
||||
};
|
||||
} ./composer-repository-hook.sh;
|
||||
composerRepositoryHook = makeSetupHook {
|
||||
name = "composer-repository-hook.sh";
|
||||
propagatedBuildInputs = [
|
||||
jq
|
||||
moreutils
|
||||
cacert
|
||||
];
|
||||
substitutions = {
|
||||
phpScriptUtils = lib.getExe php-script-utils;
|
||||
};
|
||||
} ./composer-repository-hook.sh;
|
||||
|
||||
composerInstallHook = makeSetupHook
|
||||
{
|
||||
name = "composer-install-hook.sh";
|
||||
propagatedBuildInputs = [ jq moreutils cacert ];
|
||||
substitutions = {
|
||||
# Specify the stdenv's `diff` by abspath to ensure that the user's build
|
||||
# inputs do not cause us to find the wrong `diff`.
|
||||
cmp = "${lib.getBin buildPackages.diffutils}/bin/cmp";
|
||||
phpScriptUtils = lib.getExe php-script-utils;
|
||||
};
|
||||
} ./composer-install-hook.sh;
|
||||
composerInstallHook = makeSetupHook {
|
||||
name = "composer-install-hook.sh";
|
||||
propagatedBuildInputs = [
|
||||
jq
|
||||
moreutils
|
||||
cacert
|
||||
];
|
||||
substitutions = {
|
||||
# Specify the stdenv's `diff` by abspath to ensure that the user's build
|
||||
# inputs do not cause us to find the wrong `diff`.
|
||||
cmp = "${lib.getBin buildPackages.diffutils}/bin/cmp";
|
||||
phpScriptUtils = lib.getExe php-script-utils;
|
||||
};
|
||||
} ./composer-install-hook.sh;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
{ php, callPackage, stdenvNoCC, lib, fetchFromGitHub, makeBinaryWrapper }:
|
||||
{
|
||||
php,
|
||||
callPackage,
|
||||
stdenvNoCC,
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
makeBinaryWrapper,
|
||||
}:
|
||||
|
||||
let
|
||||
composer = callPackage ./composer-phar.nix {
|
||||
inherit (php.packages.composer) version pharHash;
|
||||
};
|
||||
composer = callPackage ./composer-phar.nix { inherit (php.packages.composer) version pharHash; };
|
||||
|
||||
composerKeys = stdenvNoCC.mkDerivation (finalComposerKeysAttrs: {
|
||||
pname = "composer-keys";
|
||||
|
@ -43,13 +48,9 @@ stdenvNoCC.mkDerivation (finalAttrs: {
|
|||
COMPOSER_HTACCESS_PROTECT = "0";
|
||||
COMPOSER_DISABLE_NETWORK = "1";
|
||||
|
||||
nativeBuildInputs = [
|
||||
makeBinaryWrapper
|
||||
];
|
||||
nativeBuildInputs = [ makeBinaryWrapper ];
|
||||
|
||||
buildInputs = [
|
||||
composer
|
||||
];
|
||||
buildInputs = [ composer ];
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
{
|
||||
_7zz
|
||||
, cacert
|
||||
, curl
|
||||
, fetchurl
|
||||
, git
|
||||
, lib
|
||||
, makeBinaryWrapper
|
||||
, php
|
||||
, stdenvNoCC
|
||||
, unzip
|
||||
, xz
|
||||
, version
|
||||
, pharHash
|
||||
_7zz,
|
||||
cacert,
|
||||
curl,
|
||||
fetchurl,
|
||||
git,
|
||||
lib,
|
||||
makeBinaryWrapper,
|
||||
php,
|
||||
stdenvNoCC,
|
||||
unzip,
|
||||
xz,
|
||||
version,
|
||||
pharHash,
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
|
@ -34,7 +34,16 @@ stdenvNoCC.mkDerivation (finalAttrs: {
|
|||
install -D $src $out/libexec/composer/composer.phar
|
||||
makeWrapper ${php}/bin/php $out/bin/composer \
|
||||
--add-flags "$out/libexec/composer/composer.phar" \
|
||||
--prefix PATH : ${lib.makeBinPath [ _7zz cacert curl git unzip xz ]}
|
||||
--prefix PATH : ${
|
||||
lib.makeBinPath [
|
||||
_7zz
|
||||
cacert
|
||||
curl
|
||||
git
|
||||
unzip
|
||||
xz
|
||||
]
|
||||
}
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
|
Loading…
Reference in a new issue