From 95e9530dad098e69de560a3f4d198b5c05cc53ba Mon Sep 17 00:00:00 2001 From: Rain Date: Tue, 5 Mar 2024 01:49:40 -0800 Subject: fix(build): make atuin compile on non-win/mac/linux platforms (#1825) Hi! I've been trying to get atuin set up on the illumos machine I built for work @oxidecomputer, and I ran into a few issues which are fixed here: 1. The `clipboard` feature was only supported on Windows, Mac and Linux. I've added a platform gate for that. 2. The `atomic-write-file` crate needed an update to the version of `nix` -- that is included. 3. As part of this, I found a [security bug](https://rustsec.org/advisories/RUSTSEC-2024-0020.html) in the whoami crate. The bug has been fixed upstream and I've included it. whoami 1.5.0 deprecates the `hostname` function, which produced some fresh warnings. While fixing the warnings I also took the liberty of doing some code rearrangement, adding a few functions that wrap some common operations. I didn't really know where to put those functions, so I created a new `utils` module for it. If you have a better place to put them, I'm happy to change the PR. Feel free to make any changes to this PR if you like before landing it, or to ask for review. As a followup I'm also happy to set up a cross-compile build for atuin on illumos. It's a bit harder to run tests in CI for illumos at the moment, but I'm trying to get a project started up to make that happen in the future as well. --- atuin-client/src/database.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'atuin-client/src/database.rs') diff --git a/atuin-client/src/database.rs b/atuin-client/src/database.rs index 2be27ac8..8d64bf36 100644 --- a/atuin-client/src/database.rs +++ b/atuin-client/src/database.rs @@ -21,7 +21,10 @@ use sqlx::{ }; use time::OffsetDateTime; -use crate::history::{HistoryId, HistoryStats}; +use crate::{ + history::{HistoryId, HistoryStats}, + utils::get_host_user, +}; use super::{ history::History, @@ -55,11 +58,7 @@ pub fn current_context() -> Context { eprintln!("ERROR: Failed to find $ATUIN_SESSION in the environment. Check that you have correctly set up your shell."); std::process::exit(1); }; - let hostname = format!( - "{}:{}", - env::var("ATUIN_HOST_NAME").unwrap_or_else(|_| whoami::hostname()), - env::var("ATUIN_HOST_USER").unwrap_or_else(|_| whoami::username()) - ); + let hostname = get_host_user(); let cwd = utils::get_current_dir(); let host_id = Settings::host_id().expect("failed to load host ID"); let git_root = utils::in_git_repo(cwd.as_str()); -- cgit v1.3.1