Project source-free capability contracts and keep exact source provenance in package assembly. Reuse compiled groups across unrelated graph and dependency implementation edits. Keep React public inputs separate from workspace query lowering and retain explicit type-companion dependencies. Allow independent execution-package checks, scope resource compilation to declared dependencies, and memoize source closure traversal. Document generic-specialization limits and measured Reader rebuild behavior. Verified protocol, artifact, package, React, and managed activation checks; retained-Git independent/workspace artifact equality and incompatible type dependency rejection; nix fmt -- --check and lint. One-off Reader measurements recompiled 1 of 13 groups for a child edit and 0 for a workspace QX default edit.
193 lines
10 KiB
Nix
193 lines
10 KiB
Nix
{
|
|
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
|
|
pkgs.util-linux
|
|
pkgs.nix
|
|
];
|
|
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
|
|
esbuild dist/src/execution-world/index.js --bundle --platform=node --target=node24 --format=esm --outfile=execution-world.mjs
|
|
esbuild dist/src/react-build/package-queries.js --bundle --platform=node --target=node24 --format=esm --outfile=react-query-generator.mjs
|
|
esbuild dist/src/bindings/client.js --bundle --platform=node --target=node24 --format=esm --outfile=client-codegen.mjs
|
|
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/bindings/portable-client-cli.js --bundle --platform=node --target=node24 --format=esm --outfile=quixos-codegen-client.mjs
|
|
esbuild dist/src/bindings/react-platform.js --bundle --platform=node --target=node24 --format=esm --outfile=react-platform.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
|
|
node dist/test/emit-portable-reader.js
|
|
node dist/test/emit-managed.js
|
|
runHook postCheck
|
|
'';
|
|
installPhase = ''
|
|
runHook preInstall
|
|
mkdir -p "$out"
|
|
install -Dm644 nix/checked-package.nix "$out/share/checked-package.nix"
|
|
install -Dm644 nix/checked-artifacts.nix "$out/share/checked-artifacts.nix"
|
|
install -Dm644 nix/package-context.nix "$out/share/package-context.nix"
|
|
install -Dm644 nix/package-context.mjs "$out/share/package-context.mjs"
|
|
install -Dm644 nix/check-package.mjs "$out/share/check-package.mjs"
|
|
install -Dm644 nix/check-execution.mjs "$out/share/check-execution.mjs"
|
|
substitute nix/checked-candidate.nix "$out/share/checked-candidate.nix" \
|
|
--replace-fail '@nixpkgs@' '${pkgs.path}'
|
|
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/share/quixos-protocol/qualification"
|
|
cp -r dist/portable-reader dist/managed "$out/share/quixos-protocol/qualification/"
|
|
mkdir -p "$out/bin"
|
|
for tool in quixos-codegen-ts quixos-codegen-client 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" <<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/libexec/quixos-protocol/quixos-descriptor-check.mjs" "\$@"
|
|
EOF
|
|
chmod +x "$out/bin/quixos-descriptor-check"
|
|
cat > "$out/bin/quixos-capability-compile" <<EOF
|
|
#!/bin/sh
|
|
exec ${pkgs.nodejs_24}/bin/node "$out/libexec/quixos-protocol/quixos-capability-compile.mjs" "\$@"
|
|
EOF
|
|
chmod +x "$out/bin/quixos-capability-compile"
|
|
cat > "$out/bin/quixos-workspace-compile" <<EOF
|
|
#!/bin/sh
|
|
exec ${pkgs.nodejs_24}/bin/node "$out/libexec/quixos-protocol/quixos-workspace-compile.mjs" "\$@"
|
|
EOF
|
|
chmod +x "$out/bin/quixos-workspace-compile"
|
|
cat > "$out/bin/quixos-resource-compile" <<EOF
|
|
#!/bin/sh
|
|
exec ${pkgs.nodejs_24}/bin/node "$out/libexec/quixos-protocol/quixos-resource-compile.mjs" "\$@"
|
|
EOF
|
|
chmod +x "$out/bin/quixos-resource-compile"
|
|
cat > "$out/bin/quixos-lock-check" <<EOF
|
|
#!/bin/sh
|
|
exec ${pkgs.nodejs_24}/bin/node "$out/libexec/quixos-protocol/quixos-lock-check.mjs" "\$@"
|
|
EOF
|
|
chmod +x "$out/bin/quixos-lock-check"
|
|
mkdir -p "$out/libexec/quixos-protocol"
|
|
install -m644 execution-world.mjs "$out/libexec/quixos-protocol/execution-world.mjs"
|
|
install -m644 react-query-generator.mjs "$out/libexec/quixos-protocol/react-query-generator.mjs"
|
|
install -m644 client-codegen.mjs "$out/libexec/quixos-protocol/client-codegen.mjs"
|
|
install -m644 react-platform.mjs "$out/libexec/quixos-protocol/react-platform.mjs"
|
|
install -m644 quixos-codegen-ts.mjs quixos-qx.mjs "$out/libexec/quixos-protocol/"
|
|
install -m644 quixos-codegen-client.mjs "$out/libexec/quixos-protocol/"
|
|
install -m644 quixos-descriptor-check.mjs "$out/libexec/quixos-protocol/quixos-descriptor-check.mjs"
|
|
install -m644 quixos-capability-compile.mjs "$out/libexec/quixos-protocol/quixos-capability-compile.mjs"
|
|
install -m644 quixos-workspace-compile.mjs "$out/libexec/quixos-protocol/quixos-workspace-compile.mjs"
|
|
install -m644 quixos-resource-compile.mjs "$out/libexec/quixos-protocol/quixos-resource-compile.mjs"
|
|
install -m644 quixos-lock-check.mjs "$out/libexec/quixos-protocol/quixos-lock-check.mjs"
|
|
runHook postInstall
|
|
'';
|
|
};
|
|
};
|
|
in
|
|
{
|
|
packages.default = quixos-protocol;
|
|
packages.inspector = (pkgs.callPackage ./yarn-project.nix { inherit nodejs; }) {
|
|
src = pkgs.lib.fileset.toSource {
|
|
root = ./.;
|
|
fileset = pkgs.lib.fileset.unions [
|
|
./package.json
|
|
./yarn.lock
|
|
./.yarnrc.yml
|
|
./.yarn/plugins
|
|
./src
|
|
];
|
|
};
|
|
overrideAttrs = old: {
|
|
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.esbuild ];
|
|
doCheck = false;
|
|
buildPhase = ''
|
|
esbuild src/capability-language/inspect-cli.ts --bundle --platform=node --target=node24 --format=esm --outfile=inspect.mjs
|
|
'';
|
|
installPhase = ''
|
|
mkdir -p "$out/bin" "$out/lib"
|
|
cp inspect.mjs "$out/lib/inspect.mjs"
|
|
printf '#!${pkgs.runtimeShell}\nexec ${nodejs}/bin/node --max-old-space-size=128 %s/lib/inspect.mjs\n' "$out" > "$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}"
|
|
'';
|
|
};
|
|
}
|
|
);
|
|
}
|