feat: implement modular foundation and core system services

- Update flake.nix with 25.11 release and core inputs
- Add dedicated modules for audio (Pipewire), bluetooth, and networking
- Update GEMINI.md with the new Modular Merging Architecture blueprint
- Configure graphical installer ISO and test VM outputs
This commit is contained in:
Bernardo Magri
2026-04-03 21:06:42 +01:00
parent 33deeb494b
commit 29cc0d2547
49 changed files with 1628 additions and 855 deletions

View File

@@ -1,46 +1,36 @@
#!/bin/bash
#!/usr/bin/env bash
# Set the system-wide monospace font that should be used by the terminal, hyprlock, waybar, swayosd, etc.
# The font name must be one of the ones returned by nomarchy-font-list.
# Declarative version for Nomarchy NixOS.
font_name="$1"
if [[ -n $font_name ]]; then
if fc-list | grep -iq "$font_name"; then
if [[ -f ~/.config/alacritty/alacritty.toml ]]; then
sed -i "s/family = \".*\"/family = \"$font_name\"/g" ~/.config/alacritty/alacritty.toml
fi
if [[ -f ~/.config/kitty/kitty.conf ]]; then
sed -i "s/^font_family .*/font_family $font_name/g" ~/.config/kitty/kitty.conf
pkill -USR1 kitty
fi
if [[ -f ~/.config/ghostty/config ]]; then
sed -i "s/font-family = \".*\"/font-family = \"$font_name\"/g" ~/.config/ghostty/config
pkill -SIGUSR2 ghostty
fi
sed -i "s/font_family = .*/font_family = $font_name/g" ~/.config/hypr/hyprlock.conf
sed -i "s/font-family: .*/font-family: '$font_name';/g" ~/.config/waybar/style.css
sed -i "s/font-family: .*/font-family: '$font_name';/g" ~/.config/swayosd/style.css
xmlstarlet ed -L \
-u '//match[@target="pattern"][test/string="monospace"]/edit[@name="family"]/string' \
-v "$font_name" \
~/.config/fontconfig/fonts.conf
nomarchy-restart-waybar
nomarchy-restart-swayosd
if pgrep -x ghostty; then
notify-send -u low " You must restart Ghostty to see font change"
fi
nomarchy-hook font-set "$font_name"
else
echo "Font '$font_name' not found."
exit 1
fi
else
if [[ -z $font_name ]]; then
echo "Usage: nomarchy-font-set <font-name>"
exit 1
fi
STATE_DIR="$HOME/.config/home-manager"
STATE_FILE="$STATE_DIR/font-state.nix"
mkdir -p "$STATE_DIR"
if fc-list | grep -iq "$font_name"; then
echo "$font_name" > "$STATE_FILE"
echo "Font set to $font_name declaratively. Applying changes..."
env-update
# Instant feedback for certain apps via IPC
if pgrep -x kitty; then
pkill -USR1 kitty
fi
if pgrep -x ghostty; then
pkill -SIGUSR2 ghostty
notify-send -u low " You must restart Ghostty to see font change"
fi
nomarchy-hook font-set "$font_name"
else
echo "Font '$font_name' not found."
exit 1
fi

View File

@@ -1,15 +1,27 @@
#!/bin/bash
#!/usr/bin/env bash
# Toggles the window gaps globally between no gaps and the default 10/5/2.
# Toggles the window gaps globally between no gaps and the default 10/5/2, declaratively and instantly.
gaps=$(hyprctl getoption general:gaps_out -j | jq -r '.custom' | awk '{print $1}')
STATE_FILE="$HOME/.config/home-manager/hyprland-state.json"
mkdir -p "$(dirname "$STATE_FILE")"
if [ ! -f "$STATE_FILE" ]; then
echo '{"gaps_out": 10, "gaps_in": 5, "border_size": 2}' > "$STATE_FILE"
fi
gaps=$(jq -r '.gaps_out' "$STATE_FILE")
if [[ $gaps == "0" ]]; then
NEW_STATE='{"gaps_out": 10, "gaps_in": 5, "border_size": 2}'
hyprctl keyword general:gaps_out 10
hyprctl keyword general:gaps_in 5
hyprctl keyword general:border_size 2
else
NEW_STATE='{"gaps_out": 0, "gaps_in": 0, "border_size": 0}'
hyprctl keyword general:gaps_out 0
hyprctl keyword general:gaps_in 0
hyprctl keyword general:border_size 0
fi
echo "$NEW_STATE" > "$STATE_FILE"
echo "Toggled gaps to $NEW_STATE declaratively."

View File

@@ -1,6 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
# Install one of the supported development environments. Usually called via Install > Development > * in the Nomarchy Menu.
# Install one of the supported development environments declaratively.
# Usually called via Install > Development > * in the Nomarchy Menu.
if [[ -z $1 ]]; then
echo "Usage: nomarchy-install-dev-env <ruby|node|bun|deno|go|laravel|symfony|php|python|elixir|phoenix|rust|java|zig|ocaml|dotnet|clojure|scala>" >&2
@@ -8,144 +9,78 @@ if [[ -z $1 ]]; then
fi
install_php() {
nomarchy-pkg-add php composer php-sqlite xdebug
# Install Path for Composer
if [[ :$PATH: != *:$HOME/.config/composer/vendor/bin:* ]]; then
echo 'export PATH="$HOME/.config/composer/vendor/bin:$PATH"' >>"$HOME/.bashrc"
source "$HOME/.bashrc"
echo "Added Composer global bin directory to PATH."
else
echo "Composer global bin directory already in PATH."
fi
# Enable some extensions
local php_ini_path="/etc/php/php.ini"
local extensions_to_enable=(
"bcmath"
"intl"
"iconv"
"openssl"
"pdo_sqlite"
"pdo_mysql"
)
# Enable Xdebug
sudo sed -i \
-e 's/^;zend_extension=xdebug.so/zend_extension=xdebug.so/' \
-e 's/^;xdebug.mode=debug/xdebug.mode=debug/' \
/etc/php/conf.d/xdebug.ini
for ext in "${extensions_to_enable[@]}"; do
sudo sed -i "s/^;extension=${ext}/extension=${ext}/" "$php_ini_path"
done
echo -e "Installing PHP environment declaratively...\n"
nomarchy-pkg-add php
nomarchy-pkg-add phpExtensions.bcmath
nomarchy-pkg-add phpExtensions.intl
nomarchy-pkg-add phpExtensions.iconv
nomarchy-pkg-add phpExtensions.openssl
nomarchy-pkg-add phpExtensions.pdo_sqlite
nomarchy-pkg-add phpExtensions.pdo_mysql
nomarchy-pkg-add phpPackages.composer
echo -e "\nPHP environment added to your packages."
}
install_node() {
echo -e "Installing Node.js...\n"
echo -e "Installing Node.js with mise...\n"
mise use --global node
}
case "$1" in
ruby)
echo -e "Installing Ruby on Rails...\n"
echo -e "Installing Ruby with mise...\n"
nomarchy-pkg-add libyaml
mise settings add ruby.compile false
mise settings add idiomatic_version_file_enable_tools ruby
mise use --global ruby@latest
echo "gem: --no-document" >~/.gemrc
mise x ruby -- gem install rails --no-document
echo -e "\nYou can now run: rails new myproject"
echo -e "\nYou can now use: ruby --version"
;;
node)
install_node
;;
bun)
echo -e "Installing Bun...\n"
echo -e "Installing Bun with mise...\n"
mise use -g bun@latest
;;
deno)
echo -e "Installing Deno...\n"
echo -e "Installing Deno with mise...\n"
mise use -g deno@latest
;;
go)
echo -e "Installing Go...\n"
echo -e "Installing Go with mise...\n"
mise use --global go@latest
;;
php)
echo -e "Installing PHP...\n"
install_php
;;
laravel)
echo -e "Installing PHP and Laravel...\n"
echo -e "Installing Laravel stack...\n"
install_php
install_node
# Composer global packages are imperative, but that's how they work.
composer global require laravel/installer
echo -e "\nYou can now run: laravel new myproject"
;;
symfony)
echo -e "Installing PHP and Symfony...\n"
install_php
nomarchy-pkg-add symfony-cli
echo -e "\nYou can now run: symfony new --webapp myproject"
;;
python)
echo -e "Installing Python...\n"
echo -e "Installing Python with mise...\n"
mise use --global python@latest
echo -e "\nInstalling uv...\n"
curl -fsSL https://astral.sh/uv/install.sh | sh
;;
elixir)
echo -e "Installing Elixir...\n"
mise use --global erlang@latest
mise use --global elixir@latest
mise x elixir -- mix local.hex --force
;;
phoenix)
echo -e "Installing Phoenix Framework...\n"
# Ensure Erlang/Elixir first
mise use --global erlang@latest
mise use --global elixir@latest
# Hex & Rebar
mise x elixir -- mix local.hex --force
mise x elixir -- mix local.rebar --force
# Phoenix project (phx_new)
mise x elixir -- mix archive.install hex phx_new --force
echo -e "\nYou can now run: mix phx.new my_app"
# uv can be installed via nix
nomarchy-pkg-add uv
;;
rust)
echo -e "Installing Rust...\n"
bash -c "$(curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs)" -- -y
echo -e "Installing Rust declaratively...\n"
# Instead of shell script from website, use nixpkgs
nomarchy-pkg-add rustup
rustup-init -y
;;
java)
echo -e "Installing Java...\n"
mise use --global java@latest
;;
zig)
echo -e "Installing Zig...\n"
mise use --global zig@latest
mise use -g zls@latest
;;
ocaml)
echo -e "Installing OCaml...\n"
bash -c "$(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)"
opam init --yes
eval "$(opam env)"
opam install ocaml-lsp-server odoc ocamlformat utop --yes
;;
dotnet)
echo -e "Installing .NET...\n"
mise use --global dotnet@latest
;;
clojure)
echo -e "Installing Clojure...\n"
nomarchy-pkg-add rlwrap
mise use --global clojure@latest
;;
scala)
echo -e "Installing Scala...\n"
mise use --global java@latest
mise use --global scala@latest
mise use --global scala-cli@latest
# Add more language cases as needed, utilizing mise or nixpkgs.
*)
# Fallback to mise for languages that it supports
echo -e "Installing $1 with mise...\n"
if mise use --global "$1@latest"; then
echo "$1 installed successfully."
else
echo "Unsupported language: $1"
exit 1
fi
;;
esac

View File

@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Install one of the supported development environments declaratively for Nomarchy NixOS.
if [[ -z $1 ]]; then
echo "Usage: nomarchy-install-dev-env <ruby|node|bun|deno|go|laravel|symfony|php|python|elixir|phoenix|rust|java|zig|ocaml|dotnet|clojure|scala>" >&2
exit 1
fi
case "$1" in
php)
echo -e "Installing PHP and extensions declaratively...\n"
# This uses the already refactored declarative nomarchy-pkg-add
nomarchy-pkg-add php
nomarchy-pkg-add phpExtensions.bcmath
nomarchy-pkg-add phpExtensions.intl
nomarchy-pkg-add phpExtensions.iconv
nomarchy-pkg-add phpExtensions.openssl
nomarchy-pkg-add phpExtensions.pdo_sqlite
nomarchy-pkg-add phpExtensions.pdo_mysql
nomarchy-pkg-add phpPackages.composer
echo -e "\nPHP environment added to your packages."
;;
# The rest use 'mise' which is already installed and manages its own state in ~/.config/mise
*)
# Delegate to the original script logic if mise is used
# Or we can just call the mise command directly if it's a simple case.
# Let's keep the mise-based language installs as they are, but make sure mise is available.
/etc/profiles/per-user/$USER/bin/nomarchy-install-dev-env.original "$@"
;;
esac

View File

@@ -1,12 +1,30 @@
#!/bin/bash
#!/usr/bin/env bash
# Install one of the supported databases in a Docker container with the suitable development options.
# Configure Docker declaratively and provide instructions for running DBs.
# Usually called via Install > Development > Docker DB from the Nomarchy Menu.
FEATURE_FILE="/etc/nixos/nomarchy-features/docker.nix"
if [ ! -f "$FEATURE_FILE" ]; then
sudo mkdir -p "/etc/nixos/nomarchy-features"
cat <<EOF | sudo tee "$FEATURE_FILE" > /dev/null
{ config, pkgs, ... }:
{
virtualisation.docker.enable = true;
users.users.\${config.users.users.mainUser}.extraGroups = [ "docker" ]; # Replace mainUser with your username
}
EOF
echo "Created $FEATURE_FILE to enable Docker."
echo "IMPORTANT: To finish enabling Docker, add './nomarchy-features/docker.nix' to your imports list in /etc/nixos/system.nix or /etc/nixos/flake.nix,"
echo "then run 'sys-update'."
echo "Wait for the update to complete before running docker commands."
echo ""
fi
options=("MySQL" "PostgreSQL" "Redis" "MongoDB" "MariaDB" "MSSQL")
if (( $# == 0 )); then
choices=$(printf "%s\n" "${options[@]}" | gum choose --header "Select database (return to install, esc to cancel)") || main_menu
choices=$(printf "%s\n" "${options[@]}" | gum choose --header "Select database (ensure Docker is running)") || exit 0
else
choices="$@"
fi

View File

@@ -1,9 +1,23 @@
#!/bin/bash
#!/usr/bin/env bash
# Install and launch Steam after first letting the user pick the correct grahics card drivers.
# Configure Steam declaratively for NixOS
set -e
FEATURE_FILE="/etc/nixos/nomarchy-features/steam.nix"
echo "Now pick dependencies matching your graphics card"
sudo pacman -S steam
setsid gtk-launch steam >/dev/null 2>&1 &
if [ -f "$FEATURE_FILE" ]; then
echo "Steam is already configured in $FEATURE_FILE"
exit 0
fi
sudo mkdir -p "/etc/nixos/nomarchy-features"
cat <<EOF | sudo tee "$FEATURE_FILE" > /dev/null
{ config, pkgs, ... }:
{
programs.steam.enable = true;
hardware.graphics.enable32Bit = true; # Needed for many games
}
EOF
echo "Created $FEATURE_FILE."
echo "IMPORTANT: To finish enabling Steam, add './nomarchy-features/steam.nix' to your imports list in /etc/nixos/system.nix or /etc/nixos/flake.nix,"
echo "then run 'sys-update'."

View File

@@ -1,10 +1,25 @@
#!/bin/bash
#!/usr/bin/env bash
# Install the Tailscale mesh VPN service and a web app for the Tailscale Admin Console.
# Configure Tailscale declaratively for NixOS
curl -fsSL https://tailscale.com/install.sh | sh
FEATURE_FILE="/etc/nixos/nomarchy-features/tailscale.nix"
echo -e "\nStarting Tailscale..."
sudo tailscale up --accept-routes
if [ -f "$FEATURE_FILE" ]; then
echo "Tailscale is already configured in $FEATURE_FILE"
exit 0
fi
sudo mkdir -p "/etc/nixos/nomarchy-features"
cat <<EOF | sudo tee "$FEATURE_FILE" > /dev/null
{ config, pkgs, ... }:
{
services.tailscale.enable = true;
}
EOF
echo "Created $FEATURE_FILE."
echo "IMPORTANT: To finish enabling Tailscale, add './nomarchy-features/tailscale.nix' to your imports list in /etc/nixos/system.nix or /etc/nixos/flake.nix,"
echo "then run 'sys-update'."
echo "After sys-update completes, you can log in by running 'sudo tailscale up'."
nomarchy-webapp-install "Tailscale" "https://login.tailscale.com/admin/machines" https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/tailscale-light.png

View File

@@ -1,29 +1,22 @@
#!/bin/bash
#!/usr/bin/env bash
# Install VSCode and configure it to use the gnome-libsecret password store, not to update automatically, and to use the current Nomarchy theme.
# Install VSCode declaratively for Nomarchy NixOS.
echo "Installing VSCode..."
nomarchy-pkg-add visual-studio-code-bin
nomarchy-pkg-add vscode
mkdir -p ~/.vscode ~/.config/Code/User
cat > ~/.vscode/argv.json << 'EOF'
// This configuration file allows you to pass permanent command line arguments to VS Code.
// Only a subset of arguments is currently supported to reduce the likelihood of breaking
// the installation.
//
// PLEASE DO NOT CHANGE WITHOUT UNDERSTANDING THE IMPACT
//
// NOTE: Changing this file requires a restart of VS Code.
{
"password-store":"gnome-libsecret"
}
EOF
# VSCode still allows some runtime configuration in its JSON files.
mkdir -p ~/.config/Code/User
# Ensure VSC's own auto-update feature is turned off
printf '{\n "update.mode": "none"\n}\n' > ~/.config/Code/User/settings.json
if [ ! -f ~/.config/Code/User/settings.json ]; then
echo '{"update.mode": "none"}' > ~/.config/Code/User/settings.json
else
# Update existing settings.json with update.mode: none using jq
jq '. + {"update.mode": "none"}' ~/.config/Code/User/settings.json > ~/.config/Code/User/settings.json.tmp && mv ~/.config/Code/User/settings.json.tmp ~/.config/Code/User/settings.json
fi
# Apply Nomarchy theme to VSCode
nomarchy-theme-set-vscode
setsid gtk-launch code
setsid code >/dev/null 2>&1 &

View File

@@ -1,19 +1,23 @@
#!/bin/bash
#!/usr/bin/env bash
# Install support for using Xbox controllers with Steam/RetroArch/etc.
# Configure Xbox Controller support (xpadneo) declaratively for Nomarchy NixOS.
set -e
FEATURE_FILE="/etc/nixos/nomarchy-features/xbox-controller.nix"
# Install xpadneo to ensure controllers work out of the box
nomarchy-pkg-add linux-headers
nomarchy-pkg-aur-add xpadneo-dkms
if [ -f "$FEATURE_FILE" ]; then
echo "Xbox controller support is already configured in $FEATURE_FILE"
exit 0
fi
# Prevent xpad/xpadneo driver conflict
echo blacklist xpad | sudo tee /etc/modprobe.d/blacklist-xpad.conf >/dev/null
echo hid_xpadneo | sudo tee /etc/modules-load.d/xpadneo.conf >/dev/null
sudo mkdir -p "/etc/nixos/nomarchy-features"
cat <<EOF | sudo tee "$FEATURE_FILE" > /dev/null
{ config, pkgs, ... }:
{
hardware.xpadneo.enable = true;
# Note: This automatically handles blacklisting xpad if needed and provides modules.
}
EOF
# Give user access to game controllers
sudo usermod -a -G input $USER
# Modules need to be loaded
gum confirm "Install requires reboot. Ready?" && sudo reboot now
echo "Created $FEATURE_FILE."
echo "IMPORTANT: To finish enabling Xbox controller support, add './nomarchy-features/xbox-controller.nix' to your imports list in /etc/nixos/system.nix or /etc/nixos/flake.nix,"
echo "then run 'sys-update'."

75
bin/nomarchy-on-boot Executable file
View File

@@ -0,0 +1,75 @@
#!/usr/bin/env bash
# Nomarchy on-boot initialization script.
# Automatically detects the hardware, applies necessary runtime tweaks,
# and sets the correct screen resolution/scaling.
# 1. Automatically configure optimal screen resolution and scaling
nomarchy-hyprland-monitor-scaling-cycle >/dev/null 2>&1
# 2. Hardware-specific runtime tweaks
if nomarchy-hw-match "Laptop 16"; then
# Framework 16 specific tweaks
nomarchy-theme-set-keyboard-f16 >/dev/null 2>&1
fi
if nomarchy-hw-asus-rog; then
# Asus ROG specific tweaks
nomarchy-theme-set-keyboard-asus-rog >/dev/null 2>&1
fi
# 3. Declarative hardware configuration check (nixos-hardware)
# This part ensures that if we are on an installed system, the correct
# nixos-hardware module is selected in the configuration.
HW_FILE="/etc/nixos/hardware-selection.nix"
if [ -w "$HW_FILE" ]; then
PRODUCT_NAME=$(cat /sys/class/dmi/id/product_name 2>/dev/null || echo "Unknown")
BOARD_NAME=$(cat /sys/class/dmi/id/board_name 2>/dev/null || echo "Unknown")
CPU_VENDOR=$(lscpu | grep "Vendor ID" | awk '{print $3}')
NEW_HW_MODULES=""
if [[ "$CPU_VENDOR" == "AuthenticAMD" ]]; then
NEW_HW_MODULES="inputs.nixos-hardware.nixosModules.common-cpu-amd"
elif [[ "$CPU_VENDOR" == "GenuineIntel" ]]; then
NEW_HW_MODULES="inputs.nixos-hardware.nixosModules.common-cpu-intel"
fi
# Auto-detect specific known models for nixos-hardware
if echo "$PRODUCT_NAME" | grep -qi "XPS 15 9500"; then
NEW_HW_MODULES="$NEW_HW_MODULES\n inputs.nixos-hardware.nixosModules.dell-xps-15-9500"
elif echo "$PRODUCT_NAME" | grep -qi "XPS 13"; then
NEW_HW_MODULES="$NEW_HW_MODULES\n inputs.nixos-hardware.nixosModules.dell-xps-13-9300" # fallback example
elif echo "$PRODUCT_NAME" | grep -qi "Framework Laptop 16"; then
NEW_HW_MODULES="$NEW_HW_MODULES\n inputs.nixos-hardware.nixosModules.framework-16-7040-amd"
elif echo "$PRODUCT_NAME" | grep -qi "Framework Laptop 13"; then
NEW_HW_MODULES="$NEW_HW_MODULES\n inputs.nixos-hardware.nixosModules.framework-13-7040-amd"
elif echo "$PRODUCT_NAME" | grep -qi "Surface"; then
NEW_HW_MODULES="$NEW_HW_MODULES\n inputs.nixos-hardware.nixosModules.microsoft-surface-pro-8" # fallback example
elif echo "$PRODUCT_NAME" | grep -qi "Zephyrus G14"; then
NEW_HW_MODULES="$NEW_HW_MODULES\n inputs.nixos-hardware.nixosModules.asus-zephyrus-g14"
elif echo "$PRODUCT_NAME" | grep -qi "ThinkPad X1 Carbon"; then
NEW_HW_MODULES="$NEW_HW_MODULES\n inputs.nixos-hardware.nixosModules.lenovo-thinkpad-x1-carbon-gen9"
fi
# Check if the current HW file differs from our detection
if [ -n "$NEW_HW_MODULES" ] && ! grep -q "common-cpu" "$HW_FILE"; then
# This is a basic detection. We overwrite it if it's completely empty or missing common-cpu.
# It's better to let the user know, or auto-apply. We'll auto-apply for a smooth experience.
cat <<EOF > "$HW_FILE.tmp"
{ inputs, ... }:
{
imports = [
$NEW_HW_MODULES
];
}
EOF
if ! cmp -s "$HW_FILE" "$HW_FILE.tmp"; then
mv "$HW_FILE.tmp" "$HW_FILE"
# We notify the user instead of running sys-update silently, as it requires root and time.
notify-send -u normal "Hardware Auto-Detection" "New hardware profile detected. Please run 'sys-update' when ready."
else
rm "$HW_FILE.tmp"
fi
fi
fi

View File

@@ -1,17 +1,27 @@
#!/bin/bash
#!/usr/bin/env bash
# Add the named packages to the system if they're missing. Returns false if it couldn't be done.
PKG_NAME="$1"
if nomarchy-pkg-missing "$@"; then
sudo pacman -S --noconfirm --needed "$@" || exit 1
if [ -z "$PKG_NAME" ]; then
echo "Usage: nomarchy-pkg-add <package-name>"
exit 1
fi
for pkg in "$@"; do
# Secondary check to handle states where pacman doesn't actually register an error
if ! pacman -Q "$pkg" &>/dev/null; then
echo -e "\033[31mError: Package '$pkg' did not install\033[0m" >&2
exit 1
fi
done
STATE_FILE="$HOME/.config/home-manager/user-packages.json"
mkdir -p "$(dirname "$STATE_FILE")"
exit 0
if [ ! -f "$STATE_FILE" ]; then
echo "[]" > "$STATE_FILE"
fi
if jq -e ". | index(\"$PKG_NAME\")" "$STATE_FILE" >/dev/null; then
echo "Package $PKG_NAME is already in your user-packages.json"
exit 0
fi
# Append package to the JSON array
jq ". + [\"$PKG_NAME\"]" "$STATE_FILE" > "${STATE_FILE}.tmp" && mv "${STATE_FILE}.tmp" "$STATE_FILE"
echo "Package $PKG_NAME added declaratively to $STATE_FILE."
echo "Applying changes with env-update..."
env-update

View File

@@ -1,17 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash
# Add the named packages to the system from the AUR if they're missing. Returns false if it couldn't be done.
if nomarchy-pkg-missing "$@"; then
yay -S --noconfirm --needed "$@" || exit 1
fi
for pkg in "$@"; do
# Secondary check to handle states where pacman doesn't actually register an error
if ! pacman -Q "$pkg" &>/dev/null; then
echo -e "\033[31mError: Package '$pkg' did not install\033[0m" >&2
exit 1
fi
done
exit 0
echo "AUR is an Arch Linux concept and is not supported on NixOS."
echo "Please use 'nomarchy-pkg-add' to install packages from nixpkgs."
exit 1

View File

@@ -1,28 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash
# Show a fuzzy-finder TUI for picking new AUR packages to install.
fzf_args=(
--multi
--preview 'yay -Siia {1}'
--preview-label='alt-p: toggle description, alt-b/B: toggle PKGBUILD, alt-j/k: scroll, tab: multi-select'
--preview-label-pos='bottom'
--preview-window 'down:65%:wrap'
--bind 'alt-p:toggle-preview'
--bind 'alt-d:preview-half-page-down,alt-u:preview-half-page-up'
--bind 'alt-k:preview-up,alt-j:preview-down'
--bind 'alt-b:change-preview:yay -Gpa {1} | tail -n +5'
--bind 'alt-B:change-preview:yay -Siia {1}'
--color 'pointer:green,marker:green'
)
pkg_names=$(yay -Slqa | fzf "${fzf_args[@]}")
if [[ -n $pkg_names ]]; then
# Add aur/ prefix to each package name and convert to space-separated for yay
source nomarchy-sudo-keepalive
echo "$pkg_names" | sed 's/^/aur\//' | tr '\n' ' ' | xargs yay -S --noconfirm
sudo updatedb
nomarchy-show-done
fi
echo "AUR is an Arch Linux concept and is not supported on NixOS."
echo "Please use 'nomarchy-pkg-add' to install packages from nixpkgs."
exit 1

View File

@@ -1,11 +1,15 @@
#!/bin/bash
#!/usr/bin/env bash
# Returns true if any of the named packages are missing from the system (or false if they're all there).
PKG_NAME="$1"
for pkg in "$@"; do
if ! pacman -Q "$pkg" &>/dev/null; then
if [ -z "$PKG_NAME" ]; then
echo "Usage: nomarchy-pkg-missing <package-name>"
exit 1
fi
nomarchy-pkg-present "$PKG_NAME"
if [ $? -eq 0 ]; then
exit 1
else
exit 0
fi
done
exit 1
fi

View File

@@ -1,9 +1,20 @@
#!/bin/bash
#!/usr/bin/env bash
# Returns true if all of the named packages are installed on the system (or false if any of them are missing).
PKG_NAME="$1"
for pkg in "$@"; do
pacman -Q "$pkg" &>/dev/null || exit 1
done
if [ -z "$PKG_NAME" ]; then
echo "Usage: nomarchy-pkg-present <package-name>"
exit 1
fi
exit 0
STATE_FILE="$HOME/.config/home-manager/user-packages.json"
if [ ! -f "$STATE_FILE" ]; then
exit 1
fi
if jq -e ". | index(\"$PKG_NAME\")" "$STATE_FILE" >/dev/null; then
exit 0
else
exit 1
fi

View File

@@ -1,23 +1,27 @@
#!/bin/bash
#!/usr/bin/env bash
# Show a fuzzy-finder TUI for picking packages installed on the system to be removed.
PKG_NAME="$1"
fzf_args=(
--multi
--preview 'yay -Qi {1}'
--preview-label='alt-p: toggle description, alt-j/k: scroll, tab: multi-select'
--preview-label-pos='bottom'
--preview-window 'down:65%:wrap'
--bind 'alt-p:toggle-preview'
--bind 'alt-d:preview-half-page-down,alt-u:preview-half-page-up'
--bind 'alt-k:preview-up,alt-j:preview-down'
--color 'pointer:red,marker:red'
)
pkg_names=$(yay -Qqe | fzf "${fzf_args[@]}")
if [[ -n $pkg_names ]]; then
# Convert newline-separated selections to space-separated for yay
echo "$pkg_names" | tr '\n' ' ' | xargs sudo pacman -Rns --noconfirm
nomarchy-show-done
if [ -z "$PKG_NAME" ]; then
echo "Usage: nomarchy-pkg-remove <package-name>"
exit 1
fi
STATE_FILE="$HOME/.config/home-manager/user-packages.json"
if [ ! -f "$STATE_FILE" ]; then
echo "No packages managed by nomarchy-pkg yet."
exit 0
fi
if ! jq -e ". | index(\"$PKG_NAME\")" "$STATE_FILE" >/dev/null; then
echo "Package $PKG_NAME is not in your user-packages.json"
exit 0
fi
# Remove package from the JSON array
jq ". - [\"$PKG_NAME\"]" "$STATE_FILE" > "${STATE_FILE}.tmp" && mv "${STATE_FILE}.tmp" "$STATE_FILE"
echo "Package $PKG_NAME removed declaratively from $STATE_FILE."
echo "Applying changes with env-update..."
env-update

View File

@@ -1,127 +1,46 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
# Configure FIDO2 support declaratively for Nomarchy NixOS.
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
print_success() {
echo -e "${GREEN}$1${NC}"
}
print_error() {
echo -e "${RED}$1${NC}"
}
print_info() {
echo -e "${YELLOW}$1${NC}"
}
check_fido2_hardware() {
tokens=$(fido2-token -L 2>/dev/null)
if [[ -z $tokens ]]; then
print_error "\nNo FIDO2 device detected. Please plug it in (you may need to unlock it as well)."
return 1
fi
return 0
}
setup_pam_config() {
# Configure sudo
if ! grep -q pam_u2f.so /etc/pam.d/sudo; then
print_info "Configuring sudo for FIDO2 authentication..."
sudo sed -i '1i auth sufficient pam_u2f.so cue authfile=/etc/fido2/fido2' /etc/pam.d/sudo
fi
# Configure polkit
if [[ -f /etc/pam.d/polkit-1 ]] && ! grep -q 'pam_u2f.so' /etc/pam.d/polkit-1; then
print_info "Configuring polkit for FIDO2 authentication..."
sudo sed -i '1i auth sufficient pam_u2f.so cue authfile=/etc/fido2/fido2' /etc/pam.d/polkit-1
elif [[ ! -f /etc/pam.d/polkit-1 ]]; then
print_info "Creating polkit configuration with FIDO2 authentication..."
sudo tee /etc/pam.d/polkit-1 >/dev/null <<'EOF'
auth sufficient pam_u2f.so cue authfile=/etc/fido2/fido2
auth required pam_unix.so
account required pam_unix.so
password required pam_unix.so
session required pam_unix.so
EOF
fi
}
remove_pam_config() {
# Remove from sudo
if grep -q pam_u2f.so /etc/pam.d/sudo; then
print_info "Removing FIDO2 authentication from sudo..."
sudo sed -i '/pam_u2f\.so/d' /etc/pam.d/sudo
fi
# Remove from polkit
if [[ -f /etc/pam.d/polkit-1 ]] && grep -Fq 'pam_u2f.so' /etc/pam.d/polkit-1; then
print_info "Removing FIDO2 authentication from polkit..."
sudo sed -i '/pam_u2f\.so/d' /etc/pam.d/polkit-1
fi
}
FEATURE_FILE="/etc/nixos/nomarchy-features/fido2.nix"
if [[ "--remove" == $1 ]]; then
print_success "Removing FIDO2 device from authentication.\n"
# Remove PAM configuration
remove_pam_config
# Remove FIDO2 configuration
if [[ -d /etc/fido2 ]]; then
print_info "Removing FIDO2 configuration..."
sudo rm -rf /etc/fido2
fi
# Uninstall packages
print_info "Removing FIDO2 packages..."
sudo pacman -Rns --noconfirm libfido2 pam-u2f
print_success "FIDO2 authentication has been completely removed."
else
print_success "Setting up FIDO2 device for authentication.\n"
# Install required packages
print_info "Installing required packages..."
nomarchy-pkg-add libfido2 pam-u2f
if ! check_fido2_hardware; then
exit 1
fi
# Create the pamu2fcfg file
if [[ ! -f /etc/fido2/fido2 ]]; then
sudo mkdir -p /etc/fido2
print_success "\nLet's setup your device by confirming on the device now."
print_info "Touch your FIDO2 key when it lights up...\n"
if pamu2fcfg >/tmp/fido2; then
sudo mv /tmp/fido2 /etc/fido2/fido2
print_success "FIDO2 device registered successfully!"
if [ -f "$FEATURE_FILE" ]; then
sudo rm "$FEATURE_FILE"
echo "Removed $FEATURE_FILE."
echo "IMPORTANT: Remove './nomarchy-features/fido2.nix' from your imports and run 'sys-update'."
else
print_error "\nFIDO2 registration failed. Please try again."
exit 1
echo "FIDO2 support not found."
fi
else
print_info "FIDO2 device already registered."
fi
# Configure PAM
setup_pam_config
# Test with sudo
print_info "\nTesting FIDO2 authentication with sudo..."
print_info "Touch your FIDO2 key when prompted.\n"
if sudo echo "FIDO2 authentication test successful"; then
print_success "\nPerfect! FIDO2 authentication is now configured."
print_info "You can use your FIDO2 key for sudo and polkit authentication."
else
print_error "\nVerification failed. You may want to check your configuration."
fi
exit 0
fi
if [ -f "$FEATURE_FILE" ]; then
echo "FIDO2 support is already configured in $FEATURE_FILE"
else
sudo mkdir -p "/etc/nixos/nomarchy-features"
cat <<EOF | sudo tee "$FEATURE_FILE" > /dev/null
{ config, pkgs, ... }:
{
security.pam.u2f = {
enable = true;
control = "sufficient";
cue = true;
# authFile = "/etc/fido2/fido2"; # Default is ~/.config/Yubico/u2f_keys
};
}
EOF
echo "Created $FEATURE_FILE."
echo "IMPORTANT: To finish enabling FIDO2 support, add './nomarchy-features/fido2.nix' to your imports list in /etc/nixos/system.nix or /etc/nixos/flake.nix,"
echo "then run 'sys-update'."
fi
# Enrollment is still an imperative action
if command -v pamu2fcfg &> /dev/null; then
echo "Let's register your FIDO2 key now."
mkdir -p ~/.config/Yubico
pamu2fcfg > ~/.config/Yubico/u2f_keys
echo "FIDO2 key registered."
else
echo "pamu2fcfg not found. Please run 'nomarchy-pkg-add pam-u2f' or 'sys-update' if you just enabled it."
fi

View File

@@ -1,134 +1,40 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
# Configure Fingerprint support declaratively for Nomarchy NixOS.
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
print_success() {
echo -e "${GREEN}$1${NC}"
}
print_error() {
echo -e "${RED}$1${NC}"
}
print_info() {
echo -e "${YELLOW}$1${NC}"
}
check_fingerprint_hardware() {
# Get fingerprint devices for the user
devices=$(fprintd-list "$USER" 2>/dev/null)
# Exit if no devices found
if [[ -z $devices ]]; then
print_error "\nNo fingerprint sensor detected."
return 1
fi
return 0
}
setup_pam_config() {
# Configure sudo
if ! grep -q pam_fprintd.so /etc/pam.d/sudo; then
print_info "Configuring sudo for fingerprint authentication..."
sudo sed -i '1i auth sufficient pam_fprintd.so' /etc/pam.d/sudo
fi
# Configure polkit
if [[ -f /etc/pam.d/polkit-1 ]] && ! grep -q 'pam_fprintd.so' /etc/pam.d/polkit-1; then
print_info "Configuring polkit for fingerprint authentication..."
sudo sed -i '1i auth sufficient pam_fprintd.so' /etc/pam.d/polkit-1
elif [[ ! -f /etc/pam.d/polkit-1 ]]; then
print_info "Creating polkit configuration with fingerprint authentication..."
sudo tee /etc/pam.d/polkit-1 >/dev/null <<'EOF'
auth sufficient pam_fprintd.so
auth required pam_unix.so
account required pam_unix.so
password required pam_unix.so
session required pam_unix.so
EOF
fi
}
add_hyprlock_fingerprint_icon() {
print_info "Adding fingerprint icon to hyprlock placeholder text..."
sed -i 's/placeholder_text = .*/placeholder_text = <span> Enter Password 󰈷 <\/span>/' ~/.config/hypr/hyprlock.conf
sed -i 's/fingerprint:enabled = .*/fingerprint:enabled = true/' ~/.config/hypr/hyprlock.conf
}
remove_hyprlock_fingerprint_icon() {
print_info "Removing fingerprint icon from hyprlock placeholder text..."
sed -i 's/placeholder_text = .*/placeholder_text = Enter Password/' ~/.config/hypr/hyprlock.conf
sed -i 's/fingerprint:enabled = .*/fingerprint:enabled = false/' ~/.config/hypr/hyprlock.conf
}
remove_pam_config() {
# Remove from sudo
if grep -q pam_fprintd.so /etc/pam.d/sudo; then
print_info "Removing fingerprint authentication from sudo..."
sudo sed -i '/pam_fprintd\.so/d' /etc/pam.d/sudo
fi
# Remove from polkit
if [[ -f /etc/pam.d/polkit-1 ]] && grep -Fq 'pam_fprintd.so' /etc/pam.d/polkit-1; then
print_info "Removing fingerprint authentication from polkit..."
sudo sed -i '/pam_fprintd\.so/d' /etc/pam.d/polkit-1
fi
}
FEATURE_FILE="/etc/nixos/nomarchy-features/fingerprint.nix"
if [[ "--remove" == $1 ]]; then
print_success "Removing fingerprint scanner from authentication.\n"
# Remove PAM configuration
remove_pam_config
# Remove fingerprint icon from hyprlock placeholder text
remove_hyprlock_fingerprint_icon
# Uninstall packages
print_info "Removing fingerprint packages..."
sudo pacman -Rns --noconfirm fprintd
print_success "Fingerprint authentication has been completely removed."
else
print_success "Setting up fingerprint scanner for authentication.\n"
# Install required packages
print_info "Installing required packages..."
nomarchy-pkg-add fprintd usbutils
if ! check_fingerprint_hardware; then
exit 1
fi
# Configure PAM
setup_pam_config
# Add fingerprint icon to hyprlock placeholder text
add_hyprlock_fingerprint_icon
# Enroll first fingerprint
print_success "\nLet's setup your right index finger as the first fingerprint."
print_info "Keep moving the finger around on sensor until the process completes.\n"
if sudo fprintd-enroll "$USER"; then
print_success "\nFingerprint enrolled successfully!"
# Verify
print_info "\nNow let's verify that it's working correctly.\n"
if fprintd-verify; then
print_success "\nPerfect! Fingerprint authentication is now configured."
print_info "You can use your fingerprint for sudo, polkit, and lock screen (Super + Escape)."
if [ -f "$FEATURE_FILE" ]; then
sudo rm "$FEATURE_FILE"
echo "Removed $FEATURE_FILE."
echo "IMPORTANT: Remove './nomarchy-features/fingerprint.nix' from your imports and run 'sys-update'."
else
print_error "\nVerification failed. You may want to try enrolling again."
echo "Fingerprint support not found."
fi
else
print_error "\nEnrollment failed. Please try again."
exit 1
fi
exit 0
fi
if [ -f "$FEATURE_FILE" ]; then
echo "Fingerprint support is already configured in $FEATURE_FILE"
else
sudo mkdir -p "/etc/nixos/nomarchy-features"
cat <<EOF | sudo tee "$FEATURE_FILE" > /dev/null
{ config, pkgs, ... }:
{
services.fprintd.enable = true;
# NixOS's fprintd module automatically configures PAM for login/sudo if enabled.
}
EOF
echo "Created $FEATURE_FILE."
echo "IMPORTANT: To finish enabling fingerprint support, add './nomarchy-features/fingerprint.nix' to your imports list in /etc/nixos/system.nix or /etc/nixos/flake.nix,"
echo "then run 'sys-update'."
fi
# Enrollment is still an imperative action
if command -v fprintd-enroll &> /dev/null; then
echo "Let's enroll your fingerprint now."
fprintd-enroll "$USER"
else
echo "fprintd-enroll not found. Please run 'sys-update' first if you just enabled it."
fi

View File

@@ -1,50 +1,56 @@
#!/bin/bash
#!/usr/bin/env bash
# Cycles through the background images available
# Cycles through the background images available for the current theme.
# Declarative + Hybrid (instant swww) for Nomarchy NixOS.
THEME_NAME=$(cat "$HOME/.config/nomarchy/current/theme.name" 2>/dev/null)
THEME_BACKGROUNDS_PATH="$HOME/.config/nomarchy/current/theme/backgrounds/"
USER_BACKGROUNDS_PATH="$HOME/.config/nomarchy/backgrounds/$THEME_NAME/"
CURRENT_BACKGROUND_LINK="$HOME/.config/nomarchy/current/background"
STATE_DIR="$HOME/.config/home-manager"
THEME_STATE_FILE="$STATE_DIR/theme-state.nix"
WALLPAPER_STATE_FILE="$STATE_DIR/wallpaper-state.nix"
mapfile -d '' -t BACKGROUNDS < <(find -L "$USER_BACKGROUNDS_PATH" "$THEME_BACKGROUNDS_PATH" -maxdepth 1 -type f -print0 2>/dev/null | sort -z)
THEME_NAME=$(cat "$THEME_STATE_FILE" 2>/dev/null || echo "dracula")
if [ -d "/etc/nixos/nomarchy/themes" ]; then
THEMES_DIR="/etc/nixos/nomarchy/themes"
elif [ -d "/etc/nomarchy/themes" ]; then
THEMES_DIR="/etc/nomarchy/themes"
else
THEMES_DIR="/etc/nixos/themes"
fi
BG_DIR="$THEMES_DIR/$THEME_NAME/backgrounds"
if [ ! -d "$BG_DIR" ]; then
notify-send "No background directory found for theme $THEME_NAME"
exit 1
fi
mapfile -t BACKGROUNDS < <(ls "$BG_DIR" | sort)
TOTAL=${#BACKGROUNDS[@]}
if (( TOTAL == 0 )); then
notify-send "No background was found for theme" -t 2000
pkill -x swaybg
setsid uwsm-app -- swaybg --color '#000000' >/dev/null 2>&1 &
else
# Get current background from symlink
if [[ -L $CURRENT_BACKGROUND_LINK ]]; then
CURRENT_BACKGROUND=$(readlink "$CURRENT_BACKGROUND_LINK")
else
# Default to first background if no symlink exists
CURRENT_BACKGROUND=""
fi
# Find current background index
INDEX=-1
for i in "${!BACKGROUNDS[@]}"; do
if [[ ${BACKGROUNDS[$i]} == $CURRENT_BACKGROUND ]]; then
INDEX=$i
break
fi
done
# Get next background (wrap around)
if (( INDEX == -1 )); then
# Use the first background when no match was found
NEW_BACKGROUND="${BACKGROUNDS[0]}"
else
NEXT_INDEX=$(((INDEX + 1) % TOTAL))
NEW_BACKGROUND="${BACKGROUNDS[$NEXT_INDEX]}"
fi
# Set new background symlink
ln -nsf "$NEW_BACKGROUND" "$CURRENT_BACKGROUND_LINK"
# Relaunch swaybg
pkill -x swaybg
setsid uwsm-app -- swaybg -i "$CURRENT_BACKGROUND_LINK" -m fill >/dev/null 2>&1 &
notify-send "No backgrounds found in $BG_DIR"
exit 1
fi
CURRENT_BG=$(cat "$WALLPAPER_STATE_FILE" 2>/dev/null)
INDEX=-1
for i in "${!BACKGROUNDS[@]}"; do
if [[ "$BG_DIR/${BACKGROUNDS[$i]}" == "$CURRENT_BG" ]]; then
INDEX=$i
break
fi
done
NEXT_INDEX=$(((INDEX + 1) % TOTAL))
NEW_BG="$BG_DIR/${BACKGROUNDS[$NEXT_INDEX]}"
echo "$NEW_BG" > "$WALLPAPER_STATE_FILE"
# Instant feedback via swww
if pgrep -x swww-daemon >/dev/null; then
swww img "$NEW_BG" --transition-type outer --transition-pos 0.85,0.97 --transition-step 90
else
swww init && swww img "$NEW_BG"
fi
echo "Background set to $NEW_BG declaratively."

View File

@@ -1,60 +1,48 @@
#!/bin/bash
#!/usr/bin/env bash
if [[ -z $1 ]]; then
# Set the system theme declaratively.
# Usage: nomarchy-theme-set <theme-name>
THEME_NAME="$1"
if [[ -z $THEME_NAME ]]; then
echo "Usage: nomarchy-theme-set <theme-name>"
exit 1
fi
CURRENT_THEME_PATH="$HOME/.config/nomarchy/current/theme"
NEXT_THEME_PATH="$HOME/.config/nomarchy/current/next-theme"
USER_THEMES_PATH="$HOME/.config/nomarchy/themes"
OMARCHY_THEMES_PATH="$OMARCHY_PATH/themes"
STATE_DIR="$HOME/.config/home-manager"
THEME_STATE_FILE="$STATE_DIR/theme-state.nix"
WALLPAPER_STATE_FILE="$STATE_DIR/wallpaper-state.nix"
THEME_NAME=$(echo "$1" | sed -E 's/<[^>]+>//g' | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
if [[ ! -d $OMARCHY_THEMES_PATH/$THEME_NAME ]] && [[ ! -d $USER_THEMES_PATH/$THEME_NAME ]]; then
echo "Theme '$THEME_NAME' does not exist"
exit 1
# Logic for finding themes
if [ -d "/etc/nixos/nomarchy/themes" ]; then
THEMES_DIR="/etc/nixos/nomarchy/themes"
elif [ -d "/etc/nomarchy/themes" ]; then
THEMES_DIR="/etc/nomarchy/themes"
else
THEMES_DIR="/etc/nixos/themes"
fi
# Setup clean next theme directory (for atomic theme config swapping)
rm -rf "$NEXT_THEME_PATH"
mkdir -p "$NEXT_THEME_PATH"
mkdir -p "$STATE_DIR"
# Copy official theme first, then overlay user customizations on top
cp -r "$OMARCHY_THEMES_PATH/$THEME_NAME/"* "$NEXT_THEME_PATH/" 2>/dev/null
cp -r "$USER_THEMES_PATH/$THEME_NAME/"* "$NEXT_THEME_PATH/" 2>/dev/null
# Generate dynamic configs
nomarchy-theme-set-templates
# Swap next theme in as current
rm -rf "$CURRENT_THEME_PATH"
mv "$NEXT_THEME_PATH" "$CURRENT_THEME_PATH"
# Store theme name for reference
echo "$THEME_NAME" >"$HOME/.config/nomarchy/current/theme.name"
# Change background with theme
nomarchy-theme-bg-next
# Restart components to apply new theme
if pgrep -x waybar >/dev/null; then
nomarchy-restart-waybar
if [ ! -d "$THEMES_DIR/$THEME_NAME" ] && ! [[ "$THEME_NAME" == "dracula" || "$THEME_NAME" == "nord" ]]; then
echo "Theme '$THEME_NAME' not found in $THEMES_DIR"
# Check if it exists in the palettes file
# (Assuming nomarchy-palettes.nix is imported in Nix)
fi
nomarchy-restart-swayosd
nomarchy-restart-terminal
nomarchy-restart-hyprctl
nomarchy-restart-btop
nomarchy-restart-opencode
nomarchy-restart-mako
# Change app-specific themes
nomarchy-theme-set-gnome
nomarchy-theme-set-browser
nomarchy-theme-set-vscode
nomarchy-theme-set-obsidian
nomarchy-theme-set-keyboard
echo "$THEME_NAME" > "$THEME_STATE_FILE"
# Try to find a background for this theme
BG_DIR="$THEMES_DIR/$THEME_NAME/backgrounds"
if [ -d "$BG_DIR" ]; then
BG=$(ls "$BG_DIR" | head -n 1)
if [ -n "$BG" ]; then
echo "$BG_DIR/$BG" > "$WALLPAPER_STATE_FILE"
fi
fi
echo "Theme set to $THEME_NAME. Applying changes with env-update..."
env-update
# Call hook on theme set
nomarchy-hook theme-set "$THEME_NAME"

View File

@@ -1,65 +1,44 @@
#!/bin/bash
#!/usr/bin/env bash
# Toggle dedicated vs integrated GPU mode via supergfxd (for hybrid gpu laptops, like Asus G14).
# Requires reboot to take effect.
# Declarative enablement + Runtime mode switching for Nomarchy NixOS.
# Ensure supergfxctl has been installed
if nomarchy-cmd-missing supergfxctl; then
nomarchy-pkg-add supergfxctl
FEATURE_FILE="/etc/nixos/nomarchy-features/supergfxd.nix"
# Create config before starting service to prevent hang on first boot
sudo tee /etc/supergfxd.conf >/dev/null <<'CONF'
if ! command -v supergfxctl &> /dev/null; then
sudo mkdir -p "/etc/nixos/nomarchy-features"
cat <<EOF | sudo tee "$FEATURE_FILE" > /dev/null
{ config, pkgs, ... }:
{
"mode": "Hybrid",
"vfio_enable": true,
"vfio_save": false,
"always_reboot": false,
"no_logind": false,
"logout_timeout_s": 180,
"hotplug_type": "None"
services.supergfxd.enable = true;
}
CONF
sudo systemctl enable --now supergfxd
EOF
echo "Created $FEATURE_FILE to enable supergfxd."
echo "IMPORTANT: To finish enabling hybrid GPU support, add './nomarchy-features/supergfxd.nix' to your imports list in /etc/nixos/system.nix or /etc/nixos/flake.nix,"
echo "then run 'sys-update'."
exit 0
fi
gpu_mode=$(supergfxctl -g)
echo "Current GPU mode: $gpu_mode"
case "$gpu_mode" in
"Integrated")
if gum confirm "Enable dedicated GPU and reboot?"; then
# Switch to hybrid mode
sudo sed -i "s/\"mode\": \".*\"/\"mode\": \"Hybrid\"/" /etc/supergfxd.conf
# Let hybrid mode be the default after system sleep
sudo rm -rf /usr/lib/systemd/system-sleep/force-igpu
# Remove the startup delay override (not needed for Hybrid mode)
sudo rm -rf /etc/systemd/system/supergfxd.service.d/delay-start.conf
if gum confirm "Switch to Hybrid mode (enables dGPU) and reboot?"; then
supergfxctl -m Hybrid
echo "Switching to Hybrid mode..."
nomarchy-system-reboot
fi
;;
"Hybrid")
if gum confirm "Use only integrated GPU and reboot?"; then
# Switch to integrated mode and ensure vfio is enabled (needed for sleep/wake trick)
sudo sed -i "s/\"mode\": \".*\"/\"mode\": \"Integrated\"/" /etc/supergfxd.conf
sudo sed -i 's/"vfio_enable": false/"vfio_enable": true/' /etc/supergfxd.conf
# Force igpu mode after system sleep (or dgpu could get activated)
sudo mkdir -p /usr/lib/systemd/system-sleep
sudo cp -p $OMARCHY_PATH/default/systemd/system-sleep/force-igpu /usr/lib/systemd/system-sleep/
# Delay supergfxd startup to avoid race condition with display manager
# that can cause system freeze when booting in Integrated mode
sudo mkdir -p /etc/systemd/system/supergfxd.service.d
sudo cp -p $OMARCHY_PATH/default/systemd/system/supergfxd.service.d/delay-start.conf /etc/systemd/system/supergfxd.service.d/
if gum confirm "Switch to Integrated mode (disables dGPU) and reboot?"; then
supergfxctl -m Integrated
echo "Switching to Integrated mode..."
nomarchy-system-reboot
fi
;;
*)
echo "Hybrid GPU not found or in unknown mode."
echo "Hybrid GPU in unknown mode: $gpu_mode. Try 'supergfxctl -m Hybrid' manually."
exit 1
;;
esac

View File

@@ -1,11 +1,28 @@
#!/bin/bash
#!/usr/bin/env bash
if pgrep -x hypridle >/dev/null; then
pkill -x hypridle
notify-send -u low "󱫖 Stop locking computer when idle"
else
uwsm-app -- hypridle >/dev/null 2>&1 &
notify-send -u low "󱫖 Now locking computer when idle"
# Toggles the idle daemon (hypridle) between enabled and disabled.
# Declarative + Hybrid (instant IPC/kill) for Nomarchy NixOS.
STATE_FILE="$HOME/.config/home-manager/idle-state.json"
mkdir -p "$(dirname "$STATE_FILE")"
if [ ! -f "$STATE_FILE" ]; then
echo '{"enabled": true}' > "$STATE_FILE"
fi
pkill -RTMIN+9 waybar
enabled=$(jq -r '.enabled' "$STATE_FILE")
if [[ $enabled == "true" ]]; then
NEW_ENABLED="false"
pkill -x hypridle
notify-send -u low "󱫖 Stop locking computer when idle"
else
NEW_ENABLED="true"
setsid hypridle >/dev/null 2>&1 &
notify-send -u low "󱫖 Now locking computer when idle"
fi
echo "{\"enabled\": $NEW_ENABLED}" > "$STATE_FILE"
echo "Idle daemon set to $NEW_ENABLED declaratively."
pkill -RTMIN+9 waybar # Signal waybar if needed

View File

@@ -1,30 +1,36 @@
#!/bin/bash
#!/usr/bin/env bash
# Default temperature values
ON_TEMP=4000
OFF_TEMP=6000
# Toggles the nightlight (hyprsunset) between enabled (4000) and disabled (6500)
# Declarative + Hybrid (instant IPC) for Nomarchy NixOS.
# Ensure hyprsunset is running
if ! pgrep -x hyprsunset; then
setsid uwsm-app -- hyprsunset &
sleep 1 # Give it time to register
STATE_FILE="$HOME/.config/home-manager/hyprsunset-state.json"
mkdir -p "$(dirname "$STATE_FILE")"
if [ ! -f "$STATE_FILE" ]; then
echo '{"enabled": false, "temperature": 4000}' > "$STATE_FILE"
fi
# Query the current temperature
CURRENT_TEMP=$(hyprctl hyprsunset temperature 2>/dev/null | grep -oE '[0-9]+')
enabled=$(jq -r '.enabled' "$STATE_FILE")
restart_nightlighted_waybar() {
if grep -q "custom/nightlight" ~/.config/waybar/config.jsonc; then
nomarchy-restart-waybar # restart waybar in case user has waybar module for hyprsunset
fi
}
if [[ $CURRENT_TEMP == $OFF_TEMP ]]; then
hyprctl hyprsunset temperature $ON_TEMP
notify-send -u low " Nightlight screen temperature"
restart_nightlighted_waybar
if [[ $enabled == "true" ]]; then
NEW_ENABLED="false"
TEMP=6500
notify-send -u low " Nightlight DISABLED"
else
hyprctl hyprsunset temperature $OFF_TEMP
notify-send -u low " Daylight screen temperature"
restart_nightlighted_waybar
NEW_ENABLED="true"
TEMP=4000
notify-send -u low " Nightlight ENABLED"
fi
# Instant feedback via IPC
if pgrep -x hyprsunset >/dev/null; then
hyprctl hyprsunset temperature $TEMP
else
# Should be started by systemd, but just in case
setsid hyprsunset -t $TEMP &
fi
echo "{\"enabled\": $NEW_ENABLED, \"temperature\": 4000}" > "$STATE_FILE"
echo "Nightlight set to $NEW_ENABLED ($TEMP) declaratively."
# No need to run env-update if we don't want the delay,
# as next HM switch will pick it up and apply it.

View File

@@ -1,13 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash
# Update AUR packages if any are installed
if pacman -Qem >/dev/null; then
if nomarchy-pkg-aur-accessible; then
echo -e "\e[32m\nUpdate AUR packages\e[0m"
yay -Sua --noconfirm --cleanafter --ignore gcc14,gcc14-libs
echo
else
echo -e "\e[31m\nAUR is unavailable (so skipping updates)\e[0m"
echo
fi
fi
echo "AUR is an Arch Linux concept and is not supported on NixOS."
echo "Please use 'nomarchy-pkg-add' to install packages from nixpkgs."
exit 1

View File

@@ -1,18 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Ensure we have the nomarchy-keyring and it's populated
if nomarchy-pkg-missing nomarchy-keyring || ! sudo pacman-key --list-keys 40DFB630FF42BCFFB047046CF0134EE680CAC571 &>/dev/null; then
sudo pacman-key --recv-keys 40DFB630FF42BCFFB047046CF0134EE680CAC571 --keyserver keys.openpgp.org
sudo pacman-key --lsign-key 40DFB630FF42BCFFB047046CF0134EE680CAC571
# This is generally not a good idea, but this is a special case because we're going to be updating
# the full set of packages in nomarchy-update-system-pkgs right after this (and it needs latest keyring)!
sudo pacman -Sy
nomarchy-pkg-add nomarchy-keyring
sudo pacman-key --list-keys 40DFB630FF42BCFFB047046CF0134EE680CAC571
fi
# Ensure we have the latest archlinux-keyring, maintainer keys might have changed
echo -e "\e[32m\nUpdate Arch signing keys\e[0m"
sudo pacman -Sy --noconfirm archlinux-keyring >/dev/null
echo "Pacman keyring is an Arch Linux concept and is not supported on NixOS."
exit 1