Skip to content

Commit

Permalink
build: update nix flake (#4998)
Browse files Browse the repository at this point in the history
- update lock file
- improve npm client package using `pkgs.buildNpmPackage`
- improve windmill package
  • Loading branch information
uael authored Jan 3, 2025
1 parent 2832b88 commit 0ee7c9e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 39 deletions.
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 43 additions & 33 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
];
};
buildInputs = with pkgs; [
openssl openssl.dev libxml2.dev xmlsec.dev libxslt.dev
openssl openssl.dev libxml2.dev xmlsec.dev libxslt.dev libtool
rust nodejs
postgresql
pkg-config cmake
Expand All @@ -30,6 +30,21 @@
xmlsec.dev
libxslt.dev
]);
RUSTY_V8_ARCHIVE =
let
version = "130.0.1";
target = pkgs.hostPlatform.rust.rustcTarget;
sha256 = {
x86_64-linux = "sha256-qc25H3Aj2KRhsAZ+2SD1c4RmweVK07oW71opZXRuUoc=";
aarch64-linux = "sha256-qc25H3Aj2KRhsAZ+2SD1c4RmweVK07oW71opZXRuUoc=";
x86_64-darwin = pkgs.lib.fakeHash;
aarch64-darwin = "sha256-d1QTLt8gOUFxACes4oyIYgDF/srLOEk+5p5Oj1ECajQ=";
}.${system};
in pkgs.fetchurl {
name = "librusty_v8-${version}";
url = "https://github.com/denoland/rusty_v8/releases/download/v${version}/librusty_v8_release_${target}.a.gz";
inherit sha256;
};
in {
devShell = pkgs.mkShell {
buildInputs = buildInputs ++ (with pkgs; [
Expand All @@ -45,7 +60,6 @@
'')
(pkgs.writeScriptBin "wm-build" ''
cd ./frontend
echo $(pwd)
npm install
npm run ${if pkgs.stdenv.isDarwin then "generate-backend-client-mac" else "generate-backend-client"}
npm run build $*
Expand Down Expand Up @@ -74,7 +88,7 @@
'')
];

inherit PKG_CONFIG_PATH;
inherit PKG_CONFIG_PATH RUSTY_V8_ARCHIVE;
NODE_ENV = "development";
NODE_OPTIONS = "--max-old-space-size=16384";
DATABASE_URL = "postgres://postgres:[email protected]:5432/";
Expand All @@ -90,33 +104,41 @@
CARGO_PATH = "${rust}/bin/cargo";
};
packages.default = self.packages.${system}.windmill;
packages.windmill-client = pkgs.stdenv.mkDerivation {
pname = "windmill-client";
packages.windmill-client = pkgs.buildNpmPackage {
name = "windmill-client";
version = (pkgs.lib.strings.trim (builtins.readFile ./version.txt));

src = pkgs.nix-gitignore.gitignoreSource [] ./frontend;
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ nodejs pixman cairo pango ];
doCheck = false;

src = ./.;
buildInputs = with pkgs; [ nodejs ];
npmDepsHash = "sha256-NXk9mnf74+/k0i3goqU8Zi/jr5b/bmW+HWRLJCI2CX8=";
npmBuild = "npm run build";

buildPhase = ''
export HOME=$(pwd)
npm config set strict-ssl false
cd frontend
npm install --verbose
postUnpack = ''
mkdir -p ./backend/windmill-api/
cp ${./backend/windmill-api/openapi.yaml} ./backend/windmill-api/openapi.yaml
cp ${./openflow.openapi.yaml} ./openflow.openapi.yaml
'';
preBuild = ''
npm run ${if pkgs.stdenv.isDarwin then "generate-backend-client-mac" else "generate-backend-client"}
NODE_OPTIONS="--max-old-space-size=8192" npm run build
'';

installPhase = ''
mkdir -p $out/build
cp -r build $out/build
cp -r build $out
'';

NODE_OPTIONS = "--max-old-space-size=8192";
};
packages.windmill = pkgs.rustPlatform.buildRustPackage {
pname = "windmill";
version = (pkgs.lib.strings.trim (builtins.readFile ./version.txt));

src = ./backend;
nativeBuildInputs = buildInputs;
nativeBuildInputs = buildInputs ++ [ self.packages.${system}.windmill-client pkgs.perl ];


cargoLock = {
lockFile = ./backend/Cargo.lock;
Expand All @@ -128,28 +150,16 @@
};

buildFeatures = [
"embedding" "parquet" "openidconnect" "jemalloc" "deno_core" "license" "http_trigger" "zip" "oauth2" "dind"
"php" "mysql" "mssql" "bigquery" "websocket" "python" "smtp" "csharp" "rust"
"enterprise" "enterprise_saml" "stripe" "embedding" "parquet" "prometheus"
"openidconnect" "cloud" "jemalloc" "tantivy" "deno_core" "license" "http_trigger"
"zip" "oauth2" "kafka" "otel" "dind" "php" "mysql" "mssql" "bigquery" "websocket"
"python" "smtp" "csharp" "static_frontend" "rust"
];
doCheck = false;

inherit PKG_CONFIG_PATH;
inherit PKG_CONFIG_PATH RUSTY_V8_ARCHIVE;
SQLX_OFFLINE = true;
RUSTY_V8_ARCHIVE =
let
version = "130.0.1";
target = pkgs.hostPlatform.rust.rustcTarget;
sha256 = {
x86_64-linux = pkgs.lib.fakeHash;
aarch64-linux = pkgs.lib.fakeHash;
x86_64-darwin = pkgs.lib.fakeHash;
aarch64-darwin = "sha256-d1QTLt8gOUFxACes4oyIYgDF/srLOEk+5p5Oj1ECajQ=";
}.${system};
in pkgs.fetchurl {
name = "librusty_v8-${version}";
url = "https://github.com/denoland/rusty_v8/releases/download/v${version}/librusty_v8_release_${target}.a.gz";
inherit sha256;
};
FRONTEND_BUILD_DIR = "${self.packages.${system}.windmill-client}/build";
};
});
}

0 comments on commit 0ee7c9e

Please sign in to comment.