Add support for nix-data generation config

This commit is contained in:
Victor Fuentes 2022-11-27 22:17:45 -05:00
parent d44916b04a
commit 9b9cb480fe
No known key found for this signature in database
GPG Key ID: 0A88B68D6A9ACAE0
8 changed files with 154 additions and 97 deletions

14
Cargo.lock generated
View File

@ -1675,7 +1675,7 @@ checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
[[package]] [[package]]
name = "nix-data" name = "nix-data"
version = "0.0.2" version = "0.0.2"
source = "git+https://github.com/snowflakelinux/nix-data#a75a234c2ffa661b6d3f6d276dc372677e5e2c74" source = "git+https://github.com/snowflakelinux/nix-data#42d0e42536627cdce50c522f161617b797f670be"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"brotli", "brotli",
@ -2461,18 +2461,18 @@ dependencies = [
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.147" version = "1.0.148"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" checksum = "e53f64bb4ba0191d6d0676e1b141ca55047d83b74f5607e6d8eb88126c52c2dc"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.147" version = "1.0.148"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2797,9 +2797,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.103" version = "1.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" checksum = "4ae548ec36cf198c0ef7710d3c230987c2d6d7bd98ad6edc0274462724c585ce"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@ -20,7 +20,7 @@ pkgs.stdenv.mkDerivation rec {
cargoDeps = pkgs.rustPlatform.fetchCargoTarball { cargoDeps = pkgs.rustPlatform.fetchCargoTarball {
inherit src; inherit src;
name = "${pname}-${version}"; name = "${pname}-${version}";
hash = "sha256-QaAWND3AF+/Bg38J0yzYzbU6FtIiBpLL21oKMa5RYwU="; hash = "sha256-OmHjQkK1MGes9hbJ0LEGdP1wA8ohAJEon0ycoNppl0E=";
}; };
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [

View File

@ -12,12 +12,18 @@ enum SubCommands {
/// Write stdin to file in path output /// Write stdin to file in path output
#[arg(short, long)] #[arg(short, long)]
output: String, output: String,
/// How many generations to keep
#[arg(short, long)]
generations: Option<u32>,
/// Run `nixos-rebuild` with the given arguments /// Run `nixos-rebuild` with the given arguments
arguments: Vec<String>, arguments: Vec<String>,
}, },
Rebuild { Rebuild {
/// Run `nixos-rebuild` with the given arguments /// Run `nixos-rebuild` with the given arguments
arguments: Vec<String>, arguments: Vec<String>,
/// How many generations to keep
#[arg(short, long)]
generations: Option<u32>,
}, },
Channel { Channel {
/// Whether to rebuild the system after updating channels /// Whether to rebuild the system after updating channels
@ -29,6 +35,9 @@ enum SubCommands {
/// Write stdin to file in path output /// Write stdin to file in path output
#[arg(short, long)] #[arg(short, long)]
output: String, output: String,
/// How many generations to keep
#[arg(short, long)]
generations: Option<u32>,
/// Run `nixos-rebuild` with the given arguments /// Run `nixos-rebuild` with the given arguments
arguments: Vec<String>, arguments: Vec<String>,
}, },
@ -45,6 +54,9 @@ enum SubCommands {
/// Write stdin to file in path output /// Write stdin to file in path output
#[arg(short, long)] #[arg(short, long)]
output: String, output: String,
/// How many generations to keep
#[arg(short, long)]
generations: Option<u32>,
/// Run `nixos-rebuild` with the given arguments /// Run `nixos-rebuild` with the given arguments
arguments: Vec<String>, arguments: Vec<String>,
}, },
@ -65,10 +77,14 @@ fn main() {
} }
match derived_subcommands { match derived_subcommands {
SubCommands::Config { output, arguments } => { SubCommands::Config {
output,
generations,
arguments,
} => {
let old = fs::read_to_string(&output); let old = fs::read_to_string(&output);
match write_file(&output) { match write_file(&output) {
Ok(_) => match rebuild(arguments) { Ok(_) => match rebuild(arguments, generations) {
Ok(_) => {} Ok(_) => {}
Err(err) => { Err(err) => {
eprintln!("{}", err); eprintln!("{}", err);
@ -86,7 +102,10 @@ fn main() {
} }
}; };
} }
SubCommands::Rebuild { arguments } => match rebuild(arguments) { SubCommands::Rebuild {
generations,
arguments,
} => match rebuild(arguments, generations) {
Ok(_) => (), Ok(_) => (),
Err(err) => { Err(err) => {
eprintln!("{}", err); eprintln!("{}", err);
@ -97,6 +116,7 @@ fn main() {
rebuild: dorebuild, rebuild: dorebuild,
update, update,
output, output,
generations,
arguments, arguments,
} => { } => {
if update { if update {
@ -108,7 +128,7 @@ fn main() {
match channel() { match channel() {
Ok(_) => { Ok(_) => {
if dorebuild { if dorebuild {
match rebuild(arguments) { match rebuild(arguments, generations) {
Ok(_) => (), Ok(_) => (),
Err(err) => { Err(err) => {
eprintln!("{}", err); eprintln!("{}", err);
@ -128,6 +148,7 @@ fn main() {
flakepath, flakepath,
update, update,
output, output,
generations,
arguments, arguments,
} => { } => {
if update { if update {
@ -139,7 +160,7 @@ fn main() {
match flake(&flakepath) { match flake(&flakepath) {
Ok(_) => { Ok(_) => {
if dorebuild { if dorebuild {
match rebuild(arguments) { match rebuild(arguments, generations) {
Ok(_) => (), Ok(_) => (),
Err(err) => { Err(err) => {
eprintln!("{}", err); eprintln!("{}", err);
@ -166,18 +187,38 @@ fn write_file(path: &str) -> Result<(), Box<dyn Error>> {
Ok(()) Ok(())
} }
fn rebuild(args: Vec<String>) -> Result<(), Box<dyn Error>> { fn rebuild(args: Vec<String>, generations: Option<u32>) -> Result<(), Box<dyn Error>> {
let mut cmd = Command::new("nixos-rebuild").args(args).spawn()?; let mut cmd = Command::new("nixos-rebuild").args(args).spawn()?;
let x = cmd.wait()?; let x = cmd.wait()?;
if x.success() { if !x.success() {
Ok(())
} else {
eprintln!("nixos-rebuild failed with exit code {}", x.code().unwrap()); eprintln!("nixos-rebuild failed with exit code {}", x.code().unwrap());
Err(Box::new(io::Error::new( return Err(Box::new(io::Error::new(
io::ErrorKind::Other, io::ErrorKind::Other,
"nixos-rebuild failed", "nixos-rebuild failed",
))) )));
} }
if let Some(g) = generations {
if g > 0 {
let mut cmd = Command::new("nix-env")
.arg("--delete-generations")
.arg("-p")
.arg("/nix/var/nix/profiles/system")
.arg(&format!("+{}", g))
.spawn()?;
let x = cmd.wait()?;
if !x.success() {
eprintln!(
"nix-env --delete-generations failed with exit code {}",
x.code().unwrap()
);
return Err(Box::new(io::Error::new(
io::ErrorKind::Other,
"nix-env failed",
)));
}
}
}
Ok(())
} }
fn channel() -> Result<(), Box<dyn Error>> { fn channel() -> Result<(), Box<dyn Error>> {

View File

@ -228,7 +228,6 @@ impl FactoryComponent for InstalledItemModel {
type Init = InstalledItem; type Init = InstalledItem;
type Input = InstalledItemInputMsg; type Input = InstalledItemInputMsg;
type Output = InstalledItemMsg; type Output = InstalledItemMsg;
type Widgets = InstalledItemWidgets;
type ParentWidget = adw::gtk::ListBox; type ParentWidget = adw::gtk::ListBox;
type ParentInput = InstalledPageMsg; type ParentInput = InstalledPageMsg;

View File

@ -16,8 +16,7 @@ pub struct InstallAsyncHandler {
#[tracker::no_eq] #[tracker::no_eq]
process: Option<JoinHandle<()>>, process: Option<JoinHandle<()>>,
work: Option<WorkPkg>, work: Option<WorkPkg>,
systemconfig: Option<String>, config: NixDataConfig,
flakeargs: Option<String>,
pid: Option<u32>, pid: Option<u32>,
syspkgs: SystemPkgs, syspkgs: SystemPkgs,
userpkgs: UserPkgs, userpkgs: UserPkgs,
@ -47,8 +46,12 @@ impl Worker for InstallAsyncHandler {
Self { Self {
process: None, process: None,
work: None, work: None,
systemconfig: None, config: NixDataConfig {
flakeargs: None, systemconfig: None,
flake: None,
flakearg: None,
generations: None
},
pid: None, pid: None,
syspkgs: params.syspkgs, syspkgs: params.syspkgs,
userpkgs: params.userpkgs, userpkgs: params.userpkgs,
@ -60,16 +63,7 @@ impl Worker for InstallAsyncHandler {
self.reset(); self.reset();
match msg { match msg {
InstallAsyncHandlerMsg::SetConfig(config) => { InstallAsyncHandlerMsg::SetConfig(config) => {
self.systemconfig = config.systemconfig; self.config = config;
self.flakeargs = if let Some(flake) = config.flake {
if let Some(flakearg) = config.flakearg {
Some(format!("{}#{}", flake, flakearg))
} else {
Some(flake)
}
} else {
None
}
} }
InstallAsyncHandlerMsg::SetPkgTypes(syspkgs, userpkgs) => { InstallAsyncHandlerMsg::SetPkgTypes(syspkgs, userpkgs) => {
self.syspkgs = syspkgs; self.syspkgs = syspkgs;
@ -80,8 +74,7 @@ impl Worker for InstallAsyncHandler {
if work.block { if work.block {
return; return;
} }
let systemconfig = self.systemconfig.clone(); let config = self.config.clone();
let rebuildargs = self.flakeargs.clone();
match work.pkgtype { match work.pkgtype {
InstallType::User => match work.action { InstallType::User => match work.action {
PkgAction::Install => { PkgAction::Install => {
@ -268,7 +261,7 @@ impl Worker for InstallAsyncHandler {
}, },
InstallType::System => { InstallType::System => {
REBUILD_BROKER.send(RebuildMsg::Show); REBUILD_BROKER.send(RebuildMsg::Show);
if let Some(systemconfig) = systemconfig { if let Some(systemconfig) = &config.systemconfig {
match work.action { match work.action {
PkgAction::Install => { PkgAction::Install => {
info!("Installing system package: {}", work.pkg); info!("Installing system package: {}", work.pkg);
@ -276,8 +269,7 @@ impl Worker for InstallAsyncHandler {
match installsys( match installsys(
work.pkg.to_string(), work.pkg.to_string(),
work.action.clone(), work.action.clone(),
systemconfig, config,
rebuildargs,
sender.clone(), sender.clone(),
) )
.await .await
@ -305,8 +297,7 @@ impl Worker for InstallAsyncHandler {
match installsys( match installsys(
work.pkg.to_string(), work.pkg.to_string(),
work.action.clone(), work.action.clone(),
systemconfig, config,
rebuildargs,
sender.clone(), sender.clone(),
) )
.await .await
@ -350,10 +341,19 @@ impl Worker for InstallAsyncHandler {
async fn installsys( async fn installsys(
pkg: String, pkg: String,
action: PkgAction, action: PkgAction,
systemconfig: String, config: NixDataConfig,
flakeargs: Option<String>,
_sender: ComponentSender<InstallAsyncHandler>, _sender: ComponentSender<InstallAsyncHandler>,
) -> Result<bool> { ) -> Result<bool> {
let systemconfig = config.systemconfig.unwrap_or_default();
let flakeargs = if let Some(flake) = config.flake {
if let Some(flakearg) = config.flakearg {
Some(format!("{}#{}", flake, flakearg))
} else {
Some(flake)
}
} else {
None
};
let mut p = pkg; let mut p = pkg;
let f = fs::read_to_string(&systemconfig)?; let f = fs::read_to_string(&systemconfig)?;
if let Ok(s) = nix_editor::read::getwithvalue(&f, "environment.systemPackages") { if let Ok(s) = nix_editor::read::getwithvalue(&f, "environment.systemPackages") {
@ -415,6 +415,8 @@ async fn installsys(
let mut cmd = tokio::process::Command::new("pkexec") let mut cmd = tokio::process::Command::new("pkexec")
.arg(&exe) .arg(&exe)
.arg("config") .arg("config")
.arg("--generations")
.arg(config.generations.unwrap_or(0).to_string())
.arg("--output") .arg("--output")
.arg(&systemconfig) .arg(&systemconfig)
.arg("--") .arg("--")

View File

@ -17,8 +17,7 @@ use super::{
pub struct UpdateAsyncHandler { pub struct UpdateAsyncHandler {
#[tracker::no_eq] #[tracker::no_eq]
process: Option<JoinHandle<()>>, process: Option<JoinHandle<()>>,
systemconfig: String, config: NixDataConfig,
flakeargs: Option<String>,
syspkgs: SystemPkgs, syspkgs: SystemPkgs,
userpkgs: UserPkgs, userpkgs: UserPkgs,
} }
@ -60,8 +59,12 @@ impl Worker for UpdateAsyncHandler {
fn init(params: Self::Init, _sender: relm4::ComponentSender<Self>) -> Self { fn init(params: Self::Init, _sender: relm4::ComponentSender<Self>) -> Self {
Self { Self {
process: None, process: None,
systemconfig: String::new(), config: NixDataConfig {
flakeargs: None, systemconfig: None,
flake: None,
flakearg: None,
generations: None
},
syspkgs: params.syspkgs, syspkgs: params.syspkgs,
userpkgs: params.userpkgs, userpkgs: params.userpkgs,
tracker: 0, tracker: 0,
@ -71,27 +74,17 @@ impl Worker for UpdateAsyncHandler {
fn update(&mut self, msg: Self::Input, sender: ComponentSender<Self>) { fn update(&mut self, msg: Self::Input, sender: ComponentSender<Self>) {
match msg { match msg {
UpdateAsyncHandlerMsg::UpdateConfig(config) => { UpdateAsyncHandlerMsg::UpdateConfig(config) => {
self.systemconfig = config.systemconfig.unwrap_or_default(); self.config = config;
self.flakeargs = if let Some(flake) = config.flake {
if let Some(flakearg) = config.flakearg {
Some(format!("{}#{}", flake, flakearg))
} else {
Some(flake)
}
} else {
None
}
} }
UpdateAsyncHandlerMsg::UpdatePkgTypes(syspkgs, userpkgs) => { UpdateAsyncHandlerMsg::UpdatePkgTypes(syspkgs, userpkgs) => {
self.syspkgs = syspkgs; self.syspkgs = syspkgs;
self.userpkgs = userpkgs; self.userpkgs = userpkgs;
} }
UpdateAsyncHandlerMsg::UpdateSystem => { UpdateAsyncHandlerMsg::UpdateSystem => {
let systemconfig = self.systemconfig.clone(); let config = self.config.clone();
let flakeargs = self.flakeargs.clone();
let syspkgs = self.syspkgs.clone(); let syspkgs = self.syspkgs.clone();
relm4::spawn(async move { relm4::spawn(async move {
let result = runcmd(NscCmd::All, systemconfig, flakeargs, syspkgs, None).await; let result = runcmd(NscCmd::All, config, syspkgs, None).await;
match result { match result {
Ok(true) => { Ok(true) => {
sender.output(UpdatePageMsg::DoneWorking); sender.output(UpdatePageMsg::DoneWorking);
@ -104,12 +97,11 @@ impl Worker for UpdateAsyncHandler {
}); });
} }
UpdateAsyncHandlerMsg::UpdateSystemRemove(pkgs) => { UpdateAsyncHandlerMsg::UpdateSystemRemove(pkgs) => {
let systemconfig = self.systemconfig.clone(); let config = self.config.clone();
let flakeargs = self.flakeargs.clone();
let syspkgs = self.syspkgs.clone(); let syspkgs = self.syspkgs.clone();
relm4::spawn(async move { relm4::spawn(async move {
let result = let result =
runcmd(NscCmd::All, systemconfig, flakeargs, syspkgs, Some(pkgs)).await; runcmd(NscCmd::All, config, syspkgs, Some(pkgs)).await;
match result { match result {
Ok(true) => { Ok(true) => {
sender.output(UpdatePageMsg::DoneWorking); sender.output(UpdatePageMsg::DoneWorking);
@ -122,16 +114,15 @@ impl Worker for UpdateAsyncHandler {
}); });
} }
UpdateAsyncHandlerMsg::RebuildSystem => { UpdateAsyncHandlerMsg::RebuildSystem => {
let systemconfig = self.systemconfig.clone(); let config = self.config.clone();
let flakeargs = self.flakeargs.clone();
let syspkgs = self.syspkgs.clone(); let syspkgs = self.syspkgs.clone();
relm4::spawn(async move { relm4::spawn(async move {
let result = match syspkgs { let result = match syspkgs {
SystemPkgs::Legacy => { SystemPkgs::Legacy => {
runcmd(NscCmd::Rebuild, systemconfig, flakeargs, syspkgs, None).await runcmd(NscCmd::Rebuild, config, syspkgs, None).await
} }
SystemPkgs::Flake => { SystemPkgs::Flake => {
runcmd(NscCmd::All, systemconfig, flakeargs, syspkgs, None).await runcmd(NscCmd::All, config, syspkgs, None).await
} }
SystemPkgs::None => Ok(true), SystemPkgs::None => Ok(true),
}; };
@ -183,12 +174,11 @@ impl Worker for UpdateAsyncHandler {
}); });
} }
UpdateAsyncHandlerMsg::UpdateAll => { UpdateAsyncHandlerMsg::UpdateAll => {
let systemconfig = self.systemconfig.clone(); let config = self.config.clone();
let flakeargs = self.flakeargs.clone();
let syspkgs = self.syspkgs.clone(); let syspkgs = self.syspkgs.clone();
let userpkgs = self.userpkgs.clone(); let userpkgs = self.userpkgs.clone();
relm4::spawn(async move { relm4::spawn(async move {
let result = runcmd(NscCmd::All, systemconfig, flakeargs, syspkgs, None).await; let result = runcmd(NscCmd::All, config, syspkgs, None).await;
match result { match result {
Ok(true) => { Ok(true) => {
match match userpkgs { match match userpkgs {
@ -212,12 +202,17 @@ impl Worker for UpdateAsyncHandler {
}); });
} }
UpdateAsyncHandlerMsg::UpdateAllRemove(userrmpkgs, sysrmpkgs) => { UpdateAsyncHandlerMsg::UpdateAllRemove(userrmpkgs, sysrmpkgs) => {
let systemconfig = self.systemconfig.clone(); let config = self.config.clone();
let flakeargs = self.flakeargs.clone();
let syspkgs = self.syspkgs.clone(); let syspkgs = self.syspkgs.clone();
let userpkgs = self.userpkgs.clone(); let userpkgs = self.userpkgs.clone();
relm4::spawn(async move { relm4::spawn(async move {
let result = runcmd(NscCmd::All, systemconfig, flakeargs, syspkgs, Some(sysrmpkgs)).await; let result = runcmd(
NscCmd::All,
config,
syspkgs,
Some(sysrmpkgs),
)
.await;
match result { match result {
Ok(true) => { Ok(true) => {
match match userpkgs { match match userpkgs {
@ -246,11 +241,20 @@ impl Worker for UpdateAsyncHandler {
async fn runcmd( async fn runcmd(
cmd: NscCmd, cmd: NscCmd,
systemconfig: String, config: NixDataConfig,
flakeargs: Option<String>,
syspkgs: SystemPkgs, syspkgs: SystemPkgs,
rmpkgs: Option<Vec<String>>, rmpkgs: Option<Vec<String>>,
) -> Result<bool> { ) -> Result<bool> {
let systemconfig = config.systemconfig.unwrap_or_default();
let flakeargs = if let Some(flake) = config.flake {
if let Some(flakearg) = config.flakearg {
Some(format!("{}#{}", flake, flakearg))
} else {
Some(flake)
}
} else {
None
};
let f = fs::read_to_string(&systemconfig)?; let f = fs::read_to_string(&systemconfig)?;
let exe = match std::env::current_exe() { let exe = match std::env::current_exe() {
Ok(mut e) => { Ok(mut e) => {
@ -293,6 +297,8 @@ async fn runcmd(
NscCmd::Rebuild => tokio::process::Command::new("pkexec") NscCmd::Rebuild => tokio::process::Command::new("pkexec")
.arg(&exe) .arg(&exe)
.arg("rebuild") .arg("rebuild")
.arg("--generations")
.arg(config.generations.unwrap_or(0).to_string())
.arg("--") .arg("--")
.arg("switch") .arg("switch")
.args(&rebuildargs) .args(&rebuildargs)
@ -318,6 +324,8 @@ async fn runcmd(
.arg("channel") .arg("channel")
.arg("--rebuild") .arg("--rebuild")
.arg("--update") .arg("--update")
.arg("--generations")
.arg(config.generations.unwrap_or(0).to_string())
.arg("--output") .arg("--output")
.arg(&systemconfig) .arg(&systemconfig)
.arg("--") .arg("--")
@ -337,6 +345,8 @@ async fn runcmd(
.arg(&exe) .arg(&exe)
.arg("channel") .arg("channel")
.arg("--rebuild") .arg("--rebuild")
.arg("--generations")
.arg(config.generations.unwrap_or(0).to_string())
.arg("--") .arg("--")
.arg("switch") .arg("switch")
.args(&rebuildargs) .args(&rebuildargs)
@ -360,6 +370,8 @@ async fn runcmd(
.arg("--flakepath") .arg("--flakepath")
.arg(&flakepath) .arg(&flakepath)
.arg("--update") .arg("--update")
.arg("--generations")
.arg(config.generations.unwrap_or(0).to_string())
.arg("--output") .arg("--output")
.arg(&systemconfig) .arg(&systemconfig)
.arg("--") .arg("--")
@ -382,6 +394,8 @@ async fn runcmd(
.arg("--rebuild") .arg("--rebuild")
.arg("--flakepath") .arg("--flakepath")
.arg(&flakepath) .arg(&flakepath)
.arg("--generations")
.arg(config.generations.unwrap_or(0).to_string())
.arg("--") .arg("--")
.arg("switch") .arg("switch")
.arg("--impure") .arg("--impure")
@ -434,31 +448,28 @@ async fn updateprofile(rmpkgs: Option<Vec<String>>) -> Result<bool> {
if let Some(rmpkgs) = rmpkgs { if let Some(rmpkgs) = rmpkgs {
if !rmpkgs.is_empty() { if !rmpkgs.is_empty() {
let mut cmd = tokio::process::Command::new("nix") let mut cmd = tokio::process::Command::new("nix")
.arg("profile") .arg("profile")
.arg("remove") .arg("remove")
.args( .args(
&rmpkgs &rmpkgs
.iter() .iter()
.map(|x| format!( .map(|x| format!("legacyPackages.x86_64-linux.{}", x))
"legacyPackages.x86_64-linux.{}", .collect::<Vec<String>>(),
x
))
.collect::<Vec<String>>()
) )
// Allow updating potential unfree packages // Allow updating potential unfree packages
.arg("--impure") .arg("--impure")
.stderr(Stdio::piped()) .stderr(Stdio::piped())
.spawn()?; .spawn()?;
let stderr = cmd.stderr.take().unwrap(); let stderr = cmd.stderr.take().unwrap();
let reader = tokio::io::BufReader::new(stderr); let reader = tokio::io::BufReader::new(stderr);
let mut lines = reader.lines(); let mut lines = reader.lines();
while let Ok(Some(line)) = lines.next_line().await { while let Ok(Some(line)) = lines.next_line().await {
REBUILD_BROKER.send(RebuildMsg::UpdateText(line.to_string())); REBUILD_BROKER.send(RebuildMsg::UpdateText(line.to_string()));
trace!("CAUGHT NIX PROFILE LINE: {}", line); trace!("CAUGHT NIX PROFILE LINE: {}", line);
} }
cmd.wait().await?; cmd.wait().await?;
} }
} }

View File

@ -224,6 +224,7 @@ impl SimpleComponent for WelcomeModel {
systemconfig: self.confpath.as_ref().map(|x| x.to_string_lossy().to_string()), systemconfig: self.confpath.as_ref().map(|x| x.to_string_lossy().to_string()),
flake: self.flakepath.as_ref().map(|x| x.to_string_lossy().to_string()), flake: self.flakepath.as_ref().map(|x| x.to_string_lossy().to_string()),
flakearg: None, flakearg: None,
generations: None,
}; };
sender.output(AppMsg::LoadConfig(config)); sender.output(AppMsg::LoadConfig(config));
self.hidden = true; self.hidden = true;

View File

@ -415,6 +415,7 @@ impl Component for AppModel {
systemconfig: None, systemconfig: None,
flake: None, flake: None,
flakearg: None, flakearg: None,
generations: None,
}, },
true, true,
) )
@ -673,6 +674,7 @@ impl Component for AppModel {
systemconfig: systemconfig.clone(), systemconfig: systemconfig.clone(),
flake: self.config.flake.clone(), flake: self.config.flake.clone(),
flakearg: self.config.flakearg.clone(), flakearg: self.config.flakearg.clone(),
generations: self.config.generations,
}; };
if editconfig(self.config.clone()).is_err() { if editconfig(self.config.clone()).is_err() {
warn!("Failed to update config"); warn!("Failed to update config");
@ -711,6 +713,7 @@ impl Component for AppModel {
systemconfig: self.config.systemconfig.clone(), systemconfig: self.config.systemconfig.clone(),
flake: flake.clone(), flake: flake.clone(),
flakearg, flakearg,
generations: self.config.generations,
}; };
if editconfig(self.config.clone()).is_err() { if editconfig(self.config.clone()).is_err() {
warn!("Failed to update config"); warn!("Failed to update config");