From 299caca4aac42d7639a42eb4dde951c010f6e91c Mon Sep 17 00:00:00 2001 From: Sander van der Burg Date: Wed, 2 Mar 2022 00:41:50 +0100 Subject: [PATCH] Filter the sources of development projects --- php-packages.nix | 2 +- src/Composer2Nix/Package.php | 2 +- src/Composer2Nix/composer-env.nix | 5 +++++ tests/dependencies/php-packages.nix | 2 +- tests/enduser/php-packages.nix | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/php-packages.nix b/php-packages.nix index 2cbe786..48cc20d 100644 --- a/php-packages.nix +++ b/php-packages.nix @@ -18,7 +18,7 @@ in composerEnv.buildPackage { inherit packages devPackages noDev; name = "svanderburg-composer2nix"; - src = ./.; + src = composerEnv.filterSrc ./.; executable = true; symlinkDependencies = false; meta = { diff --git a/src/Composer2Nix/Package.php b/src/Composer2Nix/Package.php index 51f5581..17db536 100644 --- a/src/Composer2Nix/Package.php +++ b/src/Composer2Nix/Package.php @@ -67,7 +67,7 @@ public function toNixAST() { return new NixFunInvocation(new NixExpression("composerEnv.buildPackage"), array( "name" => $this->composerConfig->packageName, - "src" => new NixFile("./."), + "src" => new NixFunInvocation(new NixExpression("composerEnv.filterSrc"), new NixFile("./.")), "executable" => $this->executable, "packages" => new NixInherit(), "devPackages" => new NixInherit(), diff --git a/src/Composer2Nix/composer-env.nix b/src/Composer2Nix/composer-env.nix index e1cffa8..71714b7 100644 --- a/src/Composer2Nix/composer-env.nix +++ b/src/Composer2Nix/composer-env.nix @@ -4,6 +4,10 @@ let inherit (phpPackages) composer; + + filterSrc = src: + builtins.filterSource (path: type: type != "directory" || (baseNameOf path != ".git" && baseNameOf path != ".git" && baseNameOf path != ".svn")) src; + buildZipPackage = { name, src }: stdenv.mkDerivation { inherit name src; @@ -233,6 +237,7 @@ let } // extraArgs); in { + inherit filterSrc; composer = lib.makeOverridable composer; buildZipPackage = lib.makeOverridable buildZipPackage; buildPackage = lib.makeOverridable buildPackage; diff --git a/tests/dependencies/php-packages.nix b/tests/dependencies/php-packages.nix index a093d04..6645b2a 100644 --- a/tests/dependencies/php-packages.nix +++ b/tests/dependencies/php-packages.nix @@ -377,7 +377,7 @@ in composerEnv.buildPackage { inherit packages devPackages noDev; name = "dependencies"; - src = ./.; + src = composerEnv.filterSrc ./.; executable = false; symlinkDependencies = false; meta = {}; diff --git a/tests/enduser/php-packages.nix b/tests/enduser/php-packages.nix index b83f881..c596e6a 100644 --- a/tests/enduser/php-packages.nix +++ b/tests/enduser/php-packages.nix @@ -348,7 +348,7 @@ in composerEnv.buildPackage { inherit packages devPackages noDev; name = "phpunit-phpunit"; - src = ./.; + src = composerEnv.filterSrc ./.; executable = true; symlinkDependencies = false; meta = {};