From 0cc50778e766ed61cc9c67229170328844dda62e Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Wed, 6 Mar 2024 06:38:31 +0000 Subject: [PATCH] fix(nix): add '--init none' only if systemd is not installed fix ci fix ci update README bump version code --- .fluentci/src/dagger/jobs.ts | 3 +++ .github/workflows/ci.yml | 12 +++++++++++- Cargo.lock | 4 ++-- README.md | 2 +- crates/cli/Cargo.toml | 4 ++-- crates/hm/Cargo.toml | 2 +- crates/hm/src/nix.rs | 13 +++++++++++-- 7 files changed, 31 insertions(+), 9 deletions(-) diff --git a/.fluentci/src/dagger/jobs.ts b/.fluentci/src/dagger/jobs.ts index a92b81b..b98bc02 100644 --- a/.fluentci/src/dagger/jobs.ts +++ b/.fluentci/src/dagger/jobs.ts @@ -39,6 +39,9 @@ export const test = async ( const stdout = await ctr.stdout(); console.log(stdout); + + await ctr.file("/usr/local/cargo/bin/envhub").export("./envhub"); + return stdout; }; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f62ffb4..480d8e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,4 +15,14 @@ jobs: - name: Setup Fluent CI uses: fluentci-io/setup-fluentci@v4 - name: Run Tests - run: fluentci run . test + run: | + fluentci run . test + cd demo + ../envhub init + . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh + ../envhub use + type hello + hello + ../envhub unuse + env: + CLOUDFLARE_ROOT_KEY: 123 diff --git a/Cargo.lock b/Cargo.lock index c5b04d2..85ae05a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -383,7 +383,7 @@ checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" [[package]] name = "envhub" -version = "0.2.15" +version = "0.2.16" dependencies = [ "anyhow", "clap 3.2.25", @@ -412,7 +412,7 @@ dependencies = [ [[package]] name = "envhub-hm" -version = "0.2.3" +version = "0.2.4" dependencies = [ "anyhow", "envhub-types", diff --git a/README.md b/README.md index 5eb44f1..61e8d3d 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,6 @@ You can use EnvHub as a [GitHub Action](https://github.com/tsirysndr/setup-envhu ```yaml - uses: tsirysndr/setup-envhub@v1 with: - version: 'v0.2.15' + version: 'v0.2.16' - run: envhub --help ``` diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 4aacf35..2efa0bc 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT" name = "envhub" readme = "../../README.md" repository = "https://github.com/tsirysndr/envhub" -version = "0.2.15" +version = "0.2.16" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -16,7 +16,7 @@ version = "0.2.15" anyhow = "1.0.71" clap = "3.2.20" envhub-ext = {path = "../ext", version = "0.1.1"} -envhub-hm = {path = "../hm", version = "0.2.3"} +envhub-hm = {path = "../hm", version = "0.2.4"} envhub-pkgs = {path = "../pkgs", version = "0.1.2"} envhub-providers = {path = "../providers", version = "0.2.0"} envhub-stow = {path = "../stow", version = "0.1.0"} diff --git a/crates/hm/Cargo.toml b/crates/hm/Cargo.toml index f362f96..d13ebbd 100644 --- a/crates/hm/Cargo.toml +++ b/crates/hm/Cargo.toml @@ -7,7 +7,7 @@ keywords = ["nix", "shell", "environment", "dotfiles"] license = "MIT" name = "envhub-hm" repository = "https://github.com/tsirysndr/envhub" -version = "0.2.3" +version = "0.2.4" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/hm/src/nix.rs b/crates/hm/src/nix.rs index 5fac54f..1bea380 100644 --- a/crates/hm/src/nix.rs +++ b/crates/hm/src/nix.rs @@ -18,10 +18,19 @@ pub fn install() -> Result<(), Error> { "/nix/var/nix/profiles/default/bin" ), ); + let mut child = Command::new("sh") + .arg("-c") + .arg("type systemctl > /dev/null") + .spawn()?; + let status = child.wait()?; + let init = match status.code() { + Some(0) => "", + _ => "--init none", + }; let linux = match std::env::consts::OS { - "linux" => "linux --extra-conf 'sandbox = false' --init none", - _ => "", + "linux" => format!("linux --extra-conf 'sandbox = false' {}", init), + _ => "".to_string(), }; let mut child = Command::new("sh") .arg("-c")