From 7433e1bfad5905f15622a9a79e4feada10dec794 Mon Sep 17 00:00:00 2001 From: Jason Odoom Date: Tue, 1 Aug 2023 18:57:01 -0400 Subject: [PATCH] Remove pkgs dir --- .../php/build-composer-project.nix | 61 ---------- .../php/build-composer-repository.nix | 79 ------------- pkgs/build-support/php/build-pecl.nix | 46 -------- .../php/composer-local-repo-plugin.nix | 111 ------------------ .../php/hooks/composer-install-hook.sh | 98 ---------------- .../php/hooks/composer-repository-hook.sh | 50 -------- pkgs/build-support/php/hooks/default.nix | 21 ---- .../tools/misc/composer/default.nix | 36 ------ 8 files changed, 502 deletions(-) delete mode 100644 pkgs/build-support/php/build-composer-project.nix delete mode 100644 pkgs/build-support/php/build-composer-repository.nix delete mode 100644 pkgs/build-support/php/build-pecl.nix delete mode 100644 pkgs/build-support/php/composer-local-repo-plugin.nix delete mode 100644 pkgs/build-support/php/hooks/composer-install-hook.sh delete mode 100644 pkgs/build-support/php/hooks/composer-repository-hook.sh delete mode 100644 pkgs/build-support/php/hooks/default.nix delete mode 100644 pkgs/development/tools/misc/composer/default.nix diff --git a/pkgs/build-support/php/build-composer-project.nix b/pkgs/build-support/php/build-composer-project.nix deleted file mode 100644 index 6b29bcaf..00000000 --- a/pkgs/build-support/php/build-composer-project.nix +++ /dev/null @@ -1,61 +0,0 @@ -{ stdenvNoCC, lib, writeTextDir, php, makeBinaryWrapper, fetchFromGitHub, fetchurl, composer-local-repo-plugin, mkComposerRepository, composerHooks }: - -let - buildComposerProjectOverride = finalAttrs: previousAttrs: - - let - phpDrv = finalAttrs.php or php; - composer = finalAttrs.composer or phpDrv.packages.composer; - composerLock = finalAttrs.composerLock or null; - in - { - nativeBuildInputs = (previousAttrs.nativeBuildInputs or [ ]) ++ [ - composer - composer-local-repo-plugin - composerHooks.composerInstallHook - ]; - - 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 - - runHook postConfigure - ''; - - buildPhase = previousAttrs.buildPhase or '' - runHook preBuild - - runHook postBuild - ''; - - doCheck = previousAttrs.doCheck or true; - checkPhase = previousAttrs.checkPhase or '' - runHook preCheck - - runHook postCheck - ''; - - installPhase = previousAttrs.installPhase or '' - runHook preInstall - - runHook postInstall - ''; - - composerRepository = mkComposerRepository { - inherit composer composer-local-repo-plugin composerLock; - inherit (finalAttrs) patches pname src vendorHash version; - }; - - meta = previousAttrs.meta or { } // { - platforms = lib.platforms.all; - }; - }; -in -args: (stdenvNoCC.mkDerivation args).overrideAttrs buildComposerProjectOverride diff --git a/pkgs/build-support/php/build-composer-repository.nix b/pkgs/build-support/php/build-composer-repository.nix deleted file mode 100644 index 257ed807..00000000 --- a/pkgs/build-support/php/build-composer-repository.nix +++ /dev/null @@ -1,79 +0,0 @@ -{ stdenvNoCC, lib, writeTextDir, fetchFromGitHub, php, composer-local-repo-plugin, composerHooks }: - -let - mkComposerRepositoryOverride = - /* - We cannot destruct finalAttrs since the attrset below is used to construct it - and Nix currently does not support lazy attribute names. - { - php ? null, - composer ? null, - composerLock ? "composer.lock", - src, - vendorHash, - ... - }@finalAttrs: - */ - finalAttrs: previousAttrs: - - let - phpDrv = finalAttrs.php or php; - composer = finalAttrs.composer or phpDrv.packages.composer; - in - assert (lib.assertMsg (previousAttrs ? src) "mkComposerRepository expects src 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."); - { - name = "${previousAttrs.pname}-${previousAttrs.version}-composer-repository"; - - # See https://github.com/NixOS/nix/issues/6660 - dontPatchShebangs = previousAttrs.dontPatchShebangs or true; - - nativeBuildInputs = (previousAttrs.nativeBuildInputs or [ ]) ++ [ - composer - composer-local-repo-plugin - composerHooks.composerRepositoryHook - ]; - - buildInputs = previousAttrs.buildInputs or [ ]; - - strictDeps = previousAttrs.strictDeps or true; - - # Should we keep these empty phases? - configurePhase = previousAttrs.configurePhase or '' - runHook preConfigure - - runHook postConfigure - ''; - - buildPhase = previousAttrs.buildPhase or '' - runHook preBuild - - runHook postBuild - ''; - - doCheck = previousAttrs.doCheck or true; - checkPhase = previousAttrs.checkPhase or '' - runHook preCheck - - runHook postCheck - ''; - - installPhase = previousAttrs.installPhase or '' - runHook preInstall - - runHook postInstall - ''; - - COMPOSER_CACHE_DIR = "/dev/null"; - COMPOSER_MIRROR_PATH_REPOS = "1"; - COMPOSER_HTACCESS_PROTECT = "0"; - COMPOSER_DISABLE_NETWORK = "0"; - - outputHashMode = "recursive"; - outputHashAlgo = if (finalAttrs ? vendorHash && finalAttrs.vendorHash != "") then null else "sha256"; - outputHash = finalAttrs.vendorHash or ""; - }; -in -args: (stdenvNoCC.mkDerivation args).overrideAttrs mkComposerRepositoryOverride diff --git a/pkgs/build-support/php/build-pecl.nix b/pkgs/build-support/php/build-pecl.nix deleted file mode 100644 index 389447e0..00000000 --- a/pkgs/build-support/php/build-pecl.nix +++ /dev/null @@ -1,46 +0,0 @@ -{ 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"; - inherit (args) sha256; - } -, passthru ? { } -, ... -}@args: - -stdenv.mkDerivation (args // { - name = "php-${pname}-${version}"; - extensionName = pname; - - inherit src; - - nativeBuildInputs = [ autoreconfHook re2c ] ++ nativeBuildInputs; - buildInputs = [ php ] ++ peclDeps ++ buildInputs; - - 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"; - - 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 {}; - }; -}) diff --git a/pkgs/build-support/php/composer-local-repo-plugin.nix b/pkgs/build-support/php/composer-local-repo-plugin.nix deleted file mode 100644 index c88e9149..00000000 --- a/pkgs/build-support/php/composer-local-repo-plugin.nix +++ /dev/null @@ -1,111 +0,0 @@ -{ stdenvNoCC, lib, fetchFromGitHub, composer, makeBinaryWrapper }: - -stdenvNoCC.mkDerivation (finalAttrs: -let - composerKeys = stdenvNoCC.mkDerivation (finalComposerKeysAttrs: { - pname = "composer-keys"; - version = "fa5a62092f33e094073fbda23bbfc7188df3cbc5"; - - src = fetchFromGitHub { - owner = "composer"; - repo = "composer.github.io"; - rev = "${finalComposerKeysAttrs.version}"; - hash = "sha256-3Sfn71LDG1jHwuEIU8iEnV3k6D6QTX7KVIKVaNSuCVE="; - }; - - installPhase = '' - runHook preInstall - - mkdir -p $out - install releases.pub $out/keys.tags.pub - install snapshots.pub $out/keys.dev.pub - - runHook postInstall - ''; - }); -in -{ - pname = "composer-local-repo-plugin"; - version = "ff33aaf5454888e2669f366639be9877dceb9599"; - - src = fetchFromGitHub { - owner = "drupol"; - repo = "composer-local-repo-plugin"; - rev = finalAttrs.version; - hash = "sha256-nSjAicyvStVoBFm7SJy4EYQIwrAaLjm72XMgsPF3CSg="; - }; - - COMPOSER_CACHE_DIR = "/dev/null"; - COMPOSER_MIRROR_PATH_REPOS = "1"; - COMPOSER_HTACCESS_PROTECT = "0"; - COMPOSER_DISABLE_NETWORK = "1"; - - nativeBuildInputs = [ - makeBinaryWrapper - ]; - - buildInputs = [ - composer - ]; - - configurePhase = '' - runHook preConfigure - - export COMPOSER_HOME=${placeholder "out"} - - runHook postConfigure - ''; - - buildPhase = '' - runHook preBuild - - # Configure composer globally - composer global init --quiet --no-interaction --no-ansi \ - --name="nixos/composer" \ - --homepage "https://nixos.org/" \ - --description "Composer with drupol/composer-local-repo-plugin" \ - --license "MIT" - - composer global config --quiet minimum-stability dev - composer global config --quiet prefer-stable true - composer global config --quiet autoloader-suffix "nixPredictableAutoloaderSuffix" - composer global config --quiet apcu-autoloader false - composer global config --quiet allow-plugins.drupol/composer-local-repo-plugin true - composer global config --quiet repo.packagist false - composer global config --quiet repo.plugin path $src - - # Install the local repository plugin - composer global require --quiet --no-ansi --no-interaction drupol/composer-local-repo-plugin - - runHook postBuild - ''; - - checkPhase = '' - runHook preCheck - - composer global validate --no-ansi - composer global show --no-ansi drupol/composer-local-repo-plugin - - runHook postCheck - ''; - - installPhase = '' - runHook preInstall - - mkdir -p $out - cp -ar ${composerKeys}/* $out/ - - makeWrapper ${composer}/bin/composer $out/bin/composer-local-repo-plugin \ - --prefix COMPOSER_HOME : $out - - runHook postInstall - ''; - - meta = { - description = "Composer local repo plugin for Composer"; - license = lib.licenses.mit; - homepage = "https://github.com/drupol/composer-local-repo-plugin"; - maintainers = lib.teams.php.members; - platforms = lib.platforms.all; - }; -}) diff --git a/pkgs/build-support/php/hooks/composer-install-hook.sh b/pkgs/build-support/php/hooks/composer-install-hook.sh deleted file mode 100644 index 69c9dfad..00000000 --- a/pkgs/build-support/php/hooks/composer-install-hook.sh +++ /dev/null @@ -1,98 +0,0 @@ -declare composerHomeDir -declare composerRepository -declare version - -preConfigureHooks+=(composerInstallConfigureHook) -preBuildHooks+=(composerInstallBuildHook) -preCheckHooks+=(composerInstallCheckHook) -preInstallHooks+=(composerInstallInstallHook) - -composerInstallConfigureHook() { - echo "Executing composerInstallConfigureHook" - - if [[ ! -e "${composerRepository}" ]]; then - echo "No local composer repository found." - exit 1 - fi - - if [[ -e "$composerLock" ]]; then - cp $composerLock composer.lock - fi - - if [[ ! -f "composer.lock" ]]; then - echo "No composer.lock file found" - exit 1 - fi - - chmod +w composer.json composer.lock - - echo "Finished composerInstallConfigureHook" -} - -composerInstallBuildHook() { - echo "Executing composerInstallBuildHook" - - # Since this file cannot be generated in the composer-repository-hook.sh - # because the file contains hardcoded nix store paths, we generate it here. - composer-local-repo-plugin --no-ansi build-local-repo -p ${composerRepository} > packages.json - - # Configure composer to disable packagist and avoid using the network. - composer config repo.packagist false - # Configure composer to use the local repository. - composer config repo.composer composer file://$PWD/packages.json - - # Since the composer.json file has been modified in the previous step, the - # composer.lock file needs to be updated. - COMPOSER_ROOT_VERSION="${version}" \ - composer \ - --lock \ - --no-ansi \ - --no-dev \ - --no-install \ - --no-interaction \ - --no-plugins \ - --no-scripts \ - update - - echo "Finished composerInstallBuildHook" -} - -composerInstallCheckHook() { - echo "Executing composerInstallCheckHook" - - composer validate --no-ansi --no-interaction - - echo "Finished composerInstallCheckHook" -} - -composerInstallInstallHook() { - echo "Executing composerInstallInstallHook" - - # Finally, run `composer install` to install the dependencies and generate - # the autoloader. - # The COMPOSER_ROOT_VERSION environment variable is needed only for - # vimeo/psalm. - COMPOSER_ROOT_VERSION="${version}" \ - COMPOSER_MIRROR_PATH_REPOS="1" \ - composer \ - --no-ansi \ - --no-dev \ - --no-interaction \ - --no-scripts \ - install - - # Remove packages.json, we don't need it in the store. - rm packages.json - - # Copy the relevant files only in the store. - mkdir -p $out/share/php/${pname} - cp -r . $out/share/php/${pname}/ - - # Create symlinks for the binaries. - jq -r -c 'try .bin[]' composer.json | while read bin; do - mkdir -p $out/share/php/${pname} $out/bin - ln -s $out/share/php/${pname}/$bin $out/bin/$(basename $bin) - done - - echo "Finished composerInstallInstallHook" -} diff --git a/pkgs/build-support/php/hooks/composer-repository-hook.sh b/pkgs/build-support/php/hooks/composer-repository-hook.sh deleted file mode 100644 index c7abb406..00000000 --- a/pkgs/build-support/php/hooks/composer-repository-hook.sh +++ /dev/null @@ -1,50 +0,0 @@ -declare composerHomeDir -declare composerLock -declare version - -preConfigureHooks+=(composerRepositoryConfigureHook) -preBuildHooks+=(composerRepositoryBuildHook) -preCheckHooks+=(composerRepositoryCheckHook) -preInstallHooks+=(composerRepositoryInstallHook) - -composerRepositoryConfigureHook() { - echo "Executing composerRepositoryConfigureHook" - - if [[ -e "$composerLock" ]]; then - cp $composerLock composer.lock - fi - - if [[ ! -f "composer.lock" ]]; then - echo "No composer.lock file found" - exit 1 - fi - - echo "Finished composerRepositoryConfigureHook" -} - -composerRepositoryBuildHook() { - echo "Executing composerRepositoryBuildHook" - - echo "Finished composerRepositoryBuildHook" -} - -composerRepositoryCheckHook() { - echo "Executing composerRepositoryCheckHook" - - composer validate --no-ansi --no-interaction --no-check-lock - - echo "Finished composerRepositoryCheckHook" -} - -composerRepositoryInstallHook() { - echo "Executing composerRepositoryInstallHook" - - mkdir -p $out - - # Build the local composer repository - # The command 'build-local-repo' is provided by the Composer plugin - # drupol/composer-local-repo-plugin. - composer-local-repo-plugin --no-ansi build-local-repo --no-dev -r $out - - echo "Finished composerRepositoryInstallHook" -} diff --git a/pkgs/build-support/php/hooks/default.nix b/pkgs/build-support/php/hooks/default.nix deleted file mode 100644 index 98198f01..00000000 --- a/pkgs/build-support/php/hooks/default.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ makeSetupHook -, php -, jq -, moreutils -}: - -{ - composerRepositoryHook = makeSetupHook - { - name = "composer-repository-hook.sh"; - propagatedBuildInputs = [ php jq moreutils ]; - substitutions = { }; - } ./composer-repository-hook.sh; - - composerInstallHook = makeSetupHook - { - name = "composer-install-hook.sh"; - propagatedBuildInputs = [ php jq moreutils ]; - substitutions = { }; - } ./composer-install-hook.sh; -} diff --git a/pkgs/development/tools/misc/composer/default.nix b/pkgs/development/tools/misc/composer/default.nix deleted file mode 100644 index 6667a8c0..00000000 --- a/pkgs/development/tools/misc/composer/default.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ lib, stdenvNoCC, fetchurl, php, unzip, _7zz, xz, git, curl, cacert, makeBinaryWrapper }: - -stdenvNoCC.mkDerivation (finalAttrs: { - pname = "composer-phar"; - version = "2.5.8"; - - src = fetchurl { - url = "https://github.com/composer/composer/releases/download/${finalAttrs.version}/composer.phar"; - hash = "sha256-8Hk0+tRPkEjA3IdaUGzKMcwnlNauv8GGfzsfv0jc4sU="; - }; - - dontUnpack = true; - - nativeBuildInputs = [ makeBinaryWrapper ]; - - installPhase = '' - runHook preInstall - - mkdir -p $out/bin - 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 ]} - - runHook postInstall - ''; - - meta = { - description = "Dependency Manager for PHP, shipped from the PHAR file"; - license = lib.licenses.mit; - homepage = "https://getcomposer.org/"; - changelog = "https://github.com/composer/composer/releases/tag/${finalAttrs.version}"; - maintainers = lib.teams.php.members; - platforms = lib.platforms.all; - }; -})