mirror of
https://github.com/Fission-AI/OpenSpec.git
synced 2026-10-02 05:24:34 +08:00
* feat(nix): expose openspec as a consumable overlay
Refactor the flake so the package derivation is defined once, in
`overlays.default`, and every other output consumes it. Previously the
derivation lived inline in `packages.default`, so anyone who wanted
`openspec` in their own package set had to copy the derivation rather than
import it.
What changed:
- Add `overlays.default`, a standard `final: _prev:` overlay that exposes
`pkgs.openspec`. The derivation is written against `final`, so downstream
overlay composition and `overrideAttrs` behave as expected.
- Route `packages.{default,openspec}` through the overlay via a `pkgsFor`
helper (`import nixpkgs { overlays = [ self.overlays.default ]; }`), so the
flake's own package resolves exactly as a consumer's would. No more
duplicated build definition.
- Refresh the nixpkgs pin in `flake.lock`.
`apps` and `devShells` are unchanged in behaviour.
Usage — a downstream flake:
nixpkgs.overlays = [ openspec.overlays.default ];
# -> pkgs.openspec
or devenv, via `devenv.yaml`:
inputs:
openspec:
url: github:Fission-AI/OpenSpec
overlays:
- default
Assisted-by: Claude Opus 4.8 <noreply@anthropic.com>
* test(nix): cover downstream overlay composition and updater warnings
* fix(ci): compare Nix dependencies across multiple outputs
* chore: add Nix overlay changeset
---------
Co-authored-by: John Muchovej <jmuchovej@users.noreply.github.com>
Co-authored-by: Clay Good <hi@claygood.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
143 lines
3.8 KiB
Nix
143 lines
3.8 KiB
Nix
{
|
|
description = "OpenSpec - AI-native system for spec-driven development";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
};
|
|
|
|
outputs =
|
|
{ self, nixpkgs }:
|
|
let
|
|
supportedSystems = [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
"x86_64-darwin"
|
|
"aarch64-darwin"
|
|
];
|
|
|
|
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems f;
|
|
|
|
pkgsFor =
|
|
system:
|
|
import nixpkgs {
|
|
inherit system;
|
|
overlays = [ self.overlays.default ];
|
|
};
|
|
in
|
|
{
|
|
overlays.default = final: _prev: {
|
|
openspec = final.stdenv.mkDerivation (finalAttrs: {
|
|
pname = "openspec";
|
|
version = (builtins.fromJSON (builtins.readFile ./package.json)).version;
|
|
|
|
src = final.lib.fileset.toSource {
|
|
root = ./.;
|
|
fileset = final.lib.fileset.unions [
|
|
./src
|
|
./bin
|
|
./schemas
|
|
./scripts
|
|
./test
|
|
./package.json
|
|
./pnpm-lock.yaml
|
|
./pnpm-workspace.yaml
|
|
./tsconfig.json
|
|
./build.js
|
|
./vitest.config.ts
|
|
./vitest.setup.ts
|
|
./eslint.config.js
|
|
];
|
|
};
|
|
|
|
pnpmDeps = final.fetchPnpmDeps {
|
|
inherit (finalAttrs) pname version src;
|
|
pnpm = final.pnpm_10;
|
|
fetcherVersion = 3;
|
|
hash = "sha256-gPGdwmj4oLb/j3D/BGNCaI0hFfrHKCjH4I71UYzmhfk=";
|
|
};
|
|
|
|
nativeBuildInputs = with final; [
|
|
installShellFiles
|
|
nodejs_22
|
|
npmHooks.npmInstallHook
|
|
pnpmConfigHook
|
|
pnpm_10
|
|
];
|
|
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
|
|
pnpm run build
|
|
|
|
runHook postBuild
|
|
'';
|
|
|
|
dontNpmPrune = true;
|
|
|
|
# `openspec completion generate` renders a static command registry, so it
|
|
# needs no project and no network. Opting out of telemetry also disables
|
|
# the update check, keeping the build offline.
|
|
postInstall = final.lib.optionalString (final.stdenv.buildPlatform.canExecute final.stdenv.hostPlatform) ''
|
|
export OPENSPEC_TELEMETRY=0
|
|
completions=$(mktemp -d)
|
|
for shell in bash fish zsh; do
|
|
$out/bin/openspec completion generate "$shell" > "$completions/openspec.$shell"
|
|
done
|
|
installShellCompletion --cmd openspec \
|
|
--bash "$completions/openspec.bash" \
|
|
--fish "$completions/openspec.fish" \
|
|
--zsh "$completions/openspec.zsh"
|
|
'';
|
|
|
|
meta = with final.lib; {
|
|
description = "AI-native system for spec-driven development";
|
|
homepage = "https://github.com/Fission-AI/OpenSpec";
|
|
license = licenses.mit;
|
|
maintainers = [ ];
|
|
mainProgram = "openspec";
|
|
};
|
|
});
|
|
};
|
|
|
|
packages = forAllSystems (
|
|
system:
|
|
let
|
|
pkgs = pkgsFor system;
|
|
in
|
|
{
|
|
default = pkgs.openspec;
|
|
inherit (pkgs) openspec;
|
|
}
|
|
);
|
|
|
|
apps = forAllSystems (system: {
|
|
default = {
|
|
type = "app";
|
|
program = "${self.packages.${system}.default}/bin/openspec";
|
|
};
|
|
});
|
|
|
|
devShells = forAllSystems (
|
|
system:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
in
|
|
{
|
|
default = pkgs.mkShell {
|
|
buildInputs = with pkgs; [
|
|
nodejs_22
|
|
pnpm_10
|
|
];
|
|
|
|
shellHook = ''
|
|
echo "OpenSpec development environment"
|
|
echo "Node version: $(node --version)"
|
|
echo "pnpm version: $(pnpm --version)"
|
|
echo "Run 'pnpm install' to install dependencies"
|
|
'';
|
|
};
|
|
}
|
|
);
|
|
};
|
|
}
|