{ description = "SLY – inline ANSI TUI library for Rust"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; crane.url = "github:ipetkov/crane"; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs, crane, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; craneLib = crane.mkLib pkgs; src = craneLib.cleanCargoSource ./.; commonArgs = { inherit src; strictDeps = true; }; # Build dependencies once and cache the artifacts cargoArtifacts = craneLib.buildDepsOnly commonArgs; # Helper to build a named example binary mkExample = name: craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; pname = "sly-${name}"; cargoExtraArgs = "--example ${name}"; }); in { packages = { demo = mkExample "demo"; login = mkExample "login"; api_key = mkExample "api_key"; tree = mkExample "tree"; fullwidth_box = mkExample "fullwidth_box"; default = mkExample "demo"; }; checks = { build = craneLib.cargoBuild (commonArgs // { inherit cargoArtifacts; }); test = craneLib.cargoTest (commonArgs // { inherit cargoArtifacts; }); clippy = craneLib.cargoClippy (commonArgs // { inherit cargoArtifacts; cargoClippyExtraArgs = "--all-targets -- --deny warnings"; }); fmt = craneLib.cargoFmt { inherit src; }; }; devShells.default = craneLib.devShell { checks = self.checks.${system}; packages = with pkgs; [ cargo-watch ]; }; } ); }