From dfbdb4ac5bb1d768c813b7f971ce6b51bc0c1941 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Wed, 13 Nov 2024 15:59:28 +0000 Subject: [PATCH] refactor: use nix build to update profile generation --- --- a/cmds/fleet/src/cmds/build_systems.rs +++ b/cmds/fleet/src/cmds/build_systems.rs @@ -175,12 +175,15 @@ } if action.should_switch_profile() && !failed { - info!("switching generation"); - let mut cmd = host.cmd("nix-env").await?; - cmd.comparg("--profile", "/nix/var/nix/profiles/system") - .comparg("--set", &built); - if let Err(e) = cmd.sudo().run().await { - error!("failed to switch generation: {e}"); + info!("switching system profile generation"); + // It would also be possible to update profile atomically during copy: + // https://github.com/NixOS/nix/pull/11657 + let mut cmd = host.cmd("nix").await?; + cmd.arg("build"); + cmd.comparg("--profile", "/nix/var/nix/profiles/system"); + cmd.arg(&built); + if let Err(e) = cmd.sudo().run_nix().await { + error!("failed to switch system profile generation: {e}"); failed = true; } } -- gitstuff