Skip to content

Commit

Permalink
Add option for nix-env arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloMarcendo committed Sep 20, 2023
1 parent 2dec9db commit 575ec92
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
#suse_dup = false
#rpm_ostree = false
#nix_arguments = "--flake"
#nix_env_arguments = "--prebuilt-only"

[git]
#max_concurrency = 5
Expand Down
11 changes: 11 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ pub struct Linux {
#[merge(strategy = crate::utils::merge_strategies::string_append_opt)]
nix_arguments: Option<String>,

#[merge(strategy = crate::utils::merge_strategies::string_append_opt)]
nix_env_arguments: Option<String>,

#[merge(strategy = crate::utils::merge_strategies::string_append_opt)]
apt_arguments: Option<String>,

Expand Down Expand Up @@ -1275,6 +1278,14 @@ impl Config {
.and_then(|linux| linux.nix_arguments.as_deref())
}

/// Extra nix-env arguments
pub fn nix_env_arguments(&self) -> Option<&str> {
self.config_file
.linux
.as_ref()
.and_then(|linux| linux.nix_env_arguments.as_deref())
}

/// Extra Home Manager arguments
pub fn home_manager(&self) -> Option<&Vec<String>> {
self.config_file
Expand Down
7 changes: 6 additions & 1 deletion src/steps/os/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,12 @@ pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
.arg("--verbose")
.status_checked()
} else {
run_type.execute(nix_env).arg("--upgrade").status_checked()
let mut command = run_type.execute(nix_env);
command.arg("--upgrade");
if let Some(args) = ctx.config().nix_env_arguments() {
command.args(args.split_whitespace());
};
command.status_checked()
}
}

Expand Down

0 comments on commit 575ec92

Please sign in to comment.