forked from block/goose
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
121 lines (106 loc) · 4.09 KB
/
flake.nix
File metadata and controls
121 lines (106 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
{
description = "goose - An AI agent CLI";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ rust-overlay.overlays.default ];
pkgs = import nixpkgs { inherit system overlays; };
rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
# Read package metadata from Cargo.toml
cargoToml = builtins.fromTOML (builtins.readFile ./crates/goose-cli/Cargo.toml);
workspaceToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
commonInputs = [
rust
pkgs.rust-analyzer
pkgs.pkg-config
pkgs.openssl
];
darwinInputs = with pkgs; [
libiconv
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
darwin.apple_sdk.frameworks.CoreServices
];
buildInputs = commonInputs
++ pkgs.lib.optionals pkgs.stdenv.isDarwin darwinInputs;
in
{
defaultPackage = pkgs.rustPlatform.buildRustPackage {
pname = cargoToml.package.name;
version = workspaceToml.workspace.package.version;
src = self;
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
# Patch required for Windows cross-compilation
# See: https://github.com/nmathewson/crunchy/tree/cross-compilation-fix
"crunchy-0.2.3" = "sha256-CBW3/JuMoNa6MWia6BQo07LQrH5JQbb20vuCqhyFL0Y=";
};
};
nativeBuildInputs = with pkgs; [
pkg-config
];
buildInputs = with pkgs; [
openssl
xorg.libxcb # Required for xcap screenshot functionality
dbus # Required for system integration features
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin darwinInputs;
# Build only the CLI package
cargoBuildFlags = [ "--package" "goose-cli" ];
# Enable tests with proper environment
# Tests need writable HOME and XDG directories for config/cache access
doCheck = true;
checkPhase = ''
export HOME=$(mktemp -d)
export XDG_CONFIG_HOME=$HOME/.config
export XDG_DATA_HOME=$HOME/.local/share
export XDG_STATE_HOME=$HOME/.local/state
export XDG_CACHE_HOME=$HOME/.cache
mkdir -p $XDG_CONFIG_HOME $XDG_DATA_HOME $XDG_STATE_HOME $XDG_CACHE_HOME
# Run tests for goose-cli package only
cargo test --package goose-cli --release
'';
meta = with pkgs.lib; {
description = workspaceToml.workspace.package.description;
homepage = workspaceToml.workspace.package.repository;
license = licenses.asl20; # Maps from "Apache-2.0" in Cargo.toml
mainProgram = "goose";
};
};
devShell = pkgs.mkShell {
packages = buildInputs ++ (with pkgs; [
cargo-watch
cargo-edit
clippy
gemini-cli # potentially useful during dev/testing
go_1_25 # 'just' run-ui (temporal-service)
just # used in dev/test
nodejs_24 # 'just' run-ui
ripgrep
rustfmt
xorg.libxcb
dbus
yarn # 'just' install-deps
]);
shellHook = ''
echo "goose development environment"
echo "Rust version: $(rustc --version)"
echo ""
echo "Commands:"
echo " nix build - Build goose CLI"
echo " nix run - Run goose CLI"
echo " cargo build -p goose-cli - Build with cargo"
echo " cargo run -p goose-cli - Run with cargo"
'';
};
}
);
}