This repository has been archived on 2026-07-29. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
kitchen-md/flake.nix
alexion ab309d3226 feat: add kitchen view command and parser skeleton (task 0003)
Cut the first vertical slice through both layers: a runnable
`kitchen view <file>` that reads a Recipe File, parses it, and renders
it styled to the terminal.

@kitchen-md/core exposes a pure, total `parse(input): DocumentAST` built
on a minimal remark pipeline (parse + frontmatter) with a translation
layer to core's own AST types — frontmatter passthrough, HeadingBlock,
ParagraphBlock, and TextNode. remark types never leak into the public
API.

@kitchen-md/bin's `view` subcommand (commander) reads the file and hands
the DocumentAST to a pure `render(ast): string` (chalk, ANSI
auto-suppressed off a TTY). Fallible file I/O is modelled as a neverthrow
Result over a tagged-union CliError, matched at the boundary: stdout on
success, stderr and exit 1 on failure. The command functions sit beside
the import.meta.main-guarded CLI entry so they are testable in-process.

Tests follow ADR 0009's tiers — unit (parse, render), integration (the
view command's Result), and e2e (the binary as a subprocess) — with
coverage, a path-scoped test-report generator, and a prose fixture
rounding out the tooling. ADR 0008 records errors-as-values at the CLI
boundary; ADR 0009 records the testing tiers.
2026-07-28 23:31:03 -04:00

100 lines
3.0 KiB
Nix

{
description = "kitchen the KitchenMD CLI, packaged as a Nix flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
# The single pinned Bun, used to compile the binary and to develop against.
# It is held apart from `nixpkgs` so a `nixpkgs` update cannot pull in a Bun
# release that emits empty binaries under sandboxed native compilation.
nixpkgs-bun.url = "github:nixos/nixpkgs/241313f4e8e508cb9b13278c2b0fa25b9ca27163";
flake-parts.url = "github:hercules-ci/flake-parts";
systems.url = "github:nix-systems/x86_64-linux";
bun2nix = {
url = "github:nix-community/bun2nix?ref=2.1.2";
# Compile against the pinned Bun rather than `nixpkgs`'s.
inputs.nixpkgs.follows = "nixpkgs-bun";
inputs.systems.follows = "systems";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
imports = [ inputs.treefmt-nix.flakeModule ];
perSystem =
{ system, ... }:
let
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ inputs.bun2nix.overlays.default ];
};
# The Bun from the same pinned `nixpkgs-bun` the build compiles with.
bun = inputs.nixpkgs-bun.legacyPackages.${system}.bun;
kitchen = pkgs.callPackage ./package.nix { };
bunDeps = pkgs.bun2nix.fetchBunDeps { bunNix = ./bun.nix; };
in
{
# Share the overlaid package set with the imported modules.
_module.args.pkgs = pkgs;
packages.default = kitchen;
apps.default = {
type = "app";
program = "${kitchen}/bin/kitchen";
};
devShells.default = pkgs.mkShell {
packages = [
bun
pkgs.biome
pkgs.bun2nix
];
};
treefmt = {
projectRootFile = "flake.nix";
programs.biome = {
enable = true;
# Reuse the repo's biome configuration as the single source.
# The sandboxed check has no git tree, so biome's VCS-ignore
# lookup must be off.
settings = pkgs.lib.recursiveUpdate (pkgs.lib.importJSON ./biome.json) {
vcs.enabled = false;
};
# Skip re-validating the config; biome consumes it directly.
validate.enable = false;
};
};
checks = {
tests = pkgs.bun2nix.mkDerivation {
pname = "kitchen-tests";
inherit (kitchen) version;
src = ./.;
inherit bunDeps;
dontRunLifecycleScripts = true;
dontUseBunBuild = true;
doCheck = true;
installPhase = "touch $out";
};
};
};
};
}