A simple TUI Library written in Rust
1{
2 description = "SLY – inline ANSI TUI library for Rust";
3
4 inputs = {
5 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6 crane.url = "github:ipetkov/crane";
7 flake-utils.url = "github:numtide/flake-utils";
8 };
9
10 outputs = { self, nixpkgs, crane, flake-utils }:
11 flake-utils.lib.eachDefaultSystem (system:
12 let
13 pkgs = nixpkgs.legacyPackages.${system};
14 craneLib = crane.mkLib pkgs;
15
16 src = craneLib.cleanCargoSource ./.;
17
18 commonArgs = {
19 inherit src;
20 strictDeps = true;
21 };
22
23 # Build dependencies once and cache the artifacts
24 cargoArtifacts = craneLib.buildDepsOnly commonArgs;
25
26 # Helper to build a named example binary
27 mkExample = name: craneLib.buildPackage (commonArgs // {
28 inherit cargoArtifacts;
29 pname = "sly-${name}";
30 cargoExtraArgs = "--example ${name}";
31 });
32
33 in {
34 packages = {
35 demo = mkExample "demo";
36 login = mkExample "login";
37 api_key = mkExample "api_key";
38 tree = mkExample "tree";
39 fullwidth_box = mkExample "fullwidth_box";
40 default = mkExample "demo";
41 };
42
43 checks = {
44 build = craneLib.cargoBuild (commonArgs // { inherit cargoArtifacts; });
45 test = craneLib.cargoTest (commonArgs // { inherit cargoArtifacts; });
46 clippy = craneLib.cargoClippy (commonArgs // {
47 inherit cargoArtifacts;
48 cargoClippyExtraArgs = "--all-targets -- --deny warnings";
49 });
50 fmt = craneLib.cargoFmt { inherit src; };
51 };
52
53 devShells.default = craneLib.devShell {
54 checks = self.checks.${system};
55 packages = with pkgs; [ cargo-watch ];
56 };
57 }
58 );
59}