mirror of
https://github.com/vlinkz/nix-software-center.git
synced 2024-09-11 13:35:27 +03:00
Preliminary non-NixOS support
This commit is contained in:
parent
c310668a11
commit
488f59dcf9
24
Cargo.lock
generated
24
Cargo.lock
generated
@ -45,9 +45,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ammonia"
|
||||
version = "3.2.1"
|
||||
version = "3.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4b477377562f3086b7778d241786e9406b883ccfaa03557c0fe0924b9349f13a"
|
||||
checksum = "64e6d1c7838db705c9b756557ee27c384ce695a1c51a6fe528784cb1c6840170"
|
||||
dependencies = [
|
||||
"html5ever",
|
||||
"maplit",
|
||||
@ -86,9 +86,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.58"
|
||||
version = "0.1.59"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c"
|
||||
checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -292,9 +292,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.0.27"
|
||||
version = "4.0.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0acbd8d28a0a60d7108d7ae850af6ba34cf2d1257fc646980e5f97ce14275966"
|
||||
checksum = "4d63b9e9c07271b9957ad22c173bae2a4d9a81127680962039296abcd2f8251d"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"clap_derive",
|
||||
@ -1675,7 +1675,7 @@ checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
|
||||
[[package]]
|
||||
name = "nix-data"
|
||||
version = "0.0.2"
|
||||
source = "git+https://github.com/snowflakelinux/nix-data#4ddd91d514b6ce3286033398277d25a1a1a456dc"
|
||||
source = "git+https://github.com/snowflakelinux/nix-data#8185976098e741698a625f3d90c13c3a66da74a9"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"brotli",
|
||||
@ -1698,7 +1698,7 @@ version = "0.3.0-beta.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "54cc1d93deb37efb27faaf8ffbdf9d0a536a371fb0c1e9dae2bffe01ba55f65a"
|
||||
dependencies = [
|
||||
"clap 4.0.27",
|
||||
"clap 4.0.29",
|
||||
"nixpkgs-fmt",
|
||||
"owo-colors",
|
||||
"rnix",
|
||||
@ -1765,7 +1765,7 @@ dependencies = [
|
||||
name = "nsc-helper"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap 4.0.27",
|
||||
"clap 4.0.29",
|
||||
"users",
|
||||
]
|
||||
|
||||
@ -1922,7 +1922,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core 0.9.4",
|
||||
"parking_lot_core 0.9.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1941,9 +1941,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.4"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0"
|
||||
checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
|
@ -20,7 +20,7 @@ pkgs.stdenv.mkDerivation rec {
|
||||
cargoDeps = pkgs.rustPlatform.fetchCargoTarball {
|
||||
inherit src;
|
||||
name = "${pname}-${version}";
|
||||
hash = "sha256-6iFIyW2wH4EQn5C4+35N63wylL8DSU9YWbe8NUMMnDA=";
|
||||
hash = "sha256-FSSqtcjaUInx/dG1/k06XL9beG1vJBMnuWrhybi5n3g=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
|
@ -361,7 +361,7 @@ async fn installsys(
|
||||
p = format!("pkgs.{}", p);
|
||||
}
|
||||
} else {
|
||||
return Err(anyhow!("Failed to write configuration.nix"));
|
||||
p = format!("pkgs.{}", p);
|
||||
}
|
||||
|
||||
let out = match action {
|
||||
|
@ -661,6 +661,7 @@ impl Component for PkgModel {
|
||||
add_css_class: "linked",
|
||||
set_halign: gtk::Align::Fill,
|
||||
set_hexpand: true,
|
||||
set_margin_bottom: 10,
|
||||
set_homogeneous: true,
|
||||
set_row_spacing: 5,
|
||||
set_column_spacing: 4,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use std::path::PathBuf;
|
||||
use std::path::{PathBuf, Path};
|
||||
use super::window::AppMsg;
|
||||
use adw::prelude::*;
|
||||
use nix_data::config::configfile::NixDataConfig;
|
||||
@ -47,6 +47,7 @@ impl SimpleComponent for PreferencesPageModel {
|
||||
add = &adw::PreferencesPage {
|
||||
add = &adw::PreferencesGroup {
|
||||
// set_title: "Preferences",
|
||||
set_visible: Path::new("/etc/NIXOS").exists(),
|
||||
add = &adw::ActionRow {
|
||||
set_title: "Configuration file",
|
||||
add_suffix = >k::Box {
|
||||
|
@ -2,7 +2,8 @@ use crate::{
|
||||
config,
|
||||
parse::{
|
||||
config::{editconfig, getconfig},
|
||||
packages::{AppData, LicenseEnum, PkgMaintainer, Platform}, util,
|
||||
packages::{AppData, LicenseEnum, PkgMaintainer, Platform},
|
||||
util,
|
||||
},
|
||||
ui::{
|
||||
installedpage::InstalledItem, pkgpage::PkgPageInit, rebuild::RebuildMsg,
|
||||
@ -180,7 +181,7 @@ pub enum AppAsyncMsg {
|
||||
UpdateRecPkgs(Vec<PkgTile>),
|
||||
UpdateInstalledPkgs(HashSet<String>, HashMap<String, String>),
|
||||
LoadCategory(PkgCategory, Vec<CategoryTile>, Vec<CategoryTile>),
|
||||
SetNetwork(bool)
|
||||
SetNetwork(bool),
|
||||
}
|
||||
|
||||
#[relm4::component(pub)]
|
||||
@ -448,8 +449,8 @@ impl Component for AppModel {
|
||||
} else {
|
||||
UserPkgs::Env
|
||||
};
|
||||
|
||||
let syspkgtype = if config.systemconfig.is_none() {
|
||||
let nixos = Path::new("/etc/NIXOS").exists();
|
||||
let syspkgtype = if config.systemconfig.is_none() || !nixos {
|
||||
SystemPkgs::None
|
||||
} else {
|
||||
match fs::read_to_string("/run/current-system/nixos-version") {
|
||||
@ -558,7 +559,7 @@ impl Component for AppModel {
|
||||
|
||||
sender.input(AppMsg::SetDarkMode(adw::StyleManager::default().is_dark()));
|
||||
|
||||
if welcome {
|
||||
if welcome && nixos {
|
||||
let welcomepage = WelcomeModel::builder()
|
||||
.launch(root.clone().upcast())
|
||||
.forward(sender.input_sender(), identity);
|
||||
@ -647,8 +648,8 @@ impl Component for AppModel {
|
||||
if let Err(e) = editconfig(self.config.clone()) {
|
||||
warn!("Error editing config: {}", e);
|
||||
}
|
||||
|
||||
self.syspkgtype = if self.config.systemconfig.is_none() {
|
||||
let nixos = Path::new("/etc/NIXOS").exists();
|
||||
self.syspkgtype = if self.config.systemconfig.is_none() || !nixos {
|
||||
SystemPkgs::None
|
||||
} else {
|
||||
match fs::read_to_string("/run/current-system/nixos-version") {
|
||||
@ -705,8 +706,8 @@ impl Component for AppModel {
|
||||
if editconfig(self.config.clone()).is_err() {
|
||||
warn!("Failed to update config");
|
||||
}
|
||||
|
||||
if systemconfig.is_some() {
|
||||
let nixos = Path::new("/etc/NIXOS").exists();
|
||||
if systemconfig.is_some() &&nixos {
|
||||
if self.syspkgtype == SystemPkgs::None {
|
||||
if self.config.flake.is_some() {
|
||||
self.syspkgtype = SystemPkgs::Flake;
|
||||
@ -745,10 +746,13 @@ impl Component for AppModel {
|
||||
warn!("Failed to update config");
|
||||
}
|
||||
|
||||
if flake.is_some() {
|
||||
self.syspkgtype = SystemPkgs::Flake;
|
||||
} else {
|
||||
self.syspkgtype = SystemPkgs::Legacy;
|
||||
let nixos = Path::new("/etc/NIXOS").exists();
|
||||
if nixos {
|
||||
if flake.is_some() {
|
||||
self.syspkgtype = SystemPkgs::Flake;
|
||||
} else {
|
||||
self.syspkgtype = SystemPkgs::Legacy;
|
||||
}
|
||||
}
|
||||
|
||||
self.pkgpage.emit(PkgMsg::UpdateConfig(self.config.clone()));
|
||||
|
@ -11,6 +11,7 @@ use rand::thread_rng;
|
||||
use relm4::adw::prelude::*;
|
||||
use relm4::*;
|
||||
use sqlx::SqlitePool;
|
||||
use std::path::Path;
|
||||
use std::{collections::HashMap, env};
|
||||
|
||||
pub struct WindowAsyncHandler;
|
||||
@ -39,15 +40,31 @@ impl Worker for WindowAsyncHandler {
|
||||
let mut catpicks: HashMap<PkgCategory, Vec<String>> = HashMap::new();
|
||||
let mut catpkgs: HashMap<PkgCategory, Vec<String>> = HashMap::new();
|
||||
|
||||
let pkgdb = match nix_data::cache::nixos::nixospkgs().await {
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
error!("Error getting NixOS pkgs: {}", e);
|
||||
sender.output(AppMsg::LoadError(
|
||||
String::from("Error retrieving NixOS package database"),
|
||||
e.to_string(),
|
||||
));
|
||||
return;
|
||||
let nixos = Path::new("/etc/NIXOS").exists();
|
||||
|
||||
let pkgdb = if nixos {
|
||||
match nix_data::cache::nixos::nixospkgs().await {
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
error!("Error getting NixOS pkgs: {}", e);
|
||||
sender.output(AppMsg::LoadError(
|
||||
String::from("Error retrieving NixOS package database"),
|
||||
e.to_string(),
|
||||
));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
match nix_data::cache::nonnixos::nixpkgs().await {
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
error!("Error getting nixpkgs: {}", e);
|
||||
sender.output(AppMsg::LoadError(
|
||||
String::from("Error retrieving nixpkgs package database"),
|
||||
e.to_string(),
|
||||
));
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -389,15 +406,31 @@ impl Worker for WindowAsyncHandler {
|
||||
}
|
||||
WindowAsyncHandlerMsg::UpdateDB(syspkgs, userpkgs) => {
|
||||
relm4::spawn(async move {
|
||||
let _pkgdb = match nix_data::cache::nixos::nixospkgs().await {
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
error!("Error getting NixOS pkgs: {}", e);
|
||||
sender.output(AppMsg::LoadError(
|
||||
String::from("Error retrieving NixOS package database"),
|
||||
e.to_string(),
|
||||
));
|
||||
return;
|
||||
let nixos = Path::new("/etc/NIXOS").exists();
|
||||
|
||||
let _pkgdb = if nixos {
|
||||
match nix_data::cache::nixos::nixospkgs().await {
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
error!("Error getting NixOS pkgs: {}", e);
|
||||
sender.output(AppMsg::LoadError(
|
||||
String::from("Error retrieving NixOS package database"),
|
||||
e.to_string(),
|
||||
));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
match nix_data::cache::nonnixos::nixpkgs().await {
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
error!("Error getting nixpkgs: {}", e);
|
||||
sender.output(AppMsg::LoadError(
|
||||
String::from("Error retrieving nixpkgs package database"),
|
||||
e.to_string(),
|
||||
));
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user