init 2
This commit is contained in:
86
flake.nix
86
flake.nix
@ -6,7 +6,7 @@
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { nixpkgs, flake-utils, ... }@inputs:
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
@ -32,14 +32,15 @@
|
||||
go
|
||||
gotools
|
||||
gopls
|
||||
goreleaser
|
||||
air
|
||||
|
||||
# Protobuf middleware
|
||||
buf
|
||||
protoc-gen-go
|
||||
protoc-gen-connect-go
|
||||
protoc-gen-es
|
||||
protoc-gen-connect-openapi
|
||||
inotify-tools
|
||||
|
||||
# Svelte frontend
|
||||
nodejs_22
|
||||
@ -50,7 +51,20 @@
|
||||
|
||||
text = ''
|
||||
gitroot=$(git rev-parse --show-toplevel)
|
||||
(cd "''${gitroot}" && air) & (cd "''${gitroot}" && npm run dev) && fg
|
||||
|
||||
(cd "''${gitroot}/server" && air) &
|
||||
P1=$!
|
||||
|
||||
(cd "''${gitroot}/client" && npm run dev) &
|
||||
P2=$!
|
||||
|
||||
protobufwatch &
|
||||
P3=$!
|
||||
|
||||
trap 'kill $P1 $P2 $P3' SIGINT SIGTERM
|
||||
wait $P1
|
||||
wait $P2
|
||||
wait $P3
|
||||
'';
|
||||
})
|
||||
|
||||
@ -59,20 +73,80 @@
|
||||
|
||||
text = ''
|
||||
gitroot=$(git rev-parse --show-toplevel)
|
||||
(cd "''${gitroot}" && npm run build) && (cd "''${gitroot}" && go build -o ./build_server/golte .)
|
||||
|
||||
cd "''${gitroot}"
|
||||
buf lint
|
||||
buf generate
|
||||
|
||||
cd "''${gitroot}/client"
|
||||
npm run build
|
||||
cp -r build ../server/client
|
||||
|
||||
cd "''${gitroot}/server"
|
||||
go build -o ../build/trevstack .
|
||||
'';
|
||||
})
|
||||
|
||||
(writeShellApplication {
|
||||
name = "gen";
|
||||
name = "protobufwatch";
|
||||
|
||||
text = ''
|
||||
gitroot=$(git rev-parse --show-toplevel)
|
||||
(cd "''${gitroot}" && buf generate)
|
||||
|
||||
cd "''${gitroot}"
|
||||
inotifywait -mre close_write,moved_to,create proto | while read -r _ _ basename;
|
||||
do
|
||||
echo "file changed: $basename"
|
||||
buf lint
|
||||
buf generate
|
||||
echo "regenerated proto services"
|
||||
done
|
||||
'';
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
packages.default = pkgs.stdenv.mkDerivation {
|
||||
pname = "trevstack";
|
||||
version = "1.0";
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
# Go backend
|
||||
go
|
||||
gotools
|
||||
gopls
|
||||
|
||||
# Protobuf middleware
|
||||
buf
|
||||
protoc-gen-go
|
||||
protoc-gen-connect-go
|
||||
protoc-gen-es
|
||||
protoc-gen-connect-openapi
|
||||
|
||||
# Svelte frontend
|
||||
nodejs_22
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
gitroot=$(git rev-parse --show-toplevel)
|
||||
|
||||
cd "''${gitroot}"
|
||||
buf lint
|
||||
buf generate
|
||||
|
||||
cd "''${gitroot}/client"
|
||||
npm run build
|
||||
cp -r build ../server/client
|
||||
|
||||
cd "''${gitroot}/server"
|
||||
go build -o ../build/trevstack .
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp build/trevstack $out/bin
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user