Fix launching with flakes

This commit is contained in:
Victor Fuentes 2022-09-07 20:36:05 -04:00
parent d2060474a4
commit 5bc30308e5
No known key found for this signature in database
GPG Key ID: 0A88B68D6A9ACAE0
3 changed files with 13 additions and 26 deletions

View File

@ -12,6 +12,7 @@ pub struct InstalledPageModel {
installeduserlist: FactoryVecDeque<InstalledItemModel>,
#[tracker::no_eq]
installedsystemlist: FactoryVecDeque<InstalledItemModel>,
userpkgtype: UserPkgs,
updatetracker: u8,
}
@ -25,7 +26,7 @@ pub enum InstalledPageMsg {
#[relm4::component(pub)]
impl SimpleComponent for InstalledPageModel {
type InitParams = ();
type InitParams = UserPkgs;
type Input = InstalledPageMsg;
type Output = AppMsg;
type Widgets = InstalledPageWidgets;
@ -44,7 +45,10 @@ impl SimpleComponent for InstalledPageModel {
gtk::Label {
set_halign: gtk::Align::Start,
add_css_class: "title-4",
set_label: "User (nix-env)",
set_label: match model.userpkgtype {
UserPkgs::Env => "User (nix-env)",
UserPkgs::Profile => "User (nix profile)",
},
},
#[local_ref]
installeduserlist -> gtk::ListBox {
@ -55,7 +59,6 @@ impl SimpleComponent for InstalledPageModel {
if let Some(i) = listbox.index_of_child(row) {
sender.input(InstalledPageMsg::OpenRow(i as usize, InstallType::User))
}
// sender.input(InstalledPageMsg::OpenRow(row.clone(), InstallType::User));
}
},
gtk::Label {
@ -72,7 +75,6 @@ impl SimpleComponent for InstalledPageModel {
if let Some(i) = listbox.index_of_child(row) {
sender.input(InstalledPageMsg::OpenRow(i as usize, InstallType::System))
}
// sender.input(InstalledPageMsg::OpenRow(row.clone(), InstallType::System));
}
}
}
@ -81,7 +83,7 @@ impl SimpleComponent for InstalledPageModel {
}
fn init(
(): Self::InitParams,
userpkgtype: Self::InitParams,
root: &Self::Root,
sender: ComponentSender<Self>,
) -> ComponentParts<Self> {
@ -89,6 +91,7 @@ impl SimpleComponent for InstalledPageModel {
installeduserlist: FactoryVecDeque::new(gtk::ListBox::new(), &sender.input),
installedsystemlist: FactoryVecDeque::new(gtk::ListBox::new(), &sender.input),
updatetracker: 0,
userpkgtype,
tracker: 0
};
@ -125,15 +128,6 @@ impl SimpleComponent for InstalledPageModel {
sender.output(AppMsg::OpenPkg(pkg.to_string()));
}
}
// for (i, child) in installeduserlist_guard.widget().iter_children().enumerate() {
// if child == row {
// if let Some(item) = installeduserlist_guard.get(i) {
// if let Some(pkg) = &item.item.pkg {
// sender.output(AppMsg::OpenPkg(pkg.to_string()));
// }
// }
// }
// }
}
InstallType::System => {
let installedsystemlist_guard = self.installedsystemlist.guard();
@ -142,15 +136,6 @@ impl SimpleComponent for InstalledPageModel {
sender.output(AppMsg::OpenPkg(pkg.to_string()));
}
}
// for (i, child) in installedsystemlist_guard.widget().iter_children().enumerate() {
// if child == row {
// if let Some(item) = installedsystemlist_guard.get(i) {
// if let Some(pkg) = &item.item.pkg {
// sender.output(AppMsg::OpenPkg(pkg.to_string()));
// }
// }
// }
// }
}
}
}

View File

@ -1511,6 +1511,8 @@ impl Component for PkgModel {
.arg("shell")
.arg(&format!("nixpkgs#{}", self.pkg))
.arg("--command")
.arg("bash")
.arg("-c")
.arg(&format!("env XDG_DATA_DIRS=$XDG_DATA_DIRS:$(nix eval nixpkgs#{}.outPath --raw)/share gtk-launch {}", self.pkg, x))
.spawn();
}
@ -1522,7 +1524,7 @@ impl Component for PkgModel {
format!("nix-shell -p {} --command \"{}; $SHELL\"", self.pkg, x)
}
UserPkgs::Profile => {
format!("nix shell nixpkgs#{} --command \"{}; $SHELL\"", self.pkg, x)
format!("nix shell nixpkgs#{} --command bash -c \"{}; $SHELL\"", self.pkg, x)
}
};
launchterm(&cmd);
@ -1534,7 +1536,7 @@ impl Component for PkgModel {
format!("nix-shell -p {} --command \"{}; $SHELL\"", self.pkg, self.pname)
}
UserPkgs::Profile => {
format!("nix shell nixpkgs#{} --command \"{}; $SHELL\"", self.pkg, self.pname)
format!("nix shell nixpkgs#{} --command bash -c \"{}; $SHELL\"", self.pkg, self.pname)
}
};
launchterm(&cmd);

View File

@ -401,7 +401,7 @@ impl Component for AppModel {
.launch(())
.forward(sender.input_sender(), identity);
let installedpage = InstalledPageModel::builder()
.launch(())
.launch(userpkgtype.clone())
.forward(sender.input_sender(), identity);
let updatepage = UpdatePageModel::builder()
// ADD FLAKE DETECTION