diff --git a/flake.lock b/flake.lock index 4999493..7c6a5a6 100644 --- a/flake.lock +++ b/flake.lock @@ -30,11 +30,11 @@ ] }, "locked": { - "lastModified": 1752689277, - "narHash": "sha256-uldUBFkZe/E7qbvxa3mH1ItrWZyT6w1dBKJQF/3ZSsc=", + "lastModified": 1763384566, + "narHash": "sha256-r+wgI+WvNaSdxQmqaM58lVNvJYJ16zoq+tKN20cLst4=", "owner": "nix-community", "repo": "naersk", - "rev": "0e72363d0938b0208d6c646d10649164c43f4d64", + "rev": "d4155d6ebb70fbe2314959842f744aa7cabbbf6a", "type": "github" }, "original": { @@ -45,11 +45,11 @@ }, "nix-filter": { "locked": { - "lastModified": 1731533336, - "narHash": "sha256-oRam5PS1vcrr5UPgALW0eo1m/5/pls27Z/pabHNy2Ms=", + "lastModified": 1757882181, + "narHash": "sha256-+cCxYIh2UNalTz364p+QYmWHs0P+6wDhiWR4jDIKQIU=", "owner": "numtide", "repo": "nix-filter", - "rev": "f7653272fd234696ae94229839a99b73c9ab7de0", + "rev": "59c44d1909c72441144b93cf0f054be7fe764de5", "type": "github" }, "original": { @@ -60,16 +60,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1757545623, - "narHash": "sha256-mCxPABZ6jRjUQx3bPP4vjA68ETbPLNz9V2pk9tO7pRQ=", + "lastModified": 1764677808, + "narHash": "sha256-H3lC7knbXOBrHI9hITQ7modLuX20mYJVhZORL5ioms0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "8cd5ce828d5d1d16feff37340171a98fc3bf6526", + "rev": "1aab89277eb2d87823d5b69bae631a2496cff57a", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-25.05", + "ref": "nixos-25.11", "repo": "nixpkgs", "type": "github" } @@ -78,7 +78,8 @@ "inputs": { "naersk": "naersk", "nix-filter": "nix-filter", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" } }, "rust-analyzer-src": { @@ -97,6 +98,26 @@ "repo": "rust-analyzer", "type": "github" } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1762938485, + "narHash": "sha256-AlEObg0syDl+Spi4LsZIBrjw+snSVU4T8MOeuZJUJjM=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "5b4ee75aeefd1e2d5a1cc43cf6ba65eba75e83e4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 0586565..fea0f90 100644 --- a/flake.nix +++ b/flake.nix @@ -2,12 +2,16 @@ description = "Flake for command line interface of the ServicePoint display."; inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11"; nix-filter.url = "github:numtide/nix-filter"; naersk = { url = "github:nix-community/naersk"; inputs.nixpkgs.follows = "nixpkgs"; }; + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = @@ -16,9 +20,18 @@ nixpkgs, naersk, nix-filter, + treefmt-nix, }: let lib = nixpkgs.lib; + treefmt-config = { + projectRootFile = "flake.nix"; + programs = { + nixfmt.enable = true; + keep-sorted.enable = true; + rustfmt.enable = true; + }; + }; supported-systems = [ "x86_64-linux" "aarch64-linux" @@ -31,6 +44,7 @@ system: f rec { pkgs = nixpkgs.legacyPackages.${system}; + treefmt-eval = treefmt-nix.lib.evalModule pkgs treefmt-config; inherit system; } ); @@ -63,7 +77,7 @@ [ xe xz - ffmpeg-headless + ffmpeg_6-headless.dev ] ++ lib.optionals pkgs.stdenv.isLinux ( with pkgs; @@ -120,6 +134,6 @@ } ); - formatter = forAllSystems ({ pkgs, ... }: pkgs.nixfmt-tree); + formatter = forAllSystems ({ treefmt-eval, ... }: treefmt-eval.config.build.wrapper); }; } diff --git a/src/image_processing.rs b/src/image_processing.rs index 6e27cde..b8f06e8 100644 --- a/src/image_processing.rs +++ b/src/image_processing.rs @@ -164,9 +164,7 @@ impl ImageProcessingPipeline { let result = (width, height); trace!( "scaling {:?} to {:?} to fit {:?}", - source, - result, - self.render_size + source, result, self.render_size ); result } diff --git a/src/pixels.rs b/src/pixels.rs index 3f9665d..a5c5368 100644 --- a/src/pixels.rs +++ b/src/pixels.rs @@ -92,7 +92,8 @@ fn pixels_video( ) { ffmpeg::init().unwrap(); - let mut ictx = ffmpeg::format::input(&options.file_name).expect("failed to open video input file"); + let mut ictx = + ffmpeg::format::input(&options.file_name).expect("failed to open video input file"); let input = ictx .streams() @@ -103,12 +104,14 @@ fn pixels_video( let context_decoder = ffmpeg::codec::context::Context::from_parameters(input.parameters()) .expect("could not extract video context from parameters"); - let mut decoder = context_decoder.decoder().video() + let mut decoder = context_decoder + .decoder() + .video() .expect("failed to create decoder for video stream"); let src_width = decoder.width(); let src_height = decoder.height(); - + let mut scaler = ffmpeg::software::scaling::Context::get( decoder.format(), src_width, @@ -117,7 +120,8 @@ fn pixels_video( src_width, src_height, ffmpeg::software::scaling::Flags::BILINEAR, - ).expect("failed to create scaling context"); + ) + .expect("failed to create scaling context"); let mut frame_index = 0; @@ -128,14 +132,16 @@ fn pixels_video( let mut decoded = ffmpeg::util::frame::video::Video::empty(); let mut rgb_frame = ffmpeg::util::frame::video::Video::empty(); while decoder.receive_frame(&mut decoded).is_ok() { - scaler.run(&decoded, &mut rgb_frame) + scaler + .run(&decoded, &mut rgb_frame) .expect("failed to scale frame"); let image = RgbImage::from_raw(src_width, src_height, rgb_frame.data(0).to_owned()) .expect("could not read rgb data to image"); let image = DynamicImage::from(image); - let bitmap= processing_pipeline.process(image); - connection.send_command(BitmapCommand::from(bitmap)) + let bitmap = processing_pipeline.process(image); + connection + .send_command(BitmapCommand::from(bitmap)) .expect("failed to send image command"); frame_index += 1; @@ -145,13 +151,13 @@ fn pixels_video( for (stream, packet) in ictx.packets() { if stream.index() == video_stream_index { - decoder.send_packet(&packet) + decoder + .send_packet(&packet) .expect("failed to send video packet"); receive_and_process_decoded_frames(&mut decoder) .expect("failed to process video packet"); } } decoder.send_eof().expect("failed to send eof"); - receive_and_process_decoded_frames(&mut decoder) - .expect("failed to eof packet"); + receive_and_process_decoded_frames(&mut decoder).expect("failed to eof packet"); } diff --git a/src/stream_stdin.rs b/src/stream_stdin.rs index 872461c..ac744fd 100644 --- a/src/stream_stdin.rs +++ b/src/stream_stdin.rs @@ -4,7 +4,9 @@ use servicepoint::*; use std::thread::sleep; pub(crate) fn stream_stdin(connection: &Transport, slow: bool) { - warn!("This mode will break when using multi-byte characters and does not support ANSI escape sequences yet."); + warn!( + "This mode will break when using multi-byte characters and does not support ANSI escape sequences yet." + ); let mut app = App { connection, mirror: CharGrid::new(TILE_WIDTH, TILE_HEIGHT), diff --git a/src/stream_window.rs b/src/stream_window.rs index ffbc717..46545d9 100644 --- a/src/stream_window.rs +++ b/src/stream_window.rs @@ -7,10 +7,10 @@ use image::{DynamicImage, ImageBuffer, Rgb, Rgba}; use log::{debug, error, info, trace, warn}; use scap::{ capturer::{Capturer, Options}, - frame::convert_bgra_to_rgb, frame::Frame, + frame::convert_bgra_to_rgb, }; -use servicepoint::{BitmapCommand, CompressionCode, Origin, FRAME_PACING}; +use servicepoint::{BitmapCommand, CompressionCode, FRAME_PACING, Origin}; use std::time::{Duration, Instant}; pub fn stream_window(