diff --git a/flake.nix b/flake.nix index 2de116c..ce67021 100644 --- a/flake.nix +++ b/flake.nix @@ -8,101 +8,107 @@ fenix.url = "github:nix-community/fenix"; }; - outputs = inputs: with inputs; - flake-utils.lib.eachDefaultSystem - (system: - let - pkgs = import nixpkgs { - inherit system; - overlays = [fenix.overlays.default]; - # overlays = [cargo2nix.overlays.default]; - }; - naersk' = pkgs.callPackage naersk {}; - nbi = with pkgs; [ - # Rust tools - alejandra - (pkgs.fenix.stable.withComponents [ - "cargo" - "clippy" - "rust-src" - "rustc" - "rustfmt" - ]) - rust-analyzer - vulkan-loader - wayland - wayland-protocols - libxkbcommon - pkg-config - sccache - ]; + outputs = + inputs: + with inputs; + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ fenix.overlays.default ]; + # overlays = [cargo2nix.overlays.default]; + }; + naersk' = pkgs.callPackage naersk { }; + nbi = with pkgs; [ + # Rust tools + alejandra + (pkgs.fenix.stable.withComponents [ + "cargo" + "clippy" + "rust-src" + "rustc" + "rustfmt" + ]) + rust-analyzer + vulkan-loader + wayland + wayland-protocols + libxkbcommon + pkg-config + sccache + ]; - bi = with pkgs; [ - gcc - stdenv - gnumake - gdb - lldb - cmake - clang - libclang - makeWrapper - vulkan-headers - vulkan-loader - vulkan-tools - libGL - cargo-flamegraph + bi = with pkgs; [ + gcc + stdenv + gnumake + gdb + lldb + cmake + clang + libclang + makeWrapper + vulkan-headers + vulkan-loader + vulkan-tools + libGL + cargo-flamegraph + bacon - fontconfig - glib - alsa-lib - gst_all_1.gst-libav - gst_all_1.gst-plugins-bad - gst_all_1.gst-plugins-good - gst_all_1.gst-plugins-ugly - gst_all_1.gst-plugins-base - gst_all_1.gst-plugins-rs - gst_all_1.gst-vaapi - gst_all_1.gstreamer - # podofo - # mpv - ffmpeg-full - mupdf - # yt-dlp + fontconfig + glib + alsa-lib + gst_all_1.gst-libav + gst_all_1.gst-plugins-bad + gst_all_1.gst-plugins-good + gst_all_1.gst-plugins-ugly + gst_all_1.gst-plugins-base + gst_all_1.gst-plugins-rs + gst_all_1.gst-vaapi + gst_all_1.gstreamer + # podofo + # mpv + ffmpeg-full + mupdf + # yt-dlp - just - sqlx-cli - cargo-watch - ]; - in rec - { - devShell = pkgs.mkShell.override { - # stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.clangStdenv; - } { - nativeBuildInputs = nbi; - buildInputs = bi; - LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${ - with pkgs; - pkgs.lib.makeLibraryPath [ - pkgs.vulkan-loader - pkgs.wayland - pkgs.wayland-protocols - pkgs.libxkbcommon - pkgs.mupdf - pkgs.libclang - ] - }"; - # LIBCLANG_PATH = "${pkgs.clang}"; - DATABASE_URL = "sqlite:///home/chris/.local/share/lumina/library-db.sqlite3"; - }; - defaultPackage = naersk'.buildPackage { + just + sqlx-cli + cargo-watch + ]; + in + rec { + devShell = + pkgs.mkShell.override + { + # stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.clangStdenv; + } + { + nativeBuildInputs = nbi; + buildInputs = bi; + LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${ + with pkgs; + pkgs.lib.makeLibraryPath [ + pkgs.vulkan-loader + pkgs.wayland + pkgs.wayland-protocols + pkgs.libxkbcommon + pkgs.mupdf + pkgs.libclang + ] + }"; + # LIBCLANG_PATH = "${pkgs.clang}"; + DATABASE_URL = "sqlite:///home/chris/.local/share/lumina/library-db.sqlite3"; + }; + defaultPackage = naersk'.buildPackage { + src = ./.; + }; + packages = { + default = naersk'.buildPackage { src = ./.; }; - packages = { - default = naersk'.buildPackage { - src = ./.; - }; - }; - } - ); + }; + } + ); } diff --git a/src/core/images.rs b/src/core/images.rs index 581ad6a..eca52c4 100644 --- a/src/core/images.rs +++ b/src/core/images.rs @@ -52,7 +52,9 @@ impl Content for Image { if self.path.exists() { self.path .file_name() - .map_or("Missing image".into(), |f| f.to_string_lossy().to_string()) + .map_or("Missing image".into(), |f| { + f.to_string_lossy().to_string() + }) } else { "Missing image".into() } @@ -158,7 +160,9 @@ impl Model { } } Err(e) => { - error!("There was an error in converting images: {e}"); + error!( + "There was an error in converting images: {e}" + ); } } } diff --git a/src/core/kinds.rs b/src/core/kinds.rs index ebf4a3c..6dafbd6 100644 --- a/src/core/kinds.rs +++ b/src/core/kinds.rs @@ -21,11 +21,11 @@ pub enum ServiceItemKind { impl std::fmt::Display for ServiceItemKind { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { let s = match self { - Self::Song(s) => "song".to_owned(), - Self::Image(i) => "image".to_owned(), - Self::Video(v) => "video".to_owned(), - Self::Presentation(p) => "html".to_owned(), - Self::Content(s) => "content".to_owned(), + Self::Song(_) => "song".to_owned(), + Self::Image(_) => "image".to_owned(), + Self::Video(_) => "video".to_owned(), + Self::Presentation(_) => "html".to_owned(), + Self::Content(_) => "content".to_owned(), }; write!(f, "{s}") } @@ -76,7 +76,9 @@ impl Display for ParseError { f: &mut std::fmt::Formatter<'_>, ) -> std::fmt::Result { let message = match self { - Self::UnknownType => "The type does not exist. It needs to be one of 'song', 'video', 'image', 'presentation', or 'content'", + Self::UnknownType => { + "The type does not exist. It needs to be one of 'song', 'video', 'image', 'presentation', or 'content'" + } }; write!(f, "Error: {message}") } diff --git a/src/core/model.rs b/src/core/model.rs index 62d0c06..13ddda8 100644 --- a/src/core/model.rs +++ b/src/core/model.rs @@ -1,7 +1,6 @@ use std::mem::replace; -use cosmic::iced::Executor; -use miette::{miette, Result}; +use miette::{Result, miette}; use sqlx::{Connection, SqliteConnection}; #[derive(Debug, Clone)] @@ -46,7 +45,8 @@ impl Model { Ok(()) } - #[must_use] pub fn get_item(&self, index: i32) -> Option<&T> { + #[must_use] + pub fn get_item(&self, index: i32) -> Option<&T> { self.items.get(index as usize) } diff --git a/src/core/presentations.rs b/src/core/presentations.rs index c729563..1bae1bf 100644 --- a/src/core/presentations.rs +++ b/src/core/presentations.rs @@ -75,7 +75,9 @@ impl Content for Presentation { if self.path.exists() { self.path .file_name() - .map_or("Missing presentation".into(), |f| f.to_string_lossy().to_string()) + .map_or("Missing presentation".into(), |f| { + f.to_string_lossy().to_string() + }) } else { "Missing presentation".into() } @@ -189,14 +191,16 @@ impl ServiceTrait for Presentation { } impl Presentation { - #[must_use] pub fn new() -> Self { + #[must_use] + pub fn new() -> Self { Self { title: String::new(), ..Default::default() } } - #[must_use] pub const fn get_kind(&self) -> &PresKind { + #[must_use] + pub const fn get_kind(&self) -> &PresKind { &self.kind } } diff --git a/src/core/service_items.rs b/src/core/service_items.rs index 3f81a89..3912fa0 100644 --- a/src/core/service_items.rs +++ b/src/core/service_items.rs @@ -172,30 +172,32 @@ impl From<&Value> for ServiceItem { } else if let Some(background) = list.get(background_pos) { - if let Value::List(item) = background { match &item[0] { - Value::Symbol(Symbol(s)) - if s == "image" => - { - Self::from(&Image::from( - background, - )) + if let Value::List(item) = background { + match &item[0] { + Value::Symbol(Symbol(s)) + if s == "image" => + { + Self::from(&Image::from( + background, + )) + } + Value::Symbol(Symbol(s)) + if s == "video" => + { + Self::from(&Video::from( + background, + )) + } + Value::Symbol(Symbol(s)) + if s == "presentation" => + { + Self::from(&Presentation::from( + background, + )) + } + _ => todo!(), } - Value::Symbol(Symbol(s)) - if s == "video" => - { - Self::from(&Video::from( - background, - )) - } - Value::Symbol(Symbol(s)) - if s == "presentation" => - { - Self::from(&Presentation::from( - background, - )) - } - _ => todo!(), - } } else { + } else { error!( "There is no background here: {:?}", background diff --git a/src/core/songs.rs b/src/core/songs.rs index 5ceffe1..e9d8b9d 100644 --- a/src/core/songs.rs +++ b/src/core/songs.rs @@ -1,16 +1,15 @@ use std::{collections::HashMap, option::Option, path::PathBuf}; -use cosmic::iced::Executor; use crisp::types::{Keyword, Symbol, Value}; -use miette::{miette, IntoDiagnostic, Result}; +use miette::{IntoDiagnostic, Result, miette}; use serde::{Deserialize, Serialize}; use sqlx::{ - pool::PoolConnection, query, sqlite::SqliteRow, FromRow, Row, - Sqlite, SqliteConnection, SqlitePool, + FromRow, Row, Sqlite, SqliteConnection, SqlitePool, + pool::PoolConnection, query, sqlite::SqliteRow, }; use tracing::error; -use crate::{core::slide, Slide, SlideBuilder}; +use crate::{Slide, SlideBuilder, core::slide}; use super::{ content::Content, @@ -128,7 +127,9 @@ impl FromRow<'_, SqliteRow> for Song { })), verse_order: Some({ let str: &str = row.try_get(0)?; - str.split(' ').map(std::string::ToString::to_string).collect() + str.split(' ') + .map(std::string::ToString::to_string) + .collect() }), background: { let string: String = row.try_get(7)?; @@ -250,8 +251,7 @@ pub fn lisp_to_song(list: Vec) -> Song { .position(|v| v == &Value::Keyword(Keyword::from("title"))) { let pos = key_pos + 1; - list.get(pos) - .map_or(String::from("song"), String::from) + list.get(pos).map_or(String::from("song"), String::from) } else { String::from("song") }; @@ -625,7 +625,27 @@ You saved my soul" let lyrics = song.get_lyrics(); match lyrics { Ok(lyrics) => { - assert_eq!(vec!["From the Day\nI Am They", "When You found me,\nI was so blind\nMy sin was before me,\nI was swallowed by pride", "But out of the darkness,\nYou brought me to Your light\nYou showed me new mercy\nAnd opened up my eyes", "From the day\nYou saved my soul\n'Til the very moment\nWhen I come home", "I'll sing, I'll dance,\nMy heart will overflow\nFrom the day\nYou saved my soul", "Where brilliant light\nIs all around\nAnd endless joy\nIs the only sound", "Oh, rest my heart\nForever now\nOh, in Your arms\nI'll always be found", "From the day\nYou saved my soul\n'Til the very moment\nWhen I come home", "I'll sing, I'll dance,\nMy heart will overflow\nFrom the day\nYou saved my soul", "My love is Yours\nMy heart is Yours\nMy life is Yours\nForever", "My love is Yours\nMy heart is Yours\nMy life is Yours\nForever", "From the day\nYou saved my soul\n'Til the very moment\nWhen I come home", "I'll sing, I'll dance,\nMy heart will overflow\nFrom the day\nYou saved my soul", "From the day\nYou saved my soul\n'Til the very moment\nWhen I come home", "I'll sing, I'll dance,\nMy heart will overflow\nFrom the day\nYou saved my soul", "Oh Oh Oh\nFrom the day\nYou saved my soul\n"], lyrics); + assert_eq!( + vec![ + "From the Day\nI Am They", + "When You found me,\nI was so blind\nMy sin was before me,\nI was swallowed by pride", + "But out of the darkness,\nYou brought me to Your light\nYou showed me new mercy\nAnd opened up my eyes", + "From the day\nYou saved my soul\n'Til the very moment\nWhen I come home", + "I'll sing, I'll dance,\nMy heart will overflow\nFrom the day\nYou saved my soul", + "Where brilliant light\nIs all around\nAnd endless joy\nIs the only sound", + "Oh, rest my heart\nForever now\nOh, in Your arms\nI'll always be found", + "From the day\nYou saved my soul\n'Til the very moment\nWhen I come home", + "I'll sing, I'll dance,\nMy heart will overflow\nFrom the day\nYou saved my soul", + "My love is Yours\nMy heart is Yours\nMy life is Yours\nForever", + "My love is Yours\nMy heart is Yours\nMy life is Yours\nForever", + "From the day\nYou saved my soul\n'Til the very moment\nWhen I come home", + "I'll sing, I'll dance,\nMy heart will overflow\nFrom the day\nYou saved my soul", + "From the day\nYou saved my soul\n'Til the very moment\nWhen I come home", + "I'll sing, I'll dance,\nMy heart will overflow\nFrom the day\nYou saved my soul", + "Oh Oh Oh\nFrom the day\nYou saved my soul\n" + ], + lyrics + ); } Err(e) => { assert!(false, "{:?}", e) diff --git a/src/core/videos.rs b/src/core/videos.rs index 11729f7..f31aa20 100644 --- a/src/core/videos.rs +++ b/src/core/videos.rs @@ -7,13 +7,12 @@ use super::{ service_items::ServiceTrait, slide::Slide, }; -use cosmic::iced::Executor; use crisp::types::{Keyword, Symbol, Value}; use miette::{IntoDiagnostic, Result}; use serde::{Deserialize, Serialize}; use sqlx::{ - pool::PoolConnection, query, query_as, Sqlite, SqliteConnection, - SqlitePool, + Sqlite, SqliteConnection, SqlitePool, pool::PoolConnection, + query, query_as, }; use std::path::PathBuf; use tracing::error; @@ -57,7 +56,9 @@ impl Content for Video { if self.path.exists() { self.path .file_name() - .map_or("Missing video".into(), |f| f.to_string_lossy().to_string()) + .map_or("Missing video".into(), |f| { + f.to_string_lossy().to_string() + }) } else { "Missing video".into() } @@ -196,7 +197,9 @@ impl Model