refactor: replace home dependency with std::env::home_dir
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -2988,7 +2988,6 @@ dependencies = [
|
|||||||
"futures",
|
"futures",
|
||||||
"glob",
|
"glob",
|
||||||
"globset",
|
"globset",
|
||||||
"home",
|
|
||||||
"ignore",
|
"ignore",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"is_elevated",
|
"is_elevated",
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ edition = "2021"
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
home = "=0.5.11"
|
|
||||||
etcetera = "=0.10.0"
|
etcetera = "=0.10.0"
|
||||||
serde = { version = "~1.0", features = ["derive"] }
|
serde = { version = "~1.0", features = ["derive"] }
|
||||||
toml = { version = "=0.9.8", features = ["preserve_order"] }
|
toml = { version = "=0.9.8", features = ["preserve_order"] }
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#![allow(clippy::cognitive_complexity)]
|
#![allow(clippy::cognitive_complexity)]
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::env::home_dir;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
@@ -48,7 +49,7 @@ mod sudo;
|
|||||||
mod terminal;
|
mod terminal;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
pub(crate) static HOME_DIR: LazyLock<PathBuf> = LazyLock::new(|| home::home_dir().expect("No home directory"));
|
pub(crate) static HOME_DIR: LazyLock<PathBuf> = LazyLock::new(|| home_dir().expect("No home directory"));
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub(crate) static XDG_DIRS: LazyLock<Xdg> = LazyLock::new(|| Xdg::new().expect("No home directory"));
|
pub(crate) static XDG_DIRS: LazyLock<Xdg> = LazyLock::new(|| Xdg::new().expect("No home directory"));
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ use color_eyre::eyre::Context;
|
|||||||
use color_eyre::eyre::Result;
|
use color_eyre::eyre::Result;
|
||||||
use color_eyre::eyre::{eyre, OptionExt};
|
use color_eyre::eyre::{eyre, OptionExt};
|
||||||
use etcetera::BaseStrategy;
|
use etcetera::BaseStrategy;
|
||||||
use home;
|
|
||||||
use ini::Ini;
|
use ini::Ini;
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
use nix::unistd::Uid;
|
use nix::unistd::Uid;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use rust_i18n::t;
|
use rust_i18n::t;
|
||||||
use semver::Version;
|
use semver::Version;
|
||||||
|
use std::env::home_dir;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::os::unix::fs::MetadataExt;
|
use std::os::unix::fs::MetadataExt;
|
||||||
@@ -526,8 +526,8 @@ pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
let nix = require("nix")?;
|
let nix = require("nix")?;
|
||||||
let nix_channel = require("nix-channel")?;
|
let nix_channel = require("nix-channel")?;
|
||||||
let nix_env = require("nix-env")?;
|
let nix_env = require("nix-env")?;
|
||||||
// TODO: Is None possible here?
|
// TODO: Is None possible here? Should we use HOME_DIR instead?
|
||||||
let profile_path = match home::home_dir() {
|
let profile_path = match home_dir() {
|
||||||
Some(home) => XDG_DIRS
|
Some(home) => XDG_DIRS
|
||||||
.state_dir()
|
.state_dir()
|
||||||
.map(|d| d.join("nix/profile"))
|
.map(|d| d.join("nix/profile"))
|
||||||
|
|||||||
Reference in New Issue
Block a user