{ 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; }; nodejs = pkgs.nodejs_24; quixos-protocol = (pkgs.callPackage ./yarn-project.nix { inherit nodejs; }) { src = pkgs.lib.cleanSource ./.; overrideAttrs = old: { nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.diffutils pkgs.esbuild pkgs.protobuf pkgs.git pkgs.jujutsu pkgs.gnutar ]; buildPhase = '' runHook preBuild mkdir -p "$TMPDIR/generated-before" cp --recursive src/gen "$TMPDIR/generated-before/proto" cp --recursive src/capability-language/generated "$TMPDIR/generated-before/capability" cp --recursive src/resource-lock/generated "$TMPDIR/generated-before/lock" export QUIXOS_PROTO_PATH="${pkgs.protobuf}/include:$PWD/proto''${QUIXOS_PROTO_PATH:+:$QUIXOS_PROTO_PATH}" patchShebangs node_modules/.bin node_modules/@bufbuild/protoc-gen-es/bin yarn build diff --recursive --unified "$TMPDIR/generated-before/proto" src/gen diff --recursive --unified "$TMPDIR/generated-before/capability" src/capability-language/generated diff --recursive --unified "$TMPDIR/generated-before/lock" src/resource-lock/generated esbuild dist/src/descriptor-check.js \ --bundle --platform=node --target=node24 --format=esm \ --outfile=quixos-descriptor-check.mjs esbuild dist/src/capability-language/cli.js \ --bundle --platform=node --target=node24 --format=esm \ --outfile=quixos-capability-compile.mjs esbuild dist/src/capability-language/workspace-cli.js \ --bundle --platform=node --target=node24 --format=esm \ --outfile=quixos-workspace-compile.mjs esbuild dist/src/capability-language/resource-cli.js \ --bundle --platform=node --target=node24 --format=esm \ --outfile=quixos-resource-compile.mjs esbuild dist/src/resource-lock/cli.js \ --bundle --platform=node --target=node24 --format=esm \ --outfile=quixos-lock-check.mjs esbuild dist/src/bindings/cli.js --bundle --platform=node --target=node24 --format=esm --outfile=quixos-codegen-ts.mjs esbuild dist/src/capability-language/tool-cli.js --bundle --platform=node --target=node24 --format=esm --outfile=quixos-qx.mjs runHook postBuild ''; doCheck = true; checkPhase = '' runHook preCheck yarn test runHook postCheck ''; installPhase = '' runHook preInstall mkdir -p "$out" install -Dm644 nix/checked-package.nix "$out/share/checked-package.nix" cp --reflink=auto --recursive grammar "$out/grammar" cp --reflink=auto --recursive proto "$out/proto" cp --reflink=auto --recursive dist "$out/dist" cp package.json "$out/package.json" mkdir -p "$out/bin" for tool in quixos-codegen-ts quixos-qx; do printf '#!/bin/sh\nexec ${pkgs.nodejs_24}/bin/node "%s/libexec/quixos-protocol/%s.mjs" "$@"\n' "$out" "$tool" > "$out/bin/$tool" chmod +x "$out/bin/$tool" done cat > "$out/bin/quixos-descriptor-check" < "$out/bin/quixos-capability-compile" < "$out/bin/quixos-workspace-compile" < "$out/bin/quixos-resource-compile" < "$out/bin/quixos-lock-check" < "$out/bin/quixos-qx-inspect" chmod +x "$out/bin/quixos-qx-inspect" ''; }; }; checks.default = quixos-protocol; devShells.default = pkgs.mkShell { packages = [ nodejs pkgs.protobuf quixos-protocol.yarn-freestanding 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}" ''; }; }); }