tool for me to use if i drop nixos
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

derivation building works, got an executable in my demeter store.

IamPyu 78df2e64 b22f4e0c

+37 -30
+1 -1
Cargo.toml
··· 23 23 clap = { version = "4.6.0", features = ["derive"] } 24 24 bytes = "1.11.1" 25 25 semver = "1.0.27" 26 - hyper = "1.8.1" 26 + hyper = { version = "1.8.1", features = ["client"] } 27 27 mime = "0.3.17" 28 28 indexmap = "2.13.0" 29 29 strum = { version = "0.28.0", features = ["derive"] }
+17
crates/demeter/examples/wrap.rs
··· 1 + use std::collections::HashMap; 2 + 3 + use demeter::derivation::{IntoDerivation, builders::WrapProgram}; 4 + 5 + fn main() { 6 + let builder = WrapProgram { 7 + name: "hello".to_owned(), 8 + bin_name: "ls".to_owned(), 9 + args: vec!["-lahi".to_owned(), "--color=auto".to_owned()], 10 + env: HashMap::from([("NVIM_APPNAME".to_owned(), "custom-nvim".to_owned())]), 11 + }; 12 + let drv = builder.into_derivation().unwrap(); 13 + println!("{drv:?}"); 14 + println!("{}", drv.get_store_path().unwrap().display()); 15 + 16 + drv.run_derivation().unwrap(); 17 + }
+11 -10
crates/demeter/src/derivation.rs
··· 28 28 format!("{hash}-{name}") 29 29 } 30 30 31 - pub fn get_store_path(&self) -> PathBuf { 32 - let store = deo::get_path(deo::Path::Store); 33 - store.join(self.get_hash_name()) 31 + pub fn get_store_path(&self) -> Result<PathBuf, DerivationError> { 32 + let store = deo::get_path(deo::Path::Store)?; 33 + Ok(store.join(self.get_hash_name())) 34 34 } 35 35 36 36 pub fn run_derivation(&self) -> Result<(), DerivationError> { 37 37 let dir = tempfile::TempDir::with_prefix_in( 38 - format!("{}", self.get_hash_name()), 39 - deo::get_path(deo::Path::Builder), 38 + format!("{}-", self.get_hash_name()), 39 + deo::get_path(deo::Path::Builder)?, 40 40 )?; 41 41 log::info!("building derivation: {}", self.name); 42 42 43 43 let output = Command::new(self.builder.clone()) 44 44 .current_dir(dir.path()) 45 - .env("out", self.get_store_path()) 45 + .env("out", self.get_store_path()?) 46 46 .env("HOME", "/homeless") 47 47 .args(self.arguments.clone()) 48 48 .spawn()? ··· 57 57 } 58 58 } 59 59 60 - impl ToString for Derivation { 61 - fn to_string(&self) -> String { 62 - format!("{}", self.get_store_path().display()) 60 + impl TryInto<String> for Derivation { 61 + type Error = DerivationError; 62 + fn try_into(self) -> Result<String, Self::Error> { 63 + Ok(format!("{}", self.get_store_path()?.display())) 63 64 } 64 65 } 65 66 ··· 96 97 }; 97 98 d.get_hash(); 98 99 99 - println!("{}", d.get_store_path().display()); 100 + println!("{}", d.get_store_path().unwrap().display()); 100 101 } 101 102 }
+3 -16
crates/demeter/src/derivation/builders.rs
··· 85 85 "failed to find executable to wrap".to_owned(), 86 86 ))?; 87 87 88 - let src = format!("{env}\n{} {args}", exec.display()); 88 + let src = format!("{env}\n{} {args} $@", exec.display()); 89 89 90 90 let drv = WriteShell { 91 91 name: self.name, ··· 109 109 }; 110 110 let drv = builder.into_derivation().unwrap(); 111 111 println!("{drv:?}"); 112 - println!("{}", drv.get_store_path().display()); 112 + println!("{}", drv.get_store_path().unwrap().display()); 113 113 } 114 114 115 115 #[test] ··· 121 121 }; 122 122 let drv = builder.into_derivation().unwrap(); 123 123 println!("{drv:?}"); 124 - println!("{}", drv.get_store_path().display()); 125 - } 126 - 127 - #[test] 128 - fn wrap_program() { 129 - let builder = WrapProgram { 130 - name: "hello".to_owned(), 131 - bin_name: "nvim".to_owned(), 132 - args: vec!["--clean".to_owned()], 133 - env: HashMap::from([("NVIM_APPNAME".to_owned(), "custom-nvim".to_owned())]), 134 - }; 135 - let drv = builder.into_derivation().unwrap(); 136 - println!("{drv:?}"); 137 - println!("{}", drv.get_store_path().display()); 124 + println!("{}", drv.get_store_path().unwrap().display()); 138 125 } 139 126 }
+5 -3
crates/deo/src/lib.rs
··· 24 24 Builder, 25 25 } 26 26 27 - pub fn get_path(p: Path) -> PathBuf { 27 + pub fn get_path(p: Path) -> std::io::Result<PathBuf> { 28 28 let root = PathBuf::from(DEMETER_DIR); 29 29 30 - match p { 30 + let p = match p { 31 31 Path::Root => root, 32 32 Path::Bin => root.join("bin"), 33 33 Path::Store => root.join("store"), 34 34 Path::Builder => root.join("builder"), 35 - } 35 + }; 36 + std::fs::create_dir_all(&p)?; 37 + Ok(p) 36 38 } 37 39 38 40 /// Binary path used by demeter for generating wrappers (/var/lib/demeter/bin)