-
-
Notifications
You must be signed in to change notification settings - Fork 93
nixos: add --target-host and --build-host options
#276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
477b751
22f08fa
34e2aa5
20219ad
e7eebb5
280e852
067380d
83574dd
75e09d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| extern crate semver; | ||
|
|
||
| use std::path::{Path, PathBuf}; | ||
| use std::process::Command; | ||
| use std::process::{Command, Stdio}; | ||
| use std::str; | ||
|
|
||
| use color_eyre::{eyre, Result}; | ||
|
|
@@ -59,6 +59,47 @@ pub fn get_nix_version() -> Result<String> { | |
| Err(eyre::eyre!("Failed to extract version")) | ||
| } | ||
|
|
||
| /// Retrieves the current system we're running on in the format nix expects | ||
| /// | ||
| /// This functions just runs `nix eval --impure --raw --expr 'builtins.currentSystem'` and gets the | ||
| /// output | ||
| /// | ||
| /// * `Result<String>` - The current system string or an error if the version cannot be retrieved. | ||
| pub fn get_current_system() -> Result<String> { | ||
| let output = Command::new("nix") | ||
| .args([ | ||
| "eval", | ||
| "--impure", | ||
| "--raw", | ||
| "--expr", | ||
| "builtins.currentSystem", | ||
| ]) | ||
| .output()?; | ||
| let output_str = str::from_utf8(&output.stdout)?; | ||
| Ok(output_str.to_string()) | ||
| } | ||
|
||
|
|
||
| /// Prompts the user for ssh key login if needed | ||
| pub fn ensure_ssh_key_login() -> Result<()> { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't want to be too nitpicky, but there are three things I would like to note here:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not nipicky at all, youre right, i should make sure to not unwrap at the call site so that we arent ever dependant on ssh-add |
||
| // ssh-add -L checks if there are any currently usable ssh keys | ||
|
|
||
| if Command::new("ssh-add") | ||
| .arg("-L") | ||
| .stdout(Stdio::null()) | ||
| .status()? | ||
| .success() | ||
| { | ||
| return Ok(()); | ||
| } | ||
| Command::new("ssh-add") | ||
| .stdin(Stdio::inherit()) | ||
| .stdout(Stdio::inherit()) | ||
| .stderr(Stdio::inherit()) | ||
| .spawn()? | ||
| .wait()?; | ||
| Ok(()) | ||
| } | ||
|
|
||
| pub trait MaybeTempPath: std::fmt::Debug { | ||
| fn get_path(&self) -> &Path; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure that
cmd.to_cmdline_lossy()doesn't passunescapedinputs to the SSH command? I can't exactly imagine an "attack" vector here, but this seems a little dangerous.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did check that i did do escaping when implementing it, not as much for security as in the case of it would break on weird input like a
'or smth, i cant vouch for their implementation of escaping being correct, but they atleast do something