diff --git a/flake.nix b/flake.nix index e41a803..84f3dd5 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "Rust flake"; + description = "mdf-blog"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; # or whatever vers @@ -16,6 +16,14 @@ }; in { + defaultPackage = pkgs.rustPlatform.buildRustPackage { + name = "mdf-blog"; + pname = "mdf-blog"; + src = ./.; + cargoLock = { + lockFile = ./Cargo.lock; + }; + }; devShell = pkgs.mkShell { packages = with pkgs; [ rustc diff --git a/mdf-blog-arx b/mdf-blog-arx new file mode 120000 index 0000000..b59f124 --- /dev/null +++ b/mdf-blog-arx @@ -0,0 +1 @@ +/nix/store/w9v2s1d9s1039lgskl8mqp81lqxlb160-mdf-blog-arx \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 41ec8ff..00dc41e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,9 +2,10 @@ use std::{collections::HashMap, io, path::Path}; use markdown::to_html; use rss::{Channel, ChannelBuilder, GuidBuilder, Item, ItemBuilder}; -fn main() -> io::Result<()> { +fn main() -> Result<(), String> { let posts = std::env::args().skip(2).map(|f| { - let contents = std::fs::read_to_string(f.clone())?; + let contents = std::fs::read_to_string(f.clone()).map_err(|e| format!("when reading file {f} got {e}"))?; + // parse metadata, then the rest to html let mut metadata: HashMap = contents.lines().take_while(|l| { // header ends here @@ -26,7 +27,7 @@ fn main() -> io::Result<()> { }).concat(); Ok((to_html(&body), metadata)) - }).collect::)>, io::Error>>()?; + }).collect::)>, String>>()?; if let Some(mode) = std::env::args().skip(1).next() { match mode.as_str() {