Files
Justin Poehnelt 029e5def2b feat: extract google-workspace library crate (cargo workspace) (#613)
* feat: extract google-workspace library crate and restructure as cargo workspace

- Create crates/google-workspace/ with public modules: discovery, error, services, validate, client
- Move CLI binary to crates/cli/ (package: google-workspace-cli, binary: gws)
- Root Cargo.toml is now workspace-only
- Binary modules use thin re-exports from library (zero behavioral changes)
- Discovery fetch_discovery_document accepts cache_dir parameter for library consumers
- Break output.rs / error.rs circular dep by moving char detection to library validate module
- Update CI workflows for workspace (--workspace flags, path filters)
- Update dist-workspace.toml and policy.yml for new crate locations

Closes #386

* refactor: rename crates/cli to crates/google-workspace-cli

* chore: sync CLI version to 0.20.1 and regenerate skills

* chore: update labeler paths for workspace crate layout

* fix: update flake.nix to read version from CLI crate Cargo.toml

* fix: use tokio::fs for non-blocking I/O in library discovery cache

* docs: update AGENTS.md source layout for workspace structure

* docs: add crate-level READMEs for crates.io

---------

Co-authored-by: jpoehnelt-bot <jpoehnelt-bot@users.noreply.github.com>
2026-03-24 14:40:03 -06:00

78 lines
2.1 KiB
Nix

{
description = "Google Workspace CLI dynamic command surface from Discovery Service";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
# Extract version from CLI crate's Cargo.toml
cargoToml = builtins.fromTOML (builtins.readFile ./crates/google-workspace-cli/Cargo.toml);
version = cargoToml.package.version;
# System dependencies
# On Linux, keyring often needs libsecret
# On macOS, it uses Security framework
linuxDeps = with pkgs; [
libsecret
];
darwinDeps = with pkgs; [
libiconv
apple-sdk
];
gws = pkgs.rustPlatform.buildRustPackage {
pname = "gws";
inherit version;
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = pkgs.lib.optionals pkgs.stdenv.isLinux linuxDeps
++ pkgs.lib.optionals pkgs.stdenv.isDarwin darwinDeps;
# Tests are disabled by default in buildRustPackage if not specified,
# but we'll be explicit. Some tests might require network.
doCheck = false;
meta = with pkgs.lib; {
description = cargoToml.package.description;
homepage = cargoToml.package.homepage;
license = licenses.asl20;
maintainers = [{ name = "Justin Poehnelt"; email = "justin.poehnelt@gmail.com"; }];
mainProgram = "gws";
};
};
in
{
packages.default = gws;
packages.gws = gws;
apps.default = flake-utils.lib.mkApp {
drv = gws;
};
devShells.default = pkgs.mkShell {
inputsFrom = [ gws ];
buildInputs = with pkgs; [
rustc
cargo
rust-analyzer
clippy
rustfmt
];
};
}
);
}