Harmonic stores itself during install (#94)
* Harmonic stores itself during install * Use provisioned harmonic to do uninstall in CI * Steam deck is a special case * Fix mac hanging
This commit is contained in:
parent
ec0071d28f
commit
5bad0ec1f5
20
.github/workflows/ci.yml
vendored
20
.github/workflows/ci.yml
vendored
|
@ -74,7 +74,7 @@ jobs:
|
|||
- name: Initial install
|
||||
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic install linux-multi --extra-conf "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" --no-confirm
|
||||
- name: Initial uninstall (without a `nix run` first)
|
||||
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic uninstall --no-confirm
|
||||
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full /nix/harmonic uninstall --no-confirm
|
||||
|
||||
- name: Repeated install
|
||||
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic install linux-multi --extra-conf "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" --no-confirm
|
||||
|
@ -83,7 +83,7 @@ jobs:
|
|||
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
|
||||
nix run nixpkgs#fortune
|
||||
- name: Repeated uninstall
|
||||
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic uninstall --no-confirm
|
||||
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full /nix/harmonic uninstall --no-confirm
|
||||
|
||||
run-steam-deck:
|
||||
name: Run Steam Deck (mock)
|
||||
|
@ -105,7 +105,9 @@ jobs:
|
|||
- name: Initial install
|
||||
run: sudo PATH=$PATH:$HOME/bin RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic install steam-deck --persistence `pwd`/ci-test-nix --extra-conf "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" --no-confirm
|
||||
- name: Initial uninstall (without a `nix run` first)
|
||||
run: sudo PATH=$PATH:$HOME/bin RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic uninstall --no-confirm
|
||||
run: |
|
||||
cp /nix/harmonic ./harmonic # Since /nix is a mount we must avoid requiring it to remain existing
|
||||
sudo PATH=$PATH:$HOME/bin RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic uninstall --no-confirm
|
||||
|
||||
- name: Repeated install
|
||||
run: sudo PATH=$PATH:$HOME/bin RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic install steam-deck --persistence `pwd`/ci-test-nix --extra-conf "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" --no-confirm
|
||||
|
@ -114,7 +116,9 @@ jobs:
|
|||
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
|
||||
nix run nixpkgs#fortune
|
||||
- name: Repeated uninstall
|
||||
run: sudo PATH=$PATH:$HOME/bin RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic uninstall --no-confirm
|
||||
run: |
|
||||
cp /nix/harmonic ./harmonic # Since /nix is a mount we must avoid requiring it to remain existing
|
||||
sudo PATH=$PATH:$HOME/bin RUST_LOG=harmonic=trace RUST_BACKTRACE=full /nix/harmonic uninstall --no-confirm
|
||||
|
||||
build-x86_64-darwin:
|
||||
name: Build x86_64 Darwin
|
||||
|
@ -149,7 +153,9 @@ jobs:
|
|||
- name: Initial install
|
||||
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic install darwin-multi --extra-conf "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" --no-confirm
|
||||
- name: Initial uninstall (without a `nix run` first)
|
||||
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic uninstall --no-confirm
|
||||
run: |
|
||||
cp /nix/harmonic ./harmonic # Since /nix is a mount we must avoid requiring it to remain existing
|
||||
sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic uninstall --no-confirm
|
||||
|
||||
- name: Repeated install
|
||||
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic install darwin-multi --extra-conf "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" --no-confirm
|
||||
|
@ -158,5 +164,7 @@ jobs:
|
|||
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
|
||||
nix run nixpkgs#fortune
|
||||
- name: Repeated uninstall
|
||||
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic uninstall --no-confirm
|
||||
run: |
|
||||
cp /nix/harmonic ./harmonic # Since /nix is a mount we must avoid requiring it to remain existing
|
||||
sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic uninstall --no-confirm
|
||||
|
|
@ -15,6 +15,13 @@ pub enum HarmonicError {
|
|||
/// An error while writing the [`InstallPlan`](crate::InstallPlan)
|
||||
#[error("Recording install receipt")]
|
||||
RecordingReceipt(PathBuf, #[source] std::io::Error),
|
||||
/// An error while writing copying the binary into the `/nix` folder
|
||||
#[error("Copying `harmonic` binary into `/nix`")]
|
||||
CopyingSelf(
|
||||
#[source]
|
||||
#[from]
|
||||
std::io::Error,
|
||||
),
|
||||
/// An error while serializing the [`InstallPlan`](crate::InstallPlan)
|
||||
#[error("Serializing receipt")]
|
||||
SerializingReceipt(
|
||||
|
|
10
src/plan.rs
10
src/plan.rs
|
@ -143,6 +143,9 @@ impl InstallPlan {
|
|||
}
|
||||
|
||||
write_receipt(self.clone()).await?;
|
||||
copy_self_to_nix_store()
|
||||
.await
|
||||
.map_err(|e| HarmonicError::CopyingSelf(e))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -283,6 +286,13 @@ fn ensure_version<'de, D: Deserializer<'de>>(d: D) -> Result<Version, D::Error>
|
|||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
async fn copy_self_to_nix_store() -> Result<(), std::io::Error> {
|
||||
let path = std::env::current_exe()?;
|
||||
tokio::fs::copy(path, "/nix/harmonic").await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use semver::Version;
|
||||
|
|
Loading…
Reference in a new issue