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