fix(nix): fix nix upgrade command selection for profiles in XDG_STATE_HOME (#1354)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
use color_eyre::eyre::eyre;
|
use color_eyre::eyre::eyre;
|
||||||
use color_eyre::eyre::Context;
|
use color_eyre::eyre::Context;
|
||||||
use color_eyre::eyre::Result;
|
use color_eyre::eyre::Result;
|
||||||
|
use etcetera::BaseStrategy;
|
||||||
use home;
|
use home;
|
||||||
use ini::Ini;
|
use ini::Ini;
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@@ -20,6 +21,7 @@ use tracing::{debug, warn};
|
|||||||
|
|
||||||
use crate::command::CommandExt;
|
use crate::command::CommandExt;
|
||||||
use crate::sudo::SudoExecuteOpts;
|
use crate::sudo::SudoExecuteOpts;
|
||||||
|
use crate::XDG_DIRS;
|
||||||
use crate::{output_changed_message, HOME_DIR};
|
use crate::{output_changed_message, HOME_DIR};
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@@ -427,7 +429,11 @@ pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
let nix_env = require("nix-env")?;
|
let nix_env = require("nix-env")?;
|
||||||
// TODO: Is None possible here?
|
// TODO: Is None possible here?
|
||||||
let profile_path = match home::home_dir() {
|
let profile_path = match home::home_dir() {
|
||||||
Some(home) => Path::new(&home).join(".nix-profile"),
|
Some(home) => XDG_DIRS
|
||||||
|
.state_dir()
|
||||||
|
.map(|d| d.join("nix/profile"))
|
||||||
|
.filter(|p| p.exists())
|
||||||
|
.unwrap_or(Path::new(&home).join(".nix-profile")),
|
||||||
None => Path::new("/nix/var/nix/profiles/per-user/default").into(),
|
None => Path::new("/nix/var/nix/profiles/per-user/default").into(),
|
||||||
};
|
};
|
||||||
debug!("nix profile: {:?}", profile_path);
|
debug!("nix profile: {:?}", profile_path);
|
||||||
|
|||||||
Reference in New Issue
Block a user