Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ mod tests {
fn test_build_new() {
let installable = Installable::Flake {
reference: "github:user/repo".to_string(),
attribute: vec!["package".to_string()],
attribute: "package".to_string(),
};

let build = Build::new(installable.clone());
Expand All @@ -1140,7 +1140,7 @@ mod tests {
fn test_build_builder_pattern() {
let installable = Installable::Flake {
reference: "github:user/repo".to_string(),
attribute: vec!["package".to_string()],
attribute: "package".to_string(),
};

let build = Build::new(installable)
Expand Down
16 changes: 4 additions & 12 deletions src/darwin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ impl DarwinRebuildArgs {
Some(r) => r.to_owned(),
None => return Err(eyre!("NH_DARWIN_FLAKE missing reference part")),
};
let attribute = elems
.next()
.map(crate::installable::parse_attribute)
.unwrap_or_default();
let attribute = elems.next().unwrap_or_default().to_string();

Installable::Flake {
reference,
Expand All @@ -107,8 +104,7 @@ impl DarwinRebuildArgs {
// If user explicitly selects some other attribute, don't push
// darwinConfigurations
if attribute.is_empty() {
attribute.push(String::from("darwinConfigurations"));
attribute.push(hostname.clone());
*attribute = format!("darwinConfigurations.{hostname}");
}
}

Expand Down Expand Up @@ -205,10 +201,7 @@ impl DarwinReplArgs {
Some(r) => r.to_owned(),
None => return Err(eyre!("NH_DARWIN_FLAKE missing reference part")),
};
let attribute = elems
.next()
.map(crate::installable::parse_attribute)
.unwrap_or_default();
let attribute = elems.next().unwrap_or_default().to_string();

Installable::Flake {
reference,
Expand All @@ -229,8 +222,7 @@ impl DarwinReplArgs {
} = target_installable
{
if attribute.is_empty() {
attribute.push(String::from("darwinConfigurations"));
attribute.push(hostname);
*attribute = format!("darwinConfigurations.{hostname}");
}
}

Expand Down
20 changes: 7 additions & 13 deletions src/home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ impl HomeRebuildArgs {
Some(r) => r.to_owned(),
None => return Err(eyre!("NH_HOME_FLAKE missing reference part")),
};
let attribute = elems
.next()
.map(crate::installable::parse_attribute)
.unwrap_or_default();
let attribute = elems.next().unwrap_or_default().to_string();

Installable::Flake {
reference,
Expand Down Expand Up @@ -223,7 +220,7 @@ where
return Ok(res);
}

attribute.push(String::from("homeConfigurations"));
*attribute = String::from("homeConfigurations");

let flake_reference = reference.clone();
let mut found_config = false;
Expand Down Expand Up @@ -254,7 +251,7 @@ where
if check_res.map(|s| s.trim().to_owned()).as_deref() == Some("true") {
debug!("Using explicit configuration from flag: {config_name:?}");

attribute.push(config_name);
attribute.push_str(&config_name);
if push_drv {
attribute.extend(toplevel.clone());
}
Expand All @@ -264,7 +261,7 @@ where
// Explicit config provided but not found
let tried_attr_path = {
let mut attr_path = attribute.clone();
attr_path.push(config_name);
attr_path.push_str(&config_name);
Installable::Flake {
reference: flake_reference,
attribute: attr_path,
Expand Down Expand Up @@ -309,7 +306,7 @@ where

let current_try_attr = {
let mut attr_path = attribute.clone();
attr_path.push(attr_name.clone());
attr_path.push_str(&attr_name);
attr_path
};
tried.push(current_try_attr.clone());
Expand All @@ -318,7 +315,7 @@ where
check_res.map(|s| s.trim().to_owned()).as_deref()
{
debug!("Using automatically detected configuration: {}", attr_name);
attribute.push(attr_name);
attribute.push_str(&attr_name);
if push_drv {
attribute.extend(toplevel.clone());
}
Expand Down Expand Up @@ -379,10 +376,7 @@ impl HomeReplArgs {
Some(r) => r.to_owned(),
None => return Err(eyre!("NH_HOME_FLAKE missing reference part")),
};
let attribute = elems
.next()
.map(crate::installable::parse_attribute)
.unwrap_or_default();
let attribute = elems.next().unwrap_or_default().to_string();

Installable::Flake {
reference,
Expand Down
Loading
Loading