refactor: nix flake

This commit is contained in:
2025-04-17 20:49:51 -04:00
parent 1c7cf7966f
commit 24d3067e52

View File

@ -66,7 +66,18 @@
} }
); );
in { in {
devShells = forSystem ({pkgs, ...}: { devShells = forSystem ({pkgs, ...}: let
protoc-gen-connect-openapi = pkgs.buildGoModule {
name = "protoc-gen-connect-openapi";
src = pkgs.fetchFromGitHub {
owner = "sudorandom";
repo = "protoc-gen-connect-openapi";
rev = "v0.16.1";
sha256 = "sha256-3XBQCc9H9N/AZm/8J5bJRgBhVtoZKFvbdTB+glHxYdA=";
};
vendorHash = "sha256-CIiG/XhV8xxjYY0sZcSvIFcJ1Wh8LyDDwqem2cSSwBA=";
};
in {
default = pkgs.mkShell { default = pkgs.mkShell {
packages = with pkgs; packages = with pkgs;
[ [
@ -91,16 +102,7 @@
protoc-gen-go protoc-gen-go
protoc-gen-connect-go protoc-gen-connect-go
protoc-gen-es protoc-gen-es
(buildGoModule { protoc-gen-connect-openapi
name = "protoc-gen-connect-openapi";
src = pkgs.fetchFromGitHub {
owner = "sudorandom";
repo = "protoc-gen-connect-openapi";
rev = "v0.16.1";
sha256 = "sha256-3XBQCc9H9N/AZm/8J5bJRgBhVtoZKFvbdTB+glHxYdA=";
};
vendorHash = "sha256-CIiG/XhV8xxjYY0sZcSvIFcJ1Wh8LyDDwqem2cSSwBA=";
})
# Client # Client
nodejs_22 nodejs_22
@ -175,6 +177,16 @@
packages = forSystem ( packages = forSystem (
{pkgs, ...}: let {pkgs, ...}: let
client = pkgs.buildNpmPackage {
inherit pname version;
src = ./client;
npmDepsHash = "sha256-u7zkBgaxDEB2XFrNl0f7/HtW0Oy2B7FVPot9MLPzXGc=";
installPhase = ''
cp -r build "$out"
'';
};
server = pkgs.buildGoModule { server = pkgs.buildGoModule {
inherit client pname version; inherit client pname version;
src = ./server; src = ./server;
@ -185,16 +197,6 @@
cp -r ${client} client cp -r ${client} client
''; '';
}; };
client = pkgs.buildNpmPackage {
pname = "${pname}-client";
inherit version;
src = ./client;
npmDepsHash = "sha256-u7zkBgaxDEB2XFrNl0f7/HtW0Oy2B7FVPot9MLPzXGc=";
installPhase = ''
cp -r build "$out"
'';
};
in in
{ {
default = server; default = server;
@ -202,23 +204,25 @@
// builtins.listToAttrs (builtins.map (x: { // builtins.listToAttrs (builtins.map (x: {
name = "${pname}-${x.GOOS}-${x.GOARCH}"; name = "${pname}-${x.GOOS}-${x.GOARCH}";
value = server.overrideAttrs { value = server.overrideAttrs {
nativeBuildInputs = server.nativeBuildInputs ++ [ nativeBuildInputs =
server.nativeBuildInputs
++ [
pkgs.rename pkgs.rename
]; ];
env.CGO_ENABLED = 0; env.CGO_ENABLED = 0;
env.GOOS = x.GOOS; env.GOOS = x.GOOS;
env.GOARCH = x.GOARCH; env.GOARCH = x.GOARCH;
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
mkdir -p $out/bin mkdir -p $out/bin
find $GOPATH/bin -type f -exec mv -t $out/bin {} + find $GOPATH/bin -type f -exec mv -t $out/bin {} +
rename 's/(.+\/)(.+?)(\.[^.]*$|$)/$1${pname}-${x.GOOS}-${x.GOARCH}-${version}$3/' $out/bin/* rename 's/(.+\/)(.+?)(\.[^.]*$|$)/$1${pname}-${x.GOOS}-${x.GOARCH}-${version}$3/' $out/bin/*
runHook postInstall runHook postInstall
''; '';
}; };
}) })
host-systems) host-systems)
); );