|
1 | 1 | { sources ? import ./nix/sources.nix # managed by https://github.com/nmattia/niv |
2 | 2 | , nixpkgs ? sources.nixpkgs |
3 | 3 | , pkgs ? import nixpkgs { |
4 | | - overlays = [ |
5 | | - # gomod2nix must be imported as a nixpkgs overlay |
6 | | - (import (sources.gomod2nix+"/overlay.nix")) |
7 | | - ]; |
| 4 | + overlays = [ |
| 5 | + # gomod2nix must be imported as a nixpkgs overlay |
| 6 | + (import (sources.gomod2nix+"/overlay.nix")) |
| 7 | + ]; |
8 | 8 | } |
9 | | -, meta ? pkgs.lib.importJSON ./nix/meta.json |
10 | | -, dockerName ? "docker.stackable.tech/sandbox/${meta.operator.name}" |
11 | | -, dockerTag ? null |
12 | | -}: |
13 | | -rec { |
14 | | - cargo = import ./Cargo.nix { |
| 9 | +, cargo ? import ./Cargo.nix { |
15 | 10 | inherit nixpkgs pkgs; release = false; |
16 | 11 | defaultCrateOverrides = pkgs.defaultCrateOverrides // { |
17 | | - prost-build = attrs: { |
18 | | - buildInputs = [ pkgs.protobuf ]; |
19 | | - }; |
20 | | - tonic-reflection = attrs: { |
21 | | - buildInputs = [ pkgs.rustfmt ]; |
22 | | - }; |
23 | | - stackable-secret-operator = attrs: { |
24 | | - buildInputs = [ pkgs.protobuf pkgs.rustfmt ]; |
25 | | - }; |
26 | | - krb5-sys = attrs: { |
27 | | - nativeBuildInputs = [ pkgs.pkg-config ]; |
28 | | - buildInputs = [ (pkgs.enableDebugging pkgs.krb5) ]; |
29 | | - LIBCLANG_PATH = "${pkgs.libclang.lib}/lib"; |
30 | | - BINDGEN_EXTRA_CLANG_ARGS = "-I${pkgs.glibc.dev}/include -I${pkgs.clang.cc.lib}/lib/clang/${pkgs.lib.getVersion pkgs.clang.cc}/include"; |
31 | | - }; |
32 | 12 | stackable-cockpit-web = attrs: { |
33 | 13 | nativeBuildInputs = [ pkgs.nodePackages.yarn pkgs.nodejs ]; |
34 | 14 | preConfigure = |
|
60 | 40 | SWAGGER_UI_DOWNLOAD_URL = "file:///invalid-path/swagger-ui.zip"; |
61 | 41 | }; |
62 | 42 | }; |
63 | | - }; |
| 43 | + } |
| 44 | +, meta ? pkgs.lib.importJSON ./nix/meta.json |
| 45 | +, dockerName ? "docker.stackable.tech/sandbox/${meta.operator.name}" |
| 46 | +, dockerTag ? null |
| 47 | +, web ? js2nix.buildEnv { |
| 48 | + # js2nix doesn't import peer dependencies, so we use overlays to patch them in explicitly |
| 49 | + # https://github.com/canva-public/js2nix/blob/d37912f6cc824e7f41bea7a481af1739ca195c8f/docs/usage.md#overriding |
| 50 | + package-json = ./web/package.json; |
| 51 | + yarn-lock = ./yarn.lock; |
| 52 | + overlays = [ |
| 53 | + (self: super: { |
| 54 | + # TODO: remove once this https://github.com/canva-public/js2nix/issues/20 is resolved |
| 55 | + buildNodeModule = pkgs.lib.makeOverridable |
| 56 | + (args: (super.buildNodeModule args).override { doCheck = false; }); |
| 57 | + }) |
| 58 | + ]; |
| 59 | + } |
| 60 | +, goHelmWrapper ? pkgs.buildGoApplication { |
| 61 | + pname = "go-helm-wrapper"; |
| 62 | + version = "0.0"; |
| 63 | + src = pkgs.runCommand "go-helm-wrapper-src" {} |
| 64 | + '' |
| 65 | + mkdir $out |
| 66 | + cp ${./go.mod} $out/go.mod |
| 67 | + cp ${./go.sum} $out/go.sum |
| 68 | + cp -r ${./rust/helm-sys/go-helm-wrapper} $out/go-helm-wrapper |
| 69 | + ''; |
| 70 | + pwd = ./rust/helm-sys/go-helm-wrapper; |
| 71 | + modules = ./gomod2nix.toml; |
| 72 | + ldflags = "-buildmode c-archive"; |
| 73 | + allowGoReference = true; |
| 74 | + postBuild = |
| 75 | + '' |
| 76 | + for pkg in $(getGoDirs ""); do |
| 77 | + buildFlags="-buildmode c-archive -o $GOPATH/bin/libgo-helm-wrapper.a" buildGoDir build "$pkg" |
| 78 | + done |
| 79 | + ''; |
| 80 | + } |
| 81 | +, js2nix ? pkgs.callPackage sources.js2nix { nodejs = pkgs.nodejs-18_x; } |
| 82 | +, gomod2nix ? pkgs.callPackage sources.gomod2nix {} |
| 83 | +}: |
| 84 | +rec { |
| 85 | + inherit cargo sources pkgs meta; |
64 | 86 | build = cargo.workspaceMembers.stackable-cockpitd.build.override { |
65 | 87 | features = [ "ui" ]; |
66 | 88 | }; |
@@ -117,45 +139,9 @@ rec { |
117 | 139 |
|
118 | 140 | # need to use vendored crate2nix because of https://github.com/kolloch/crate2nix/issues/264 |
119 | 141 | crate2nix = import sources.crate2nix {}; |
120 | | - js2nix = pkgs.callPackage sources.js2nix { nodejs = pkgs.nodejs-18_x; }; |
121 | | - gomod2nix = pkgs.callPackage sources.gomod2nix {}; |
122 | 142 | tilt = pkgs.tilt; |
123 | 143 |
|
124 | | - web = js2nix.buildEnv { |
125 | | - # js2nix doesn't import peer dependencies, so we use overlays to patch them in explicitly |
126 | | - # https://github.com/canva-public/js2nix/blob/d37912f6cc824e7f41bea7a481af1739ca195c8f/docs/usage.md#overriding |
127 | | - package-json = ./web/package.json; |
128 | | - yarn-lock = ./yarn.lock; |
129 | | - overlays = [ |
130 | | - (self: super: { |
131 | | - # TODO: remove once this https://github.com/canva-public/js2nix/issues/20 is resolved |
132 | | - buildNodeModule = pkgs.lib.makeOverridable |
133 | | - (args: (super.buildNodeModule args).override { doCheck = false; }); |
134 | | - }) |
135 | | - ]; |
136 | | - }; |
137 | 144 |
|
138 | | - goHelmWrapper = pkgs.buildGoApplication { |
139 | | - pname = "go-helm-wrapper"; |
140 | | - version = "0.0"; |
141 | | - src = pkgs.runCommand "go-helm-wrapper-src" {} |
142 | | - '' |
143 | | - mkdir $out |
144 | | - cp ${./go.mod} $out/go.mod |
145 | | - cp ${./go.sum} $out/go.sum |
146 | | - cp -r ${./rust/helm-sys/go-helm-wrapper} $out/go-helm-wrapper |
147 | | - ''; |
148 | | - pwd = ./rust/helm-sys/go-helm-wrapper; |
149 | | - modules = ./gomod2nix.toml; |
150 | | - ldflags = "-buildmode c-archive"; |
151 | | - allowGoReference = true; |
152 | | - postBuild = |
153 | | - '' |
154 | | - for pkg in $(getGoDirs ""); do |
155 | | - buildFlags="-buildmode c-archive -o $GOPATH/bin/libgo-helm-wrapper.a" buildGoDir build "$pkg" |
156 | | - done |
157 | | - ''; |
158 | | - }; |
159 | 145 |
|
160 | 146 | regenerateNixLockfiles = pkgs.writeScriptBin "regenerate-nix-lockfiles" |
161 | 147 | '' |
|
0 commit comments