-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
/
build-composer-project.nix
108 lines (88 loc) · 2.99 KB
/
build-composer-project.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{
nix-update-script,
stdenvNoCC,
lib,
php,
}:
let
buildComposerProjectOverride =
finalAttrs: previousAttrs:
let
phpDrv = finalAttrs.php or php;
composer = finalAttrs.composer or phpDrv.packages.composer-local-repo-plugin;
in
{
composerLock = previousAttrs.composerLock or null;
composerNoDev = previousAttrs.composerNoDev or true;
composerNoPlugins = previousAttrs.composerNoPlugins or true;
composerNoScripts = previousAttrs.composerNoScripts or true;
composerStrictValidation = previousAttrs.composerStrictValidation or true;
nativeBuildInputs = (previousAttrs.nativeBuildInputs or [ ]) ++ [
composer
phpDrv
phpDrv.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
'';
doInstallCheck = previousAttrs.doInstallCheck or false;
installCheckPhase =
previousAttrs.installCheckPhase or ''
runHook preInstallCheck
runHook postInstallCheck
'';
composerRepository =
previousAttrs.composerRepository or (phpDrv.mkComposerRepository {
inherit composer;
inherit (finalAttrs)
patches
pname
src
vendorHash
version
;
composerLock = previousAttrs.composerLock or null;
composerNoDev = previousAttrs.composerNoDev or true;
composerNoPlugins = previousAttrs.composerNoPlugins or true;
composerNoScripts = previousAttrs.composerNoScripts or true;
composerStrictValidation = previousAttrs.composerStrictValidation or true;
});
# Projects providing a lockfile from upstream can be automatically updated.
passthru = previousAttrs.passthru or { } // {
updateScript =
previousAttrs.passthru.updateScript
or (if finalAttrs.composerRepository.composerLock == null then nix-update-script { } else null);
};
env = {
COMPOSER_CACHE_DIR = "/dev/null";
COMPOSER_DISABLE_NETWORK = "1";
COMPOSER_MIRROR_PATH_REPOS = "1";
};
meta = previousAttrs.meta or { } // {
platforms = lib.platforms.all;
};
};
in
args: (stdenvNoCC.mkDerivation args).overrideAttrs buildComposerProjectOverride