Skip to content

Commit

Permalink
fix: set current USER env var
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Mar 5, 2024
1 parent f308da7 commit 9162966
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
16 changes: 14 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,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.14'
version: 'v0.2.15'
- run: envhub --help
```
5 changes: 3 additions & 2 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ license = "MIT"
name = "envhub"
readme = "../../README.md"
repository = "https://github.com/tsirysndr/envhub"
version = "0.2.14"
version = "0.2.15"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.71"
clap = "3.2.20"
envhub-ext = {path = "../ext", version = "0.1.1"}
envhub-hm = {path = "../hm", version = "0.2.2"}
envhub-hm = {path = "../hm", version = "0.2.3"}
envhub-pkgs = {path = "../pkgs", version = "0.1.2"}
envhub-providers = {path = "../providers", version = "0.2.0"}
envhub-stow = {path = "../stow", version = "0.1.0"}
Expand All @@ -27,3 +27,4 @@ inquire = "0.6.2"
owo-colors = "3.5.0"
tokio = {version = "1.28.2", features = ["full"]}
toml = "0.7.4"
users = "0.11.0"
3 changes: 2 additions & 1 deletion crates/hm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords = ["nix", "shell", "environment", "dotfiles"]
license = "MIT"
name = "envhub-hm"
repository = "https://github.com/tsirysndr/envhub"
version = "0.2.2"
version = "0.2.3"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -17,3 +17,4 @@ envhub-types = {version = "0.2.0", path = "../types"}
indexmap = {version = "1.9.3", features = ["serde"]}
nix-editor = "0.3.0"
rnix = "0.11.0"
users = "0.11.0"
8 changes: 8 additions & 0 deletions crates/hm/src/nix.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
use std::{env, process::Command};
use users::get_current_username;

use anyhow::Error;

pub fn install() -> Result<(), Error> {
let user = match get_current_username() {
Some(user) => user.to_string_lossy().to_string(),
None => "root".to_string(),
};

env::set_var("USER", user);
env::set_var(
"PATH",
format!(
Expand All @@ -11,6 +18,7 @@ pub fn install() -> Result<(), Error> {
"/nix/var/nix/profiles/default/bin"
),
);

let linux = match std::env::consts::OS {
"linux" => "linux --extra-conf 'sandbox = false' --init none",
_ => "",
Expand Down

0 comments on commit 9162966

Please sign in to comment.