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:
Jens Krause 2025-02-25 20:30:20 +01:00 committed by GitHub
parent e094d7d81b
commit 3d9b235f12
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 63 additions and 45 deletions

3
.gitignore vendored
View File

@ -18,3 +18,6 @@ result/**/*
#.idea/
#
.direnv
# ignore (possible) sound files
**/*.{mp3,wav}

View File

@ -1 +1,2 @@
style_edition = "2024"
reorder_imports = true

View File

@ -2,8 +2,9 @@
name = "timr-tui"
version = "1.1.0"
description = "TUI to organize your time: Pomodoro, Countdown, Timer."
edition = "2021"
rust-version = "1.84.0"
edition = "2024"
# 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"
repository = "https://github.com/sectore/timr-tui"
readme = "README.md"

24
flake.lock generated
View File

@ -2,11 +2,11 @@
"nodes": {
"crane": {
"locked": {
"lastModified": 1738652123,
"narHash": "sha256-zdZek5FXK/k95J0vnLF0AMnYuZl4AjARq83blKuJBYY=",
"lastModified": 1739936662,
"narHash": "sha256-x4syUjNUuRblR07nDPeLDP7DpphaBVbUaSoeZkFbGSk=",
"owner": "ipetkov",
"repo": "crane",
"rev": "c7e015a5fcefb070778c7d91734768680188a9cd",
"rev": "19de14aaeb869287647d9461cbd389187d8ecdb7",
"type": "github"
},
"original": {
@ -23,11 +23,11 @@
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1738650687,
"narHash": "sha256-1tvCUR1+/F3IT1K4QHTcEO+vsip/P1iluPIttX57Ry8=",
"lastModified": 1740378829,
"narHash": "sha256-cwmm7F73aQFJY6YN1roNibNKwxT6FlfXkG3MEbpSp7Q=",
"owner": "nix-community",
"repo": "fenix",
"rev": "37a1f29ebf98fbbac667730edc5dab4ebe2e3954",
"rev": "92823f1b0c919d7e2d806956aaf98e90f3761ab7",
"type": "github"
},
"original": {
@ -56,11 +56,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1738546358,
"narHash": "sha256-nLivjIygCiqLp5QcL7l56Tca/elVqM9FG1hGd9ZSsrg=",
"lastModified": 1740367490,
"narHash": "sha256-WGaHVAjcrv+Cun7zPlI41SerRtfknGQap281+AakSAw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c6e957d81b96751a3d5967a0fd73694f303cc914",
"rev": "0196c0175e9191c474c26ab5548db27ef5d34b05",
"type": "github"
},
"original": {
@ -81,11 +81,11 @@
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1738591430,
"narHash": "sha256-Q4tPO6rH/q41IZG+NGy/Pjd2RW/bRDVjVjBh9LaVWE4=",
"lastModified": 1740329432,
"narHash": "sha256-eKQ7aBkNvF5AhUpyJ1cW450jxomZ4gTIaYir5qsNl7Y=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "13c17db07b1201e3c460b4cc0ee49ac4d0ace0e5",
"rev": "6d68c475c7aaf7534251182662456a4bf4216dfe",
"type": "github"
},
"original": {

View File

@ -18,31 +18,32 @@
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
toolchain = with fenix.packages.${system};
combine [
minimal.rustc
minimal.cargo
targets.x86_64-pc-windows-gnu.latest.rust-std
targets.x86_64-unknown-linux-musl.latest.rust-std
];
toolchain =
fenix.packages.${system}.fromToolchainFile
{
file = ./rust-toolchain.toml;
# sha256 = nixpkgs.lib.fakeSha256;
sha256 = "sha256-AJ6LX/Q/Er9kS15bn9iflkUwcgYqRQxiOIL2ToVAXaU=";
};
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
# Common build inputs for both native and cross compilation
commonArgs = {
src = craneLib.cleanCargoSource ./.;
cargoArtifacts = craneLib.buildDepsOnly {
src = craneLib.cleanCargoSource ./.;
};
strictDeps = true;
doCheck = false; # skip tests during nix build
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# Native build
timr = craneLib.buildPackage commonArgs;
# Linux build w/ statically linked binaries
staticLinuxBuild = craneLib.buildPackage (commonArgs
// {
inherit cargoArtifacts;
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
});
@ -75,14 +76,10 @@
windows = windowsBuild;
};
# Development shell with all necessary tools
devShell = with nixpkgs.legacyPackages.${system};
mkShell {
buildInputs = with fenix.packages.${system}.stable;
devShells.default = with nixpkgs.legacyPackages.${system};
craneLib.devShell {
packages =
[
rust-analyzer
clippy
rustfmt
toolchain
pkgs.just
pkgs.nixd
@ -96,7 +93,7 @@
];
inherit (commonArgs) src;
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
ALSA_PLUGIN_DIR =
if stdenv.isLinux
then "${pkgs.pipewire}/lib/alsa-lib/"

View File

@ -6,32 +6,42 @@ default:
@just --list
alias b := build
alias f := format
alias l := lint
alias t := test
alias r := run
# build app
build:
cargo build
alias t := test
# run tests
test:
cargo test
alias f := format
# format files
format:
just --fmt
cargo fmt
alias l := lint
# lint
lint:
cargo clippy --no-deps
alias r := run
# run app
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
alias dp := demo-pomodoro

6
rust-toolchain.toml Normal file
View 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"

View File

@ -1,8 +1,8 @@
use clap::ValueEnum;
use ratatui::symbols::shade;
use serde::{Deserialize, Serialize};
use time::format_description;
use time::OffsetDateTime;
use time::format_description;
#[derive(
Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Default, Serialize, Deserialize,

View File

@ -1,5 +1,5 @@
use crate::constants::APP_NAME;
use color_eyre::eyre::{eyre, Result};
use color_eyre::eyre::{Result, eyre};
use directories::ProjectDirs;
use std::fs;
use std::path::PathBuf;

View File

@ -1,6 +1,6 @@
use color_eyre::{
eyre::{ensure, eyre},
Report,
eyre::{ensure, eyre},
};
use std::fmt;
use std::time::Duration;

View File

@ -3,7 +3,7 @@ use futures::{Stream, StreamExt};
use std::{pin::Pin, time::Duration};
use tokio::sync::mpsc;
use tokio::time::interval;
use tokio_stream::{wrappers::IntervalStream, StreamMap};
use tokio_stream::{StreamMap, wrappers::IntervalStream};
use crate::common::ClockTypeId;
use crate::constants::{FPS_VALUE_MS, TICK_VALUE_MS};

View File

@ -1,4 +1,4 @@
use color_eyre::eyre::{eyre, Result};
use color_eyre::eyre::{Result, eyre};
use std::fs;
use std::path::PathBuf;
use tracing::level_filters::LevelFilter;

View File

@ -5,7 +5,7 @@ use crossterm::{
cursor, execute,
terminal::{EnterAlternateScreen, LeaveAlternateScreen},
};
use ratatui::{backend::CrosstermBackend, Terminal as RatatuiTerminal};
use ratatui::{Terminal as RatatuiTerminal, backend::CrosstermBackend};
pub type Terminal = RatatuiTerminal<CrosstermBackend<io::Stdout>>;

View File

@ -15,7 +15,7 @@ use crate::{
events::{AppEvent, AppEventTx},
utils::center_horizontal,
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,
},
};

View File

@ -9,7 +9,7 @@ use ratatui::{
use crate::{
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;