Skip to content

Commit 57c9d84

Browse files
neunenakclaudenjbrake
authored
add Nix flake for building the project (#309)
* feat: add Nix flake for building with crane Adds flake.nix and flake.lock to build the project reproducibly with Nix. Uses flake-parts + crane (idiomatic 2026 approach), with dependency caching via buildDepsOnly, and separate checks for clippy, fmt, and tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Use correct branch name * pr review * Update Nix installation command in README Removed outdated instructions for Nix and updated the command. --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: njbrake <njbrake@gmail.com> Co-authored-by: Nathan Brake <33383515+njbrake@users.noreply.github.com>
1 parent 25aaf86 commit 57c9d84

3 files changed

Lines changed: 164 additions & 0 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ curl -fsSL \
5353
# Homebrew
5454
brew install aoe
5555

56+
# Nix
57+
nix run github:njbrake/agent-of-empires
58+
5659
# Build from source
5760
git clone https://github.com/njbrake/agent-of-empires
5861
cd agent-of-empires && cargo build --release

flake.lock

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
description = "Terminal session manager for AI coding agents";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-parts.url = "github:hercules-ci/flake-parts";
7+
crane.url = "github:ipetkov/crane";
8+
};
9+
10+
outputs = inputs @ { flake-parts, ... }:
11+
flake-parts.lib.mkFlake { inherit inputs; } {
12+
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
13+
14+
perSystem = { config, self', inputs', pkgs, system, ... }:
15+
let
16+
craneLib = inputs.crane.mkLib pkgs;
17+
18+
# git2 uses vendored-openssl (needs perl to build OpenSSL)
19+
# and libgit2-sys vendors libgit2 (needs cmake to build it)
20+
nativeBuildInputs = with pkgs; [
21+
pkg-config
22+
perl
23+
cmake
24+
];
25+
26+
buildInputs = with pkgs; [
27+
zlib # required by vendored libgit2
28+
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
29+
libiconv
30+
darwin.apple_sdk.frameworks.Security
31+
darwin.apple_sdk.frameworks.SystemConfiguration
32+
];
33+
34+
commonArgs = {
35+
src = craneLib.cleanCargoSource ./.;
36+
strictDeps = true;
37+
inherit nativeBuildInputs buildInputs;
38+
};
39+
40+
# Build only workspace dependencies first (for caching)
41+
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
42+
43+
aoe = craneLib.buildPackage (commonArgs // {
44+
inherit cargoArtifacts;
45+
cargoExtraArgs = "--package agent-of-empires";
46+
# Tests are run in the separate aoe-test check below
47+
doCheck = false;
48+
meta.mainProgram = "aoe";
49+
});
50+
in
51+
{
52+
packages.default = aoe;
53+
54+
checks = {
55+
# Build the package as a check too
56+
inherit aoe;
57+
58+
aoe-clippy = craneLib.cargoClippy (commonArgs // {
59+
inherit cargoArtifacts;
60+
cargoClippyExtraArgs = "--package agent-of-empires --all-targets -- --deny warnings";
61+
});
62+
63+
aoe-fmt = craneLib.cargoFmt {
64+
inherit (commonArgs) src;
65+
};
66+
67+
aoe-test = craneLib.cargoTest (commonArgs // {
68+
inherit cargoArtifacts;
69+
cargoTestExtraArgs = "--package agent-of-empires";
70+
# Some git:: unit tests invoke the git binary directly
71+
nativeBuildInputs = commonArgs.nativeBuildInputs ++ [ pkgs.git ];
72+
});
73+
};
74+
75+
devShells.default = craneLib.devShell {
76+
checks = self'.checks;
77+
packages = with pkgs; [
78+
rust-analyzer
79+
tmux
80+
];
81+
};
82+
};
83+
};
84+
}

0 commit comments

Comments
 (0)