From df381f3a79484bd98e968d9fbb7a512c16dacd22 Mon Sep 17 00:00:00 2001 From: PabloMarcendo <58137448+PabloMarcendo@users.noreply.github.com> Date: Thu, 21 Sep 2023 03:05:03 +0200 Subject: [PATCH] feat: add option for nix-env arguments (#555) --- config.example.toml | 1 + src/config.rs | 11 +++++++++++ src/steps/os/unix.rs | 7 ++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/config.example.toml b/config.example.toml index b8bf78a4..b60f049a 100644 --- a/config.example.toml +++ b/config.example.toml @@ -112,6 +112,7 @@ #suse_dup = false #rpm_ostree = false #nix_arguments = "--flake" +#nix_env_arguments = "--prebuilt-only" [git] #max_concurrency = 5 diff --git a/src/config.rs b/src/config.rs index ffe21589..c5bc7ed0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -341,6 +341,9 @@ pub struct Linux { #[merge(strategy = crate::utils::merge_strategies::string_append_opt)] nix_arguments: Option, + #[merge(strategy = crate::utils::merge_strategies::string_append_opt)] + nix_env_arguments: Option, + #[merge(strategy = crate::utils::merge_strategies::string_append_opt)] apt_arguments: Option, @@ -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> { self.config_file diff --git a/src/steps/os/unix.rs b/src/steps/os/unix.rs index adf98dcd..86f9af94 100644 --- a/src/steps/os/unix.rs +++ b/src/steps/os/unix.rs @@ -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() } }