Rust 1.85.0 + Rust 2024 Edition (#68)
- Add `rust-toolchain.toml` - Refactor `flake` to consider `rust-toolchain.toml`, especially Rust version - `just`: Add run-sound command - Ignore sound files - Format
This commit is contained in:
parent
e094d7d81b
commit
3d9b235f12
3
.gitignore
vendored
3
.gitignore
vendored
@ -18,3 +18,6 @@ result/**/*
|
|||||||
#.idea/
|
#.idea/
|
||||||
#
|
#
|
||||||
.direnv
|
.direnv
|
||||||
|
|
||||||
|
# ignore (possible) sound files
|
||||||
|
**/*.{mp3,wav}
|
||||||
|
|||||||
@ -1 +1,2 @@
|
|||||||
|
style_edition = "2024"
|
||||||
reorder_imports = true
|
reorder_imports = true
|
||||||
|
|||||||
@ -2,8 +2,9 @@
|
|||||||
name = "timr-tui"
|
name = "timr-tui"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
description = "TUI to organize your time: Pomodoro, Countdown, Timer."
|
description = "TUI to organize your time: Pomodoro, Countdown, Timer."
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
rust-version = "1.84.0"
|
# Reminder: Always keep `channel` in `rust-toolchain.toml` in sync with `rust-version`.
|
||||||
|
rust-version = "1.85.0"
|
||||||
homepage = "https://github.com/sectore/timr-tui"
|
homepage = "https://github.com/sectore/timr-tui"
|
||||||
repository = "https://github.com/sectore/timr-tui"
|
repository = "https://github.com/sectore/timr-tui"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|||||||
24
flake.lock
generated
24
flake.lock
generated
@ -2,11 +2,11 @@
|
|||||||
"nodes": {
|
"nodes": {
|
||||||
"crane": {
|
"crane": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1738652123,
|
"lastModified": 1739936662,
|
||||||
"narHash": "sha256-zdZek5FXK/k95J0vnLF0AMnYuZl4AjARq83blKuJBYY=",
|
"narHash": "sha256-x4syUjNUuRblR07nDPeLDP7DpphaBVbUaSoeZkFbGSk=",
|
||||||
"owner": "ipetkov",
|
"owner": "ipetkov",
|
||||||
"repo": "crane",
|
"repo": "crane",
|
||||||
"rev": "c7e015a5fcefb070778c7d91734768680188a9cd",
|
"rev": "19de14aaeb869287647d9461cbd389187d8ecdb7",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -23,11 +23,11 @@
|
|||||||
"rust-analyzer-src": "rust-analyzer-src"
|
"rust-analyzer-src": "rust-analyzer-src"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1738650687,
|
"lastModified": 1740378829,
|
||||||
"narHash": "sha256-1tvCUR1+/F3IT1K4QHTcEO+vsip/P1iluPIttX57Ry8=",
|
"narHash": "sha256-cwmm7F73aQFJY6YN1roNibNKwxT6FlfXkG3MEbpSp7Q=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "fenix",
|
"repo": "fenix",
|
||||||
"rev": "37a1f29ebf98fbbac667730edc5dab4ebe2e3954",
|
"rev": "92823f1b0c919d7e2d806956aaf98e90f3761ab7",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -56,11 +56,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1738546358,
|
"lastModified": 1740367490,
|
||||||
"narHash": "sha256-nLivjIygCiqLp5QcL7l56Tca/elVqM9FG1hGd9ZSsrg=",
|
"narHash": "sha256-WGaHVAjcrv+Cun7zPlI41SerRtfknGQap281+AakSAw=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "c6e957d81b96751a3d5967a0fd73694f303cc914",
|
"rev": "0196c0175e9191c474c26ab5548db27ef5d34b05",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -81,11 +81,11 @@
|
|||||||
"rust-analyzer-src": {
|
"rust-analyzer-src": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1738591430,
|
"lastModified": 1740329432,
|
||||||
"narHash": "sha256-Q4tPO6rH/q41IZG+NGy/Pjd2RW/bRDVjVjBh9LaVWE4=",
|
"narHash": "sha256-eKQ7aBkNvF5AhUpyJ1cW450jxomZ4gTIaYir5qsNl7Y=",
|
||||||
"owner": "rust-lang",
|
"owner": "rust-lang",
|
||||||
"repo": "rust-analyzer",
|
"repo": "rust-analyzer",
|
||||||
"rev": "13c17db07b1201e3c460b4cc0ee49ac4d0ace0e5",
|
"rev": "6d68c475c7aaf7534251182662456a4bf4216dfe",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
35
flake.nix
35
flake.nix
@ -18,31 +18,32 @@
|
|||||||
}:
|
}:
|
||||||
flake-utils.lib.eachDefaultSystem (system: let
|
flake-utils.lib.eachDefaultSystem (system: let
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
toolchain = with fenix.packages.${system};
|
|
||||||
combine [
|
toolchain =
|
||||||
minimal.rustc
|
fenix.packages.${system}.fromToolchainFile
|
||||||
minimal.cargo
|
{
|
||||||
targets.x86_64-pc-windows-gnu.latest.rust-std
|
file = ./rust-toolchain.toml;
|
||||||
targets.x86_64-unknown-linux-musl.latest.rust-std
|
# sha256 = nixpkgs.lib.fakeSha256;
|
||||||
];
|
sha256 = "sha256-AJ6LX/Q/Er9kS15bn9iflkUwcgYqRQxiOIL2ToVAXaU=";
|
||||||
|
};
|
||||||
|
|
||||||
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
|
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
|
||||||
|
|
||||||
# Common build inputs for both native and cross compilation
|
|
||||||
commonArgs = {
|
commonArgs = {
|
||||||
src = craneLib.cleanCargoSource ./.;
|
src = craneLib.cleanCargoSource ./.;
|
||||||
cargoArtifacts = craneLib.buildDepsOnly {
|
|
||||||
src = craneLib.cleanCargoSource ./.;
|
|
||||||
};
|
|
||||||
strictDeps = true;
|
strictDeps = true;
|
||||||
doCheck = false; # skip tests during nix build
|
doCheck = false; # skip tests during nix build
|
||||||
};
|
};
|
||||||
|
|
||||||
|
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||||
|
|
||||||
# Native build
|
# Native build
|
||||||
timr = craneLib.buildPackage commonArgs;
|
timr = craneLib.buildPackage commonArgs;
|
||||||
|
|
||||||
# Linux build w/ statically linked binaries
|
# Linux build w/ statically linked binaries
|
||||||
staticLinuxBuild = craneLib.buildPackage (commonArgs
|
staticLinuxBuild = craneLib.buildPackage (commonArgs
|
||||||
// {
|
// {
|
||||||
|
inherit cargoArtifacts;
|
||||||
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
|
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
|
||||||
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
|
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
|
||||||
});
|
});
|
||||||
@ -75,14 +76,10 @@
|
|||||||
windows = windowsBuild;
|
windows = windowsBuild;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Development shell with all necessary tools
|
devShells.default = with nixpkgs.legacyPackages.${system};
|
||||||
devShell = with nixpkgs.legacyPackages.${system};
|
craneLib.devShell {
|
||||||
mkShell {
|
packages =
|
||||||
buildInputs = with fenix.packages.${system}.stable;
|
|
||||||
[
|
[
|
||||||
rust-analyzer
|
|
||||||
clippy
|
|
||||||
rustfmt
|
|
||||||
toolchain
|
toolchain
|
||||||
pkgs.just
|
pkgs.just
|
||||||
pkgs.nixd
|
pkgs.nixd
|
||||||
@ -96,7 +93,7 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
inherit (commonArgs) src;
|
inherit (commonArgs) src;
|
||||||
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
|
|
||||||
ALSA_PLUGIN_DIR =
|
ALSA_PLUGIN_DIR =
|
||||||
if stdenv.isLinux
|
if stdenv.isLinux
|
||||||
then "${pkgs.pipewire}/lib/alsa-lib/"
|
then "${pkgs.pipewire}/lib/alsa-lib/"
|
||||||
|
|||||||
18
justfile
18
justfile
@ -6,32 +6,42 @@ default:
|
|||||||
@just --list
|
@just --list
|
||||||
|
|
||||||
alias b := build
|
alias b := build
|
||||||
alias f := format
|
|
||||||
alias l := lint
|
|
||||||
alias t := test
|
|
||||||
alias r := run
|
|
||||||
|
|
||||||
# build app
|
# build app
|
||||||
build:
|
build:
|
||||||
cargo build
|
cargo build
|
||||||
|
|
||||||
|
alias t := test
|
||||||
|
|
||||||
# run tests
|
# run tests
|
||||||
test:
|
test:
|
||||||
cargo test
|
cargo test
|
||||||
|
|
||||||
|
alias f := format
|
||||||
|
|
||||||
# format files
|
# format files
|
||||||
format:
|
format:
|
||||||
just --fmt
|
just --fmt
|
||||||
cargo fmt
|
cargo fmt
|
||||||
|
|
||||||
|
alias l := lint
|
||||||
|
|
||||||
# lint
|
# lint
|
||||||
lint:
|
lint:
|
||||||
cargo clippy --no-deps
|
cargo clippy --no-deps
|
||||||
|
|
||||||
|
alias r := run
|
||||||
|
|
||||||
# run app
|
# run app
|
||||||
run:
|
run:
|
||||||
cargo run
|
cargo run
|
||||||
|
|
||||||
|
alias rs := run-sound
|
||||||
|
|
||||||
|
# run app while sound feature is enabled. It expects a path to a sound file.
|
||||||
|
run-sound path:
|
||||||
|
cargo run --features sound -- --sound={{ path }}
|
||||||
|
|
||||||
# demos
|
# demos
|
||||||
|
|
||||||
alias dp := demo-pomodoro
|
alias dp := demo-pomodoro
|
||||||
|
|||||||
6
rust-toolchain.toml
Normal file
6
rust-toolchain.toml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[toolchain]
|
||||||
|
# Reminder: Always keep `rust-version` in `Cargo.toml` in sync with `channel`.
|
||||||
|
channel = "1.85.0"
|
||||||
|
components = ["clippy", "rustfmt", "rust-src", "rust-analyzer"]
|
||||||
|
targets = ["x86_64-pc-windows-gnu", "x86_64-unknown-linux-musl"]
|
||||||
|
profile = "minimal"
|
||||||
@ -1,8 +1,8 @@
|
|||||||
use clap::ValueEnum;
|
use clap::ValueEnum;
|
||||||
use ratatui::symbols::shade;
|
use ratatui::symbols::shade;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use time::format_description;
|
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
|
use time::format_description;
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Default, Serialize, Deserialize,
|
Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Default, Serialize, Deserialize,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use crate::constants::APP_NAME;
|
use crate::constants::APP_NAME;
|
||||||
use color_eyre::eyre::{eyre, Result};
|
use color_eyre::eyre::{Result, eyre};
|
||||||
use directories::ProjectDirs;
|
use directories::ProjectDirs;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use color_eyre::{
|
use color_eyre::{
|
||||||
eyre::{ensure, eyre},
|
|
||||||
Report,
|
Report,
|
||||||
|
eyre::{ensure, eyre},
|
||||||
};
|
};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use futures::{Stream, StreamExt};
|
|||||||
use std::{pin::Pin, time::Duration};
|
use std::{pin::Pin, time::Duration};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tokio::time::interval;
|
use tokio::time::interval;
|
||||||
use tokio_stream::{wrappers::IntervalStream, StreamMap};
|
use tokio_stream::{StreamMap, wrappers::IntervalStream};
|
||||||
|
|
||||||
use crate::common::ClockTypeId;
|
use crate::common::ClockTypeId;
|
||||||
use crate::constants::{FPS_VALUE_MS, TICK_VALUE_MS};
|
use crate::constants::{FPS_VALUE_MS, TICK_VALUE_MS};
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use color_eyre::eyre::{eyre, Result};
|
use color_eyre::eyre::{Result, eyre};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tracing::level_filters::LevelFilter;
|
use tracing::level_filters::LevelFilter;
|
||||||
|
|||||||
@ -5,7 +5,7 @@ use crossterm::{
|
|||||||
cursor, execute,
|
cursor, execute,
|
||||||
terminal::{EnterAlternateScreen, LeaveAlternateScreen},
|
terminal::{EnterAlternateScreen, LeaveAlternateScreen},
|
||||||
};
|
};
|
||||||
use ratatui::{backend::CrosstermBackend, Terminal as RatatuiTerminal};
|
use ratatui::{Terminal as RatatuiTerminal, backend::CrosstermBackend};
|
||||||
|
|
||||||
pub type Terminal = RatatuiTerminal<CrosstermBackend<io::Stdout>>;
|
pub type Terminal = RatatuiTerminal<CrosstermBackend<io::Stdout>>;
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ use crate::{
|
|||||||
events::{AppEvent, AppEventTx},
|
events::{AppEvent, AppEventTx},
|
||||||
utils::center_horizontal,
|
utils::center_horizontal,
|
||||||
widgets::clock_elements::{
|
widgets::clock_elements::{
|
||||||
Colon, Digit, Dot, COLON_WIDTH, DIGIT_HEIGHT, DIGIT_SPACE_WIDTH, DIGIT_WIDTH, DOT_WIDTH,
|
COLON_WIDTH, Colon, DIGIT_HEIGHT, DIGIT_SPACE_WIDTH, DIGIT_WIDTH, DOT_WIDTH, Digit, Dot,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ use ratatui::{
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::Style,
|
common::Style,
|
||||||
widgets::clock_elements::{Colon, Digit, COLON_WIDTH, DIGIT_SPACE_WIDTH, DIGIT_WIDTH},
|
widgets::clock_elements::{COLON_WIDTH, Colon, DIGIT_SPACE_WIDTH, DIGIT_WIDTH, Digit},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::clock_elements::DIGIT_HEIGHT;
|
use super::clock_elements::DIGIT_HEIGHT;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user