Skip to content

Commit

Permalink
src/flake.rs: Support darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
Artturin committed Aug 31, 2024
1 parent de5ae57 commit 71311b1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/flake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pub(crate) struct Flake {
/// /etc/nixos
/// github:user/nixos-config
flake: String,
/// `nixosConfigurations` or `darwinConfigurations`
configurations_attribute: String,
/// System name as an attribute in `nixosConfigurations`.
name: String,
}
Expand Down Expand Up @@ -41,12 +43,17 @@ impl Flake {
Some(fln) => fln,
};

let configurations_attribute = "nixosConfigurations";
#[cfg(target_os = "macos")]
let configurations_attribute = "darwinConfigurations";

Flake {
// TODO: try to resolve symlinks for paths in flake syntax
// like 'git+file:///etc/nixos' (if `nixos-rebuild` supports
// it).
flake: resolve_flake(flake),
name: name.to_string(),
configurations_attribute: configurations_attribute.to_string()
}
}

Expand All @@ -61,7 +68,8 @@ impl Flake {
/// TODO: not implemented yet. Just returns current system.
pub(crate) fn system_attribute(self: &Self) -> String {
format!(
"nixosConfigurations.{}.config.system.build.toplevel.drvPath",
"{}.{}.config.system.build.toplevel.drvPath",
self.configurations_attribute,
self.name
)
}
Expand Down

0 comments on commit 71311b1

Please sign in to comment.