Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/kan-209-integrate-crane-for-faster-nix-builds.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
bump: patch
---

- build: update flake.lock to add crane input
- build: migrate kanban-mcp to crane-based build
- build: migrate kanban CLI to crane-based build
- build: add crane to flake for incremental Rust builds
- ci: migrate build job to use nix build with magic-nix-cache for 80% faster CI
33 changes: 31 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ jobs:
extra_nix_config: |
experimental-features = nix-command flakes

- uses: Swatinem/rust-cache@v2
with:
shared-key: "rust-stable"
cache-on-failure: true

- name: Check formatting
run: nix develop --command cargo fmt --all -- --check

Expand All @@ -34,6 +39,11 @@ jobs:
extra_nix_config: |
experimental-features = nix-command flakes

- uses: Swatinem/rust-cache@v2
with:
shared-key: "rust-stable"
cache-on-failure: true

- name: Run clippy
run: nix develop --command cargo clippy --all-targets --all-features -- -D warnings

Expand All @@ -49,12 +59,20 @@ jobs:
extra_nix_config: |
experimental-features = nix-command flakes

- uses: Swatinem/rust-cache@v2
with:
shared-key: "rust-stable"
cache-on-failure: true

- name: Run tests
run: nix develop --command cargo test --all-features --workspace

build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # Required for magic-nix-cache
steps:
- uses: actions/checkout@v4

Expand All @@ -64,8 +82,19 @@ jobs:
extra_nix_config: |
experimental-features = nix-command flakes

- name: Build workspace
run: nix develop --command cargo build --all-features --workspace
- uses: DeterminateSystems/magic-nix-cache-action@main

- name: Build kanban CLI
run: nix build .#default --print-build-logs

- name: Build kanban MCP server
run: nix build .#kanban-mcp --print-build-logs

- name: Verify binaries
run: |
./result/bin/kanban --version
nix build .#kanban-mcp
./result/bin/kanban-mcp --help

changeset:
name: Validate Changeset
Expand Down
41 changes: 25 additions & 16 deletions crates/kanban-mcp/default.nix
Original file line number Diff line number Diff line change
@@ -1,33 +1,42 @@
{ lib
, rustPlatform
, makeWrapper
, kanban
{
lib,
craneLib,
makeWrapper,
kanban,
}:

let
cargoToml = lib.importTOML ../../Cargo.toml;
in
rustPlatform.buildRustPackage {
inherit (cargoToml.workspace.package) version;
pname = "kanban-mcp";

src = lib.cleanSource ../..;
src = lib.cleanSourceWith {
src = ../..;
filter = path: type:
(lib.hasSuffix "\.rs" path) ||
(lib.hasSuffix "\.toml" path) ||
(lib.hasInfix "/Cargo.lock" path) ||
(type == "directory");
};

cargoLock = {
lockFile = ../../Cargo.lock;
cargoArtifacts = craneLib.buildDepsOnly {
inherit src;
pname = "kanban-mcp";
version = cargoToml.workspace.package.version;
};

in
craneLib.buildPackage {
inherit src cargoArtifacts;
pname = "kanban-mcp";
version = cargoToml.workspace.package.version;

nativeBuildInputs = [ makeWrapper ];
nativeCheckInputs = [ kanban ];

# Only build the kanban-mcp binary
cargoBuildFlags = [ "--package" "kanban-mcp" ];
cargoTestFlags = [ "--package" "kanban-mcp" ];
cargoExtraArgs = "--package kanban-mcp";
cargoTestExtraArgs = "--package kanban-mcp";

# Point integration tests to the Nix-built kanban binary
KANBAN_BIN = lib.getExe kanban;

# Wrap the binary to include kanban CLI in PATH
postInstall = ''
wrapProgram $out/bin/kanban-mcp \
--prefix PATH : ${lib.makeBinPath [ kanban ]}
Expand Down
35 changes: 27 additions & 8 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,27 +1,46 @@
{
lib,
pkgs,
rustPlatform,
craneLib,
}:

let
cargoToml = lib.importTOML ./Cargo.toml;
in
rustPlatform.buildRustPackage {
pname = "kanban";
inherit (cargoToml.workspace.package) version;

src = lib.cleanSource ./.;
src = lib.cleanSourceWith {
src = ./.;
filter = path: type:
(lib.hasSuffix "\.rs" path) ||
(lib.hasSuffix "\.toml" path) ||
(lib.hasInfix "/Cargo.lock" path) ||
(type == "directory");
};

cargoArtifacts = craneLib.buildDepsOnly {
inherit src;
pname = "kanban";
version = cargoToml.workspace.package.version;

cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = lib.optionals pkgs.stdenv.isLinux [
pkgs.wayland
pkgs.xorg.libxcb
];
};

in
craneLib.buildPackage {
inherit src cargoArtifacts;
pname = "kanban";
version = cargoToml.workspace.package.version;

nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = lib.optionals pkgs.stdenv.isLinux [
pkgs.wayland
pkgs.xorg.libxcb
];

cargoBuildFlags = [ "--package" "kanban-cli" ];
cargoExtraArgs = "--package kanban-cli";
doCheck = false;

meta = {
Expand Down
16 changes: 16 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
servers.url = "github:fulsomenko/servers";
};
Expand All @@ -10,6 +11,7 @@
self,
nixpkgs,
rust-overlay,
crane,
flake-utils,
servers,
...
Expand All @@ -25,6 +27,8 @@
extensions = ["rust-src" "rust-analyzer" "clippy" "rustfmt"];
};

craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;

changeset = pkgs.writeShellApplication {
name = "changeset";
runtimeInputs = with pkgs; [coreutils];
Expand Down Expand Up @@ -61,11 +65,13 @@
};

packages = let
kanban = pkgs.callPackage ./default.nix {};
kanban = pkgs.callPackage ./default.nix {
inherit craneLib;
};
in {
default = kanban;
kanban-mcp = pkgs.callPackage ./crates/kanban-mcp/default.nix {
inherit kanban;
inherit kanban craneLib;
};
kanban-web = pkgs.callPackage ./web/default.nix {};
mcp-server-git = servers.packages.${system}.mcp-server-git;
Expand Down
Loading