Files
Nomarchy/features/scripts/default.nix
Bernardo Magri bbdf34ced8 refactor: implement component-based architecture for enhanced maintainability
- Reorganize directory structure into core/, features/, and themes/
- Colocate application Nix logic, configs, scripts, and theme overrides
- Implement 'Inversion of Control' for theming: apps now pull theme-specific layouts
- Update flake.nix and shared library paths to match the new structure
- Document the new Feature-Centric architecture in README.md
2026-04-12 14:51:15 +01:00

157 lines
3.9 KiB
Nix

{ config, pkgs, lib, ... }:
let
# Core dependencies needed by most scripts (minimal set)
coreDeps = with pkgs; [
coreutils
gnused
gnugrep
findutils
gawk
jq
];
# Category-specific dependencies
categoryDeps = with pkgs; {
appearance = [
swww
libnotify
];
apps = [
hyprland
libnotify
];
hardware = [
brightnessctl
playerctl
pamixer
pciutils
libnotify
];
system = [
gum
libnotify
curl
wget
];
utils = [
gum
hyprland
libnotify
wl-clipboard
grim
slurp
xmlstarlet
curl
wget
];
wm = [
hyprland
swayosd
libnotify
procps
];
};
# All dependencies combined (for scripts that might call others)
allDeps = coreDeps ++ (lib.unique (lib.flatten (builtins.attrValues categoryDeps)));
# Environment variables to inject
envVars = {
NOMARCHY_TOGGLE_SUSPEND = if config.nomarchy.toggles.suspend then "true" else "false";
NOMARCHY_TOGGLE_SCREENSAVER = if config.nomarchy.toggles.screensaver then "true" else "false";
NOMARCHY_TOGGLE_IDLE = if config.nomarchy.toggles.idle then "true" else "false";
NOMARCHY_TOGGLE_NIGHTLIGHT = if config.nomarchy.toggles.nightlight then "true" else "false";
NOMARCHY_TOGGLE_WAYBAR = if config.nomarchy.toggles.waybar then "true" else "false";
NOMARCHY_TOGGLE_SKIP_VSCODE_THEME = if config.nomarchy.toggles.skipVsCodeTheme then "true" else "false";
NOMARCHY_MONOSPACE_FONT = config.nomarchy.fonts.monospace;
};
# Build wrapper arguments for environment variables
envWrapperArgs = lib.concatStringsSep " " (
lib.mapAttrsToList (name: value: "--set ${name} \"${value}\"") envVars
);
nomarchy-scripts = pkgs.stdenv.mkDerivation {
pname = "nomarchy-scripts";
version = "1.0.0";
src = ../../bin;
nativeBuildInputs = [ pkgs.makeWrapper ];
installPhase = ''
mkdir -p $out/bin
# Copy scripts preserving directory structure for category detection
for category in appearance apps hardware system utils wm; do
if [ -d "$category" ]; then
for script in "$category"/*; do
if [ -f "$script" ]; then
cp "$script" "$out/bin/"
fi
done
fi
done
chmod +x $out/bin/*
patchShebangs $out/bin
'';
postFixup = ''
# Wrap scripts with category-specific dependencies
for file in $out/bin/*; do
if [ -f "$file" ]; then
scriptName=$(basename "$file")
# Determine category from original source location
category=""
for cat in appearance apps hardware system utils wm; do
if [ -f "$src/$cat/$scriptName" ]; then
category="$cat"
break
fi
done
# Select dependencies based on category
case "$category" in
appearance)
deps="${lib.makeBinPath (coreDeps ++ categoryDeps.appearance)}"
;;
apps)
deps="${lib.makeBinPath (coreDeps ++ categoryDeps.apps)}"
;;
hardware)
deps="${lib.makeBinPath (coreDeps ++ categoryDeps.hardware)}"
;;
system)
deps="${lib.makeBinPath (coreDeps ++ categoryDeps.system)}"
;;
utils)
deps="${lib.makeBinPath (coreDeps ++ categoryDeps.utils)}"
;;
wm)
deps="${lib.makeBinPath (coreDeps ++ categoryDeps.wm)}"
;;
*)
# Fallback to all deps for unknown categories
deps="${lib.makeBinPath allDeps}"
;;
esac
wrapProgram "$file" \
--prefix PATH : "$deps" \
${envWrapperArgs}
fi
done
'';
};
in
{
home.packages = [ nomarchy-scripts ];
}