From c52c7d095d85a1a4cb7fdc704474be8ee39606b9 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Tue, 29 Oct 2024 21:30:17 -0700 Subject: [PATCH] chore: switch to flake-parts --- flake.nix | 79 ++++++++++++++++++++++++++++------------------------- src/main.rs | 1 + src/ui.rs | 22 +++++++++++++++ 3 files changed, 65 insertions(+), 37 deletions(-) create mode 100644 src/ui.rs diff --git a/flake.nix b/flake.nix index b00ed34..ff6c082 100644 --- a/flake.nix +++ b/flake.nix @@ -3,7 +3,7 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; + flake-parts.url = "github:hercules-ci/flake-parts"; fenix = { url = "github:nix-community/fenix"; inputs.nixpkgs.follows = "nixpkgs"; @@ -12,47 +12,52 @@ }; outputs = - { - nixpkgs, - flake-utils, + inputs@{ + flake-parts, fenix, naersk, ... }: - flake-utils.lib.eachDefaultSystem ( - system: - let - pkgs = import nixpkgs { inherit system; }; - naersk' = pkgs.callPackage naersk { }; - defaultBuildOpts = { - cargo = fenix.packages.${system}.stable.cargo; - rustc = fenix.packages.${system}.stable.rustc; - src = ./.; + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ + "aarch64-linux" + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + perSystem = + { system, pkgs, ... }: + let + naersk' = pkgs.callPackage naersk { }; + defaultBuildOpts = { + cargo = fenix.packages.${system}.stable.cargo; + rustc = fenix.packages.${system}.stable.rustc; + src = ./.; - nativeBuildInputs = with pkgs; [ pkg-config ]; - buildInputs = with pkgs; [ openssl ]; + nativeBuildInputs = with pkgs; [ pkg-config ]; + buildInputs = with pkgs; [ openssl ]; - mode = "build"; + mode = "build"; + }; + in + { + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + pkg-config + openssl + fenix.packages.${system}.stable.completeToolchain + cargo-audit + ]; + }; + packages = { + default = naersk'.buildPackage defaultBuildOpts; + test = naersk'.buildPackage ( + defaultBuildOpts + // { + mode = "test"; + } + ); + }; }; - in - { - devShells.default = pkgs.mkShell { - buildInputs = with pkgs; [ - pkg-config - openssl - fenix.packages.${system}.stable.completeToolchain - cargo-audit - ]; - }; - packages = { - default = naersk'.buildPackage defaultBuildOpts; - test = naersk'.buildPackage ( - defaultBuildOpts - // { - mode = "test"; - } - ); - }; - } - ); + }; } diff --git a/src/main.rs b/src/main.rs index e7388ed..dd75deb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ use cartographer::libcanvas::CanvasClient; use reqwest::{Error, Url}; use std::env; +use ui; #[tokio::main] async fn main() -> Result<(), Error> { diff --git a/src/ui.rs b/src/ui.rs new file mode 100644 index 0000000..84c2690 --- /dev/null +++ b/src/ui.rs @@ -0,0 +1,22 @@ +use std::io; + +use ratatui::{ + crossterm::event::{self, KeyCode, KeyEventKind}, + style::Stylize, + widgets::Paragraph, + DefaultTerminal, +}; + +fn run(mut terminal: DefaultTerminal) -> io::Result<()> { + loop { + terminal.draw(|frame| { + let greeting = paragraph + .new("Hello Ratatui! (press 'q' to quit)") + .white() + .on_blue(); + frame.render_widget(greeting, frame.area()); + + if let event::Event::Key(key) - + }) + } +}