feat: extra arguments for Home Manager (#507)

* feat: extra arguments for Home Manager
This commit is contained in:
SteveLauC
2023-07-24 13:07:55 +08:00
committed by GitHub
parent 1307d2d7e8
commit 635bfce198
3 changed files with 23 additions and 1 deletions

View File

@@ -57,6 +57,9 @@
# Whether to self update (this is ignored if the binary has been built without self update support, available also via setting the environment variable TOPGRADE_NO_SELF_UPGRADE) # Whether to self update (this is ignored if the binary has been built without self update support, available also via setting the environment variable TOPGRADE_NO_SELF_UPGRADE)
#no_self_update = true #no_self_update = true
# Extra Home Manager arguments
#home_manager_arguments = ["--flake", "file"]
# Commands to run before anything # Commands to run before anything
[pre_commands] [pre_commands]
#"Emacs Snapshot" = "rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak" #"Emacs Snapshot" = "rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak"

View File

@@ -351,6 +351,9 @@ pub struct Linux {
#[merge(strategy = crate::utils::merge_strategies::string_append_opt)] #[merge(strategy = crate::utils::merge_strategies::string_append_opt)]
emerge_update_flags: Option<String>, emerge_update_flags: Option<String>,
#[merge(strategy = crate::utils::merge_strategies::vec_prepend_opt)]
home_manager_arguments: Option<Vec<String>>,
} }
#[derive(Deserialize, Default, Debug, Merge)] #[derive(Deserialize, Default, Debug, Merge)]
@@ -1275,6 +1278,14 @@ impl Config {
.and_then(|linux| linux.nix_arguments.as_deref()) .and_then(|linux| linux.nix_arguments.as_deref())
} }
/// Extra Home Manager arguments
pub fn home_manager(&self) -> Option<&Vec<String>> {
self.config_file
.linux
.as_ref()
.and_then(|misc| misc.home_manager_arguments.as_ref())
}
/// Distrobox use root /// Distrobox use root
pub fn distrobox_root(&self) -> bool { pub fn distrobox_root(&self) -> bool {
self.config_file self.config_file

View File

@@ -442,7 +442,15 @@ pub fn run_home_manager(ctx: &ExecutionContext) -> Result<()> {
let home_manager = require("home-manager")?; let home_manager = require("home-manager")?;
print_separator("home-manager"); print_separator("home-manager");
ctx.run_type().execute(home_manager).arg("switch").status_checked()
let mut cmd = ctx.run_type().execute(home_manager);
cmd.arg("switch");
if let Some(extra_args) = ctx.config().home_manager() {
cmd.args(extra_args);
}
cmd.status_checked()
} }
pub fn run_tldr(ctx: &ExecutionContext) -> Result<()> { pub fn run_tldr(ctx: &ExecutionContext) -> Result<()> {