Move quixos protocol to repository root
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
{
|
||||
description = "Shared Quixos protobuf protocol definitions";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
quixos-protocol = pkgs.stdenvNoCC.mkDerivation {
|
||||
pname = "quixos-protocol";
|
||||
version = "0.1.0";
|
||||
src = ./.;
|
||||
npmDeps = pkgs.importNpmLock { npmRoot = ./.; };
|
||||
npmConfigHook = pkgs.importNpmLock.npmConfigHook;
|
||||
nativeBuildInputs = [
|
||||
pkgs.importNpmLock.npmConfigHook
|
||||
pkgs.nodejs_24
|
||||
pkgs.protobuf
|
||||
];
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
export QUIXOS_PROTO_PATH="${pkgs.protobuf}/include:$PWD/proto''${QUIXOS_PROTO_PATH:+:$QUIXOS_PROTO_PATH}"
|
||||
npm run build
|
||||
runHook postBuild
|
||||
'';
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p "$out"
|
||||
cp --reflink=auto --recursive proto "$out/proto"
|
||||
cp --reflink=auto --recursive dist "$out/dist"
|
||||
cp package.json "$out/package.json"
|
||||
mkdir -p "$out/bin"
|
||||
cat > "$out/bin/quixos-descriptor-check" <<EOF
|
||||
#!/bin/sh
|
||||
export PATH="${pkgs.protobuf}/bin:\$PATH"
|
||||
export QUIXOS_PROTO_PATH="${pkgs.protobuf}/include:$out/proto\''${QUIXOS_PROTO_PATH:+:$QUIXOS_PROTO_PATH}"
|
||||
exec ${pkgs.nodejs_24}/bin/node "$out/dist/src/descriptor-check.js" "\$@"
|
||||
EOF
|
||||
chmod +x "$out/bin/quixos-descriptor-check"
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
in {
|
||||
packages.default = quixos-protocol;
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = [
|
||||
pkgs.nodejs_24
|
||||
pkgs.protobuf
|
||||
pkgs.typescript
|
||||
quixos-protocol
|
||||
];
|
||||
shellHook = ''
|
||||
if [ -n "''${PS1-}" ]; then
|
||||
if [ -n "''${QX_DEV_SHELL_PROMPT-}" ]; then
|
||||
PS1="''${PS1#\[qx:''${QX_DEV_SHELL_PROMPT}\] }"
|
||||
fi
|
||||
export QX_DEV_SHELL_PROMPT="quixos-protocol"
|
||||
PS1="[qx:quixos-protocol] $PS1"
|
||||
fi
|
||||
export QUIXOS_PROTO_PATH="${pkgs.protobuf}/include:$PWD/proto''${QUIXOS_PROTO_PATH:+:$QUIXOS_PROTO_PATH}"
|
||||
'';
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user