Skip to content

Commit 3e41b56

Browse files
committed
new strategy to build
1 parent 529ddd3 commit 3e41b56

1 file changed

Lines changed: 17 additions & 25 deletions

File tree

flake.nix

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,19 @@
33
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
44
flake-utils.url = "github:numtide/flake-utils";
55
};
6-
7-
outputs =
8-
{
9-
self,
10-
nixpkgs,
11-
flake-utils,
12-
}:
6+
outputs = { self, nixpkgs, flake-utils }:
137
flake-utils.lib.eachDefaultSystem (
148
system:
159
let
1610
pkgs = nixpkgs.legacyPackages.${system};
17-
1811
buildPkgs = with pkgs; [
1912
pkg-config
2013
templ
2114
scdoc
2215
go
2316
tailwindcss_4
17+
zig # Add Zig
2418
];
25-
2619
devPkgs = with pkgs; [
2720
just
2821
air
@@ -32,33 +25,39 @@
3225
hivemind
3326
watchman
3427
];
35-
36-
mkPolybase =
37-
os:
28+
mkPolybase = os:
3829
pkgs.buildGoModule {
3930
pname = "polybase";
4031
version = "0.1.0";
4132
src = ./.;
4233
vendorHash = "sha256-l5RNYoXMVAUeI96lTO0who2uje3IrlycD2GpCDFX3F0=";
43-
4434
nativeBuildInputs = buildPkgs;
45-
35+
4636
postPatch = ''
4737
tailwindcss -i static/css/main.css -o static/css/styles.css -m
4838
templ generate
4939
'';
50-
40+
41+
preBuild = ''
42+
export CGO_ENABLED=1
43+
export GOOS=${os}
44+
export GOARCH=amd64
45+
46+
export CC="zig cc -target x86_64-${os}"
47+
export CXX="zig c++ -target x86_64-${os}"
48+
'';
49+
5150
buildPhase = ''
5251
go test ./tests/...
53-
54-
export GOOS=${os} GOARCH=amd64 CGO_ENABLED=0
52+
5553
mkdir -p bin
5654
go build -o bin/polybased ./polybased
5755
go build -o bin/polybase ./polybase
56+
5857
scdoc < polybase.1.scd | sed "s/1980-01-01/$(date '+%B %Y')/" > polybase.1
5958
scdoc < polybased.1.scd | sed "s/1980-01-01/$(date '+%B %Y')/" > polybased.1
6059
'';
61-
60+
6261
installPhase = ''
6362
mkdir -p $out/dist/{usr/local/bin,usr/local/man/man1,etc/rc.d}
6463
cp bin/polybased bin/polybase $out/dist/usr/local/bin/
@@ -71,25 +70,19 @@
7170
{
7271
packages = {
7372
default = mkPolybase "openbsd";
74-
7573
docker = pkgs.dockerTools.buildImage {
7674
name = "polybase";
7775
tag = "latest";
78-
7976
extraCommands = ''
8077
mkdir -p var/lib/polybase var/log/polybase etc/polybase
81-
8278
find ${./.}/migrations -name "*.sql" | \
8379
sort -n | \
8480
xargs cat | \
8581
${pkgs.sqlite}/bin/sqlite3 var/lib/polybase/polybase.db
86-
8782
chmod 755 var/lib/polybase var/log/polybase
8883
chmod 644 var/lib/polybase/polybase.db
89-
9084
touch etc/polybase/polybase.cfg
9185
'';
92-
9386
config = {
9487
Cmd = [ "${mkPolybase "linux"}/dist/usr/local/bin/polybased" ];
9588
ExposedPorts = {
@@ -101,7 +94,6 @@
10194
};
10295
};
10396
};
104-
10597
devShell = pkgs.mkShell {
10698
nativeBuildInputs = buildPkgs;
10799
buildInputs = devPkgs;

0 commit comments

Comments
 (0)