Skip to content

Commit 6b1b801

Browse files
committed
chore(nix): Formatting
1 parent 8084c18 commit 6b1b801

File tree

1 file changed

+72
-59
lines changed

1 file changed

+72
-59
lines changed

default.nix

Lines changed: 72 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1-
{ sources ? import ./nix/sources.nix # managed by https://github.com/nmattia/niv
2-
, nixpkgs ? sources.nixpkgs
3-
, pkgs ? import nixpkgs {
1+
{
2+
sources ? import ./nix/sources.nix, # managed by https://github.com/nmattia/niv
3+
nixpkgs ? sources.nixpkgs,
4+
pkgs ? import nixpkgs {
45
overlays = [
56
# gomod2nix must be imported as a nixpkgs overlay
6-
(import (sources.gomod2nix+"/overlay.nix"))
7+
(import (sources.gomod2nix + "/overlay.nix"))
78
];
8-
}
9-
, release ? true
10-
, cargo ? import ./Cargo.nix {
9+
},
10+
release ? true,
11+
cargo ? import ./Cargo.nix {
1112
inherit nixpkgs pkgs release;
1213
defaultCrateOverrides = pkgs.defaultCrateOverrides // {
1314
stackable-cockpit-web = attrs: {
14-
nativeBuildInputs = [ pkgs.nodePackages.yarn pkgs.nodejs_20 ];
15-
preConfigure =
16-
''
17-
[[ ! -e node_modules ]] || rm -r node_modules
18-
ln -s ${web.nodeModules} node_modules
19-
'';
15+
nativeBuildInputs = [
16+
pkgs.nodePackages.yarn
17+
pkgs.nodejs_20
18+
];
19+
preConfigure = ''
20+
[[ ! -e node_modules ]] || rm -r node_modules
21+
ln -s ${web.nodeModules} node_modules
22+
'';
2023
};
2124
helm-sys = attrs: {
2225
GO_HELM_WRAPPER = goHelmWrapper + "/bin";
@@ -26,60 +29,66 @@
2629
utoipa-swagger-ui = attrs: rec {
2730
# utoipa-swagger-ui tries to redownload swagger-ui, which is blocked by Nix's sandboxing
2831
# so we download it instead, and tell it to use that
29-
SWAGGER_UI_DOWNLOAD_URL = "file://${pkgs.fetchurl {
30-
url = "https://github.com/swagger-api/swagger-ui/archive/refs/tags/v5.17.3.zip";
31-
hash = "sha256-zrb8feuuDzt/g6y7Tucfh+Y2BWZov0soyNPR5LBqKx4=";
32-
}}";
32+
SWAGGER_UI_DOWNLOAD_URL = "file://${
33+
pkgs.fetchurl {
34+
url = "https://github.com/swagger-api/swagger-ui/archive/refs/tags/v5.17.3.zip";
35+
hash = "sha256-zrb8feuuDzt/g6y7Tucfh+Y2BWZov0soyNPR5LBqKx4=";
36+
}
37+
}";
3338
};
3439
};
35-
}
36-
, meta ? pkgs.lib.importJSON ./nix/meta.json
37-
, dockerName ? "oci.stackable.tech/sandbox/${meta.operator.name}"
38-
, dockerTag ? null
39-
, web ? js2nix.buildEnv {
40+
},
41+
meta ? pkgs.lib.importJSON ./nix/meta.json,
42+
dockerName ? "oci.stackable.tech/sandbox/${meta.operator.name}",
43+
dockerTag ? null,
44+
web ? js2nix.buildEnv {
4045
# js2nix doesn't import peer dependencies, so we use overlays to patch them in explicitly
4146
# https://github.com/canva-public/js2nix/blob/d37912f6cc824e7f41bea7a481af1739ca195c8f/docs/usage.md#overriding
4247
package-json = ./web/package.json;
4348
yarn-lock = ./yarn.lock;
4449
overlays = [
4550
(self: super: {
4651
# TODO: remove once this https://github.com/canva-public/js2nix/issues/20 is resolved
47-
buildNodeModule = pkgs.lib.makeOverridable
48-
(args: (super.buildNodeModule args).override { doCheck = false; });
52+
buildNodeModule = pkgs.lib.makeOverridable (
53+
args: (super.buildNodeModule args).override { doCheck = false; }
54+
);
4955
})
5056
];
51-
}
52-
, goHelmWrapper ? pkgs.buildGoApplication {
57+
},
58+
goHelmWrapper ? pkgs.buildGoApplication {
5359
go = pkgs.go_1_26;
5460
pname = "go-helm-wrapper";
5561
version = "0.0";
56-
src = pkgs.runCommand "go-helm-wrapper-src" {}
57-
''
58-
mkdir $out
59-
cp ${./go.mod} $out/go.mod
60-
cp ${./go.sum} $out/go.sum
61-
cp -r ${./rust/helm-sys/go-helm-wrapper} $out/go-helm-wrapper
62-
'';
62+
src = pkgs.runCommand "go-helm-wrapper-src" { } ''
63+
mkdir $out
64+
cp ${./go.mod} $out/go.mod
65+
cp ${./go.sum} $out/go.sum
66+
cp -r ${./rust/helm-sys/go-helm-wrapper} $out/go-helm-wrapper
67+
'';
6368
pwd = ./rust/helm-sys/go-helm-wrapper;
6469
modules = ./gomod2nix.toml;
6570
ldflags = "-buildmode c-archive";
6671
allowGoReference = true;
67-
postBuild =
68-
''
69-
for pkg in $(getGoDirs ""); do
70-
buildFlags="-buildmode c-archive -o $GOPATH/bin/libgo-helm-wrapper.a" buildGoDir build "$pkg"
71-
done
72-
'';
73-
}
74-
, js2nix ? pkgs.callPackage sources.js2nix { nodejs = pkgs.nodejs_20; }
75-
, gomod2nix ? pkgs.callPackage sources.gomod2nix {}
72+
postBuild = ''
73+
for pkg in $(getGoDirs ""); do
74+
buildFlags="-buildmode c-archive -o $GOPATH/bin/libgo-helm-wrapper.a" buildGoDir build "$pkg"
75+
done
76+
'';
77+
},
78+
js2nix ? pkgs.callPackage sources.js2nix { nodejs = pkgs.nodejs_20; },
79+
gomod2nix ? pkgs.callPackage sources.gomod2nix { },
7680
}:
7781
rec {
78-
inherit cargo sources pkgs meta;
82+
inherit
83+
cargo
84+
sources
85+
pkgs
86+
meta
87+
;
7988
build = cargo.workspaceMembers.stackable-cockpitd.build.override {
8089
features = [ "ui" ];
8190
};
82-
entrypoint = build+"/bin/stackable-cockpitd";
91+
entrypoint = build + "/bin/stackable-cockpitd";
8392
# crds = pkgs.runCommand "${meta.operator.name}-crds.yaml" {}
8493
# ''
8594
# ${entrypoint} crd > $out
@@ -90,7 +99,9 @@ rec {
9099
tag = dockerTag;
91100
contents = [
92101
# Common debugging tools
93-
pkgs.bashInteractive pkgs.coreutils pkgs.util-linuxMinimal
102+
pkgs.bashInteractive
103+
pkgs.coreutils
104+
pkgs.util-linuxMinimal
94105
# Kerberos 5 must be installed globally to load plugins correctly
95106
pkgs.krb5
96107
# Make the whole cargo workspace available on $PATH
@@ -102,9 +113,14 @@ rec {
102113
fileRefVars = {
103114
PRODUCT_CONFIG = deploy/config-spec/properties.yaml;
104115
};
105-
in pkgs.lib.concatLists (pkgs.lib.mapAttrsToList (env: path: pkgs.lib.optional (pkgs.lib.pathExists path) "${env}=${path}") fileRefVars);
116+
in
117+
pkgs.lib.concatLists (
118+
pkgs.lib.mapAttrsToList (
119+
env: path: pkgs.lib.optional (pkgs.lib.pathExists path) "${env}=${path}"
120+
) fileRefVars
121+
);
106122
Entrypoint = [ entrypoint ];
107-
Cmd = [];
123+
Cmd = [ ];
108124
};
109125
};
110126
docker = pkgs.linkFarm "stackable-cockpit-docker" [
@@ -131,18 +147,15 @@ rec {
131147
];
132148

133149
# need to use vendored crate2nix because of https://github.com/kolloch/crate2nix/issues/264
134-
crate2nix = import sources.crate2nix {};
150+
crate2nix = import sources.crate2nix { };
135151
tilt = pkgs.tilt;
136152

137-
138-
139-
regenerateNixLockfiles = pkgs.writeScriptBin "regenerate-nix-lockfiles"
140-
''
141-
#!/usr/bin/env bash
142-
set -euo pipefail
143-
echo Running crate2nix
144-
${crate2nix}/bin/crate2nix generate
145-
echo Running gomod2nix
146-
${gomod2nix}/bin/gomod2nix
147-
'';
153+
regenerateNixLockfiles = pkgs.writeScriptBin "regenerate-nix-lockfiles" ''
154+
#!/usr/bin/env bash
155+
set -euo pipefail
156+
echo Running crate2nix
157+
${crate2nix}/bin/crate2nix generate
158+
echo Running gomod2nix
159+
${gomod2nix}/bin/gomod2nix
160+
'';
148161
}

0 commit comments

Comments
 (0)