61 lines
2.4 KiB
Diff
61 lines
2.4 KiB
Diff
|
|
diff --git a/crates/core/src/upgrade/mod.rs b/crates/core/src/upgrade/mod.rs
|
||
|
|
index c5f3b87..c4fdd34 100644
|
||
|
|
--- a/crates/core/src/upgrade/mod.rs
|
||
|
|
+++ b/crates/core/src/upgrade/mod.rs
|
||
|
|
@@ -56,6 +56,9 @@ pub enum Origin {
|
||
|
|
Checkout { repo: PathBuf },
|
||
|
|
/// `cargo install`.
|
||
|
|
Cargo,
|
||
|
|
+ /// A Nix package, run from the store: Nix updates it with the rest of
|
||
|
|
+ /// the system or profile.
|
||
|
|
+ Nix,
|
||
|
|
/// None of these.
|
||
|
|
Unknown,
|
||
|
|
}
|
||
|
|
@@ -73,6 +76,10 @@ impl Origin {
|
||
|
|
/// where the system's own directories are read from.
|
||
|
|
pub fn detect_at(exe: &Path, home: &Path, cargo_home: Option<&Path>, root: &Path) -> Self {
|
||
|
|
let bin_dir = exe.parent().unwrap_or(Path::new("/"));
|
||
|
|
+ // Read-only and owned by Nix, whichever profile or wrapper started it.
|
||
|
|
+ if exe.starts_with("/nix/store") {
|
||
|
|
+ return Self::Nix;
|
||
|
|
+ }
|
||
|
|
if bin_dir == home.join(".local/bin") {
|
||
|
|
return Self::Installer { bin_dir: bin_dir.to_path_buf() };
|
||
|
|
}
|
||
|
|
@@ -154,6 +161,11 @@ impl Origin {
|
||
|
|
)],
|
||
|
|
note: "This Lightforge was installed with cargo.".to_owned(),
|
||
|
|
},
|
||
|
|
+ Self::Nix => say(
|
||
|
|
+ &[],
|
||
|
|
+ "Lightforge comes from Nix, which updates it: once the package or flake \
|
||
|
|
+ input has the new version, rebuild your system or profile.",
|
||
|
|
+ ),
|
||
|
|
Self::Unknown => say(
|
||
|
|
&[INSTALLER_COMMAND],
|
||
|
|
"Lightforge cannot tell how it was installed here. The installer puts it \
|
||
|
|
@@ -326,6 +338,10 @@ mod tests {
|
||
|
|
);
|
||
|
|
assert_eq!(detect("/home/u/.cargo/bin/lightforge-gui", &empty), Origin::Cargo);
|
||
|
|
assert_eq!(detect("/opt/lightforge/lightforge-gui", &empty), Origin::Unknown);
|
||
|
|
+ assert_eq!(
|
||
|
|
+ detect("/nix/store/00000000000000000000000000000000-lightforge/bin/lightforge-gui", &empty),
|
||
|
|
+ Origin::Nix
|
||
|
|
+ );
|
||
|
|
let _ = std::fs::remove_dir_all(&empty);
|
||
|
|
}
|
||
|
|
|
||
|
|
diff --git a/crates/launcher-gui/src/tests.rs b/crates/launcher-gui/src/tests.rs
|
||
|
|
index 79c7465..e089466 100644
|
||
|
|
--- a/crates/launcher-gui/src/tests.rs
|
||
|
|
+++ b/crates/launcher-gui/src/tests.rs
|
||
|
|
@@ -1190,6 +1190,7 @@ fn the_update_card_draws_for_every_route_and_stage() {
|
||
|
|
Origin::Deb,
|
||
|
|
Origin::Copr { atomic: true },
|
||
|
|
Origin::Checkout { repo: "/home/u/lightforge".into() },
|
||
|
|
+ Origin::Nix,
|
||
|
|
Origin::Unknown,
|
||
|
|
];
|
||
|
|
let stages = [
|