From 564fd54cdb4f698158d8e65b0ecc3d641d04a347 Mon Sep 17 00:00:00 2001 From: clsty Date: Wed, 5 Nov 2025 11:51:47 +0800 Subject: [PATCH] Update dist-nix (improve install via system PM) --- sdata/dist-nix/home-manager/home.nix | 8 +-- sdata/dist-nix/install-deps.sh | 86 +++++++---------------- sdata/dist-nix/install-setups.sh | 39 ++++++++++ sdata/subcmd-install/2.setups-selector.sh | 2 +- 4 files changed, 70 insertions(+), 65 deletions(-) create mode 100644 sdata/dist-nix/install-setups.sh diff --git a/sdata/dist-nix/home-manager/home.nix b/sdata/dist-nix/home-manager/home.nix index e9646a4ab..e8f96cde2 100644 --- a/sdata/dist-nix/home-manager/home.nix +++ b/sdata/dist-nix/home-manager/home.nix @@ -87,7 +87,7 @@ #breeze-plus (https://github.com/mjkim0727/breeze-plus) (TODO: Not available as nixpkg) (Used in kde-material-you-colors config) darkly darkly-qt5 #darkly-bin (darkly is supposed to be set as the theme for Qt apps, just have not figured out how to properly set it yet.) eza #eza (Used in Fish config: `alias ls 'eza --icons'`) - #fish (Install via system PM instead) + #fish (Install via system PM instead; TODO: should install via nix in future when authentication problem fixed) fontconfig #fontconfig (Basic thing) kitty #kitty (Used in fuzzel, Hyprland, kdeglobals and Quickshell config; kitty config is also included as dots) matugen #matugen-bin (Used in Quickshell) @@ -105,7 +105,7 @@ ### illogical-impulse-hyprland hypridle #hypridle (Used for loginctl to lock session) #hyprland (Need NixGL, included elsewhere) - #hyprlock (Should not be installed via Nix) + #hyprlock (Should not be installed via Nix; TODO: should install via nix in future when authentication problem fixed) hyprpicker #hyprpicker (Used in Hyprland and Quickshell config) hyprsunset #hyprsunset (Used in Quickshell config) #xdg-desktop-portal-hyprland (DUPLICATE) @@ -114,10 +114,10 @@ ### illogical-impulse-kde kdePackages.bluedevil #bluedevil (Seems not being used anywhere, maybe a part of KDE settings panel) - #gnome-keyring #gnome-keyring (TODO: Install via system PM instead) (Provide executable gnome-keyring-daemon, used in Hyprland and Quickshell config) + #gnome-keyring #gnome-keyring (TODO: Install via system PM instead; should install via nix in future when authentication problem fixed) (Provide executable gnome-keyring-daemon, used in Hyprland and Quickshell config) networkmanager #networkmanager kdePackages.plasma-nm #plasma-nm (Seems not being used anywhere, maybe a part of KDE settings panel) - #polkit-kde-agent (TODO: Install via system PM instead) + #polkit-kde-agent (TODO: Install via system PM instead; should install via nix in future when authentication problem fixed) kdePackages.dolphin #dolphin (Used in Hyprland and Quickshell config) kdePackages.systemsettings #systemsettings (Used in Hyprland keybinds.conf) diff --git a/sdata/dist-nix/install-deps.sh b/sdata/dist-nix/install-deps.sh index 731258e87..0de7cccc7 100644 --- a/sdata/dist-nix/install-deps.sh +++ b/sdata/dist-nix/install-deps.sh @@ -45,56 +45,24 @@ function install_nix(){ echo "Please install it by yourself and then retry." return 1 } -function install_curl(){ - local cmd=curl - +function install_cmds(){ if [[ "$OS_DISTRO_ID" == "arch" || "$OS_DISTRO_ID_LIKE" == "arch" || "$OS_DISTRO_ID" == "cachyos" ]]; then + local pkgs=() + for cmd in "$@";do + # For package name which is not cmd name, use "case" syntax to replace + pkgs+=($cmd) + done x sudo pacman -Syu - x sudo pacman -S --noconfirm $cmd + x sudo pacman -S --noconfirm --needed "${pkgs[@]}" elif [[ "$OS_DISTRO_ID" == "debian" || "$OS_DISTRO_ID_LIKE" == "debian" ]]; then - x sudo apt update - x sudo apt install $cmd + local pkgs=() + for cmd in "$@";do + # For package name which is not cmd name, use "case" syntax to replace + pkgs+=($cmd) + done + x sudo apt update -y + x sudo apt install -y "${pkgs[@]}" fi - - command -v $cmd && return - echo "Failed in installing $cmd." - echo "Please install it by yourself and then retry." - return 1 -} -function install_fish(){ - local cmd=fish - - if [[ "$OS_DISTRO_ID" == "arch" || "$OS_DISTRO_ID_LIKE" == "arch" || "$OS_DISTRO_ID" == "cachyos" ]]; then - x sudo pacman -Syu - x sudo pacman -S --noconfirm $cmd - elif [[ "$OS_DISTRO_ID" == "debian" || "$OS_DISTRO_ID_LIKE" == "debian" ]]; then - x sudo apt update - x sudo apt install $cmd - fi - - command -v $cmd && return - echo "Failed in installing $cmd." - echo "Please install it by yourself and then retry." - return 1 -} -function install_swaylock(){ - local cmd=swaylock - echo "Detecting command \"$cmd\"..." - command -v $cmd && return - echo "Command \"$cmd\" not found, try to install..." - - if [[ "$OS_DISTRO_ID" == "arch" || "$OS_DISTRO_ID_LIKE" == "arch" || "$OS_DISTRO_ID" == "cachyos" ]]; then - x sudo pacman -Syu - x sudo pacman -S --noconfirm $cmd - elif [[ "$OS_DISTRO_ID" == "debian" || "$OS_DISTRO_ID_LIKE" == "debian" ]]; then - x sudo apt update - x sudo apt install $cmd - fi - - command -v $cmd && return - echo "Failed in installing $cmd." - echo "Please install it by yourself and then retry." - return 1 } function hm_deps(){ @@ -115,21 +83,19 @@ function hm_deps(){ vianix-warning -if ! command -v curl >/dev/null 2>&1;then - echo -e "${STY_YELLOW}[$0]: \"curl\" not found.${STY_RST}" - showfun install_curl - v install_curl -fi -if ! command -v fish >/dev/null 2>&1;then - echo -e "${STY_YELLOW}[$0]: \"fish\" not found.${STY_RST}" - showfun install_fish - v install_fish -fi -if ! command -v swaylock >/dev/null 2>&1;then - echo -e "${STY_YELLOW}[$0]: \"swaylock\" not found.${STY_RST}" - showfun install_swaylock - v install_swaylock +NOT_FOUND_CMDS=() +TEST_CMDS=(curl fish swaylock gnome-keyring) +for cmd in "${TEST_CMDS[@]}"; do + if ! command -v $cmd >/dev/null 2>&1;then + NOT_FOUND_CMDS+=($cmd) + fi +done +if [[ ${#NOT_FOUND_CMDS[@]} -gt 0 ]]; then + echo -e "${STY_YELLOW}[$0]: Not found: ${NOT_FOUND_CMDS[*]}.${STY_RST}" + showfun install_cmds + v install_cmds "${NOT_FOUND_CMDS[@]}" fi + if ! command -v nix >/dev/null 2>&1;then echo -e "${STY_YELLOW}[$0]: \"nix\" not found.${STY_RST}" showfun install_nix diff --git a/sdata/dist-nix/install-setups.sh b/sdata/dist-nix/install-setups.sh new file mode 100644 index 000000000..0ddcfcf37 --- /dev/null +++ b/sdata/dist-nix/install-setups.sh @@ -0,0 +1,39 @@ +# This script is meant to be sourced. +# It's not for directly running. + +##################################################################################### +# These python packages are installed using uv into the venv (virtual environment). Once the folder of the venv gets deleted, they are all gone cleanly. So it's considered as setups, not dependencies. +showfun install-python-packages +v install-python-packages + +if [[ -z $(getent group i2c) ]]; then + v sudo groupadd i2c +fi + +v sudo usermod -aG video,i2c,input "$(whoami)" + +if [[ ! -z $(systemctl --version) ]]; then + v bash -c "echo i2c-dev | sudo tee /etc/modules-load.d/i2c-dev.conf" + # TODO: find a proper way for enable Nix installed ydotool + if ! [[ "${INSTALL_VIA_NIX}" == true ]]; then + v systemctl --user enable ydotool --now + fi + v sudo systemctl enable bluetooth --now +elif [[ ! -z $(openrc --version) ]]; then + v bash -c "echo 'modules=i2c-dev' | sudo tee -a /etc/conf.d/modules" + v sudo rc-update add modules boot + v sudo rc-update add ydotool default + v sudo rc-update add bluetooth default + + x sudo rc-service ydotool start + x sudo rc-service bluetooth start +else + printf "${STY_RED}" + printf "====================INIT SYSTEM NOT FOUND====================\n" + printf "${STY_RST}" + pause +fi + +v gsettings set org.gnome.desktop.interface font-name 'Rubik 11' +v gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' +v kwriteconfig6 --file kdeglobals --group KDE --key widgetStyle Darkly diff --git a/sdata/subcmd-install/2.setups-selector.sh b/sdata/subcmd-install/2.setups-selector.sh index e4c8e612d..0a72e8728 100644 --- a/sdata/subcmd-install/2.setups-selector.sh +++ b/sdata/subcmd-install/2.setups-selector.sh @@ -19,7 +19,7 @@ export OS_DISTRO_ID_LIKE=$(awk -F'=' '/^ID_LIKE=/ { gsub("\"","",$2); print tolo if [[ "$INSTALL_VIA_NIX" == "true" ]]; then - TARGET_ID=fallback + TARGET_ID=nix printf "${STY_YELLOW}" printf "===WARNING===\n" printf "./sdata/dist-${TARGET_ID}/install-setups.sh will be used.\n"