chore: switch to flake-parts

This commit is contained in:
Youwen Wu 2024-10-29 21:30:17 -07:00
parent b8d9ac366e
commit c52c7d095d
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3
3 changed files with 65 additions and 37 deletions

View file

@ -3,7 +3,7 @@
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils"; flake-parts.url = "github:hercules-ci/flake-parts";
fenix = { fenix = {
url = "github:nix-community/fenix"; url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@ -12,47 +12,52 @@
}; };
outputs = outputs =
{ inputs@{
nixpkgs, flake-parts,
flake-utils,
fenix, fenix,
naersk, naersk,
... ...
}: }:
flake-utils.lib.eachDefaultSystem ( flake-parts.lib.mkFlake { inherit inputs; } {
system: systems = [
let "aarch64-linux"
pkgs = import nixpkgs { inherit system; }; "x86_64-linux"
naersk' = pkgs.callPackage naersk { }; "aarch64-darwin"
defaultBuildOpts = { "x86_64-darwin"
cargo = fenix.packages.${system}.stable.cargo; ];
rustc = fenix.packages.${system}.stable.rustc; perSystem =
src = ./.; { 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 ]; nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ openssl ]; 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";
}
);
};
}
);
} }

View file

@ -1,6 +1,7 @@
use cartographer::libcanvas::CanvasClient; use cartographer::libcanvas::CanvasClient;
use reqwest::{Error, Url}; use reqwest::{Error, Url};
use std::env; use std::env;
use ui;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Error> { async fn main() -> Result<(), Error> {

22
src/ui.rs Normal file
View file

@ -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) -
})
}
}