|
1 | 1 | { lib |
2 | 2 | , buildGoModule |
| 3 | +, callPackage |
3 | 4 | , fetchFromGitHub |
4 | 5 | , nixosTests |
5 | 6 | , caddy |
@@ -74,75 +75,7 @@ buildGoModule { |
74 | 75 | package = caddy; |
75 | 76 | }; |
76 | 77 | }; |
77 | | - withPlugins = |
78 | | - { plugins |
79 | | - , hash ? lib.fakeHash |
80 | | - }: caddy.overrideAttrs (finalAttrs: prevAttrs: |
81 | | - let |
82 | | - pluginsSorted = builtins.sort builtins.lessThan plugins; |
83 | | - pluginsList = lib.concatMapStrings (plugin: "${plugin}-") pluginsSorted; |
84 | | - pluginsHash = builtins.hashString "md5" pluginsList; |
85 | | - pluginsWithoutVersion = builtins.filter (p: !lib.hasInfix "@" p) pluginsSorted; |
86 | | - in |
87 | | - assert lib.assertMsg (builtins.length pluginsWithoutVersion == 0) |
88 | | - "All plugins should have a version (eg ${builtins.elemAt pluginsWithoutVersion 0}@x.y.z)!"; |
89 | | - { |
90 | | - vendorHash = null; |
91 | | - subPackages = [ "." ]; |
92 | | - |
93 | | - src = stdenv.mkDerivation { |
94 | | - pname = "caddy-src-with-plugins-${pluginsHash}"; |
95 | | - version = finalAttrs.version; |
96 | | - |
97 | | - nativeBuildInputs = [ |
98 | | - go |
99 | | - xcaddy |
100 | | - cacert |
101 | | - git |
102 | | - ]; |
103 | | - dontUnpack = true; |
104 | | - buildPhase = |
105 | | - let |
106 | | - withArgs = lib.concatMapStrings (plugin: "--with ${plugin} ") pluginsSorted; |
107 | | - in |
108 | | - '' |
109 | | - export GOCACHE=$TMPDIR/go-cache |
110 | | - export GOPATH="$TMPDIR/go" |
111 | | - XCADDY_SKIP_BUILD=1 TMPDIR="$PWD" xcaddy build v${finalAttrs.version} ${withArgs} |
112 | | - (cd buildenv* && go mod vendor) |
113 | | - ''; |
114 | | - installPhase = '' |
115 | | - mv buildenv* $out |
116 | | - ''; |
117 | | - |
118 | | - outputHashMode = "recursive"; |
119 | | - outputHash = hash; |
120 | | - outputHashAlgo = "sha256"; |
121 | | - }; |
122 | | - |
123 | | - |
124 | | - doInstallCheck = true; |
125 | | - installCheckPhase = '' |
126 | | - runHook preInstallCheck |
127 | | -
|
128 | | - ${lib.toShellVar "notfound" pluginsSorted} |
129 | | - while read kind module version; do |
130 | | - [[ "$kind" = "dep" ]] || continue |
131 | | - module="''${module}@''${version}" |
132 | | - for i in "''${!notfound[@]}"; do |
133 | | - if [[ ''${notfound[i]} = ''${module} ]]; then |
134 | | - unset 'notfound[i]' |
135 | | - fi |
136 | | - done |
137 | | - done < <($out/bin/caddy build-info) |
138 | | - if (( ''${#notfound[@]} )); then |
139 | | - >&2 echo "Plugins not found: ''${notfound[@]}" |
140 | | - exit 1 |
141 | | - fi |
142 | | -
|
143 | | - runHook postInstallCheck |
144 | | - ''; |
145 | | - }); |
| 78 | + withPlugins = callPackage ./plugins.nix { inherit caddy; }; |
146 | 79 | }; |
147 | 80 |
|
148 | 81 | meta = with lib; { |
|
0 commit comments