diff --git a/gen-regist.sh b/gen-regist.sh new file mode 100644 index 0000000..9254e87 --- /dev/null +++ b/gen-regist.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +set -euo pipefail + +REGISTRY="modules/default.nix" + +echo "Generating $REGISTRY …" + +{ + echo "{" + + echo " common = {" + find modules/common -name "*.nix" -maxdepth 1 | sort | while read -r f; do + name=$(basename "$f" .nix) + echo " $name = ./${f#modules/};" + done + echo " };" + + echo "" + echo " hm = {" + find modules/home-manager -name "*.nix" | sort | while read -r f; do + name=$(basename "$f" .nix) + echo " $name = ./${f#modules/};" + done + echo " };" + + echo "" + echo " nixos = {" + find modules/nixos -name "*.nix" | sort | while read -r f; do + name=$(basename "$f" .nix) + echo " $name = ./${f#modules/};" + done + echo " };" + + echo "" + echo " macos = {" + find modules/macos -name "*.nix" | sort | while read -r f; do + name=$(basename "$f" .nix) + echo " $name = ./${f#modules/};" + done + echo " };" + + echo "}" +} > "$REGISTRY" + +echo "✓ Registry generated at $REGISTRY" diff --git a/hosts/framework/home.nix b/hosts/framework/home.nix index 46797f5..c264386 100644 --- a/hosts/framework/home.nix +++ b/hosts/framework/home.nix @@ -1,9 +1,12 @@ {config, pkgs, inputs, ...}: +let + modules = import ../../modules; +in { imports = [ ../common/home.nix - ../../modules/home-manager/hyprland.nix + modules.hm.hyprland.nix ]; home = { diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix index 665c9f0..c2eeff4 100644 --- a/hosts/laptop/home.nix +++ b/hosts/laptop/home.nix @@ -1,5 +1,8 @@ { config, pkgs, inputs, ... }: +let + modules = import ../../modules; +in { # Home Manager needs a bit of information about you and the paths it should # manage. diff --git a/hosts/nixos/home.nix b/hosts/nixos/home.nix index 6f35272..ba8ea3e 100644 --- a/hosts/nixos/home.nix +++ b/hosts/nixos/home.nix @@ -1,11 +1,14 @@ { config, pkgs, inputs, ... }: +let + modules = import ../../modules; +in { # Home Manager needs a bit of information about you and the paths it should # manage. imports = [ ../common/home.nix - ../../modules/home-manager/hyprland.nix + modules.hm.hyprland.nix ]; # This value determines the Home Manager release that your configuration is # compatible with. This helps avoid breakage when a new Home Manager release diff --git a/migrate-regist.sh b/migrate-regist.sh new file mode 100644 index 0000000..2cddef3 --- /dev/null +++ b/migrate-regist.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +set -euo pipefail + +FILES=$(rg "modules/.+\.nix" -l hosts) + +for file in $FILES; do + echo "Migrating $file" + + # Skip files that already import registry + if rg "import .*modules" "$file" >/dev/null; then + continue + fi + + # Insert let modules = import … + sed -i '' ' +1s|^|let\n modules = import ../../modules;\nin\n| +' "$file" + + # Replace common patterns + sed -i '' \ + -e 's|../../modules/common/\([^/]*\)\.nix|modules.common.\1|g' \ + -e 's|../../modules/home-manager/Hyprland/\([^/]*\)\.nix|modules.hm.\1|g' \ + -e 's|../../modules/home-manager/\([^/]*\)\.nix|modules.hm.\1|g' \ + -e 's|../../modules/nixos/\([^/]*\)\.nix|modules.nixos.\1|g' \ + "$file" + +done + +echo "✓ Migration pass complete" +echo "⚠️ Please review files manually and fix edge cases." diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 0000000..3f96b94 --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,39 @@ +{ + common = { + home = ../hosts/common/home.nix; + module = ../../hosts/common/modules.nix; + ai = ./common/ai.nix; + direnv = ./common/direnv.nix; + environment = ./common/environment.nix; + nix = ./common/nix.nix; + spotify = ./common/spotify.nix; + ssh = ./common/ssh.nix; + zed2 = ./common/zed2.nix; + zed = ./common/zed.nix; + }; + + hm = { + hyprland = ./home-manager/Hyprland/hyprland.nix; + scripts = ./home-manager/Hyprland/scripts.nix; + shell = ./home-manager/shell.nix; + spicetify = ./home-manager/spicetify.nix; + zed = ./home-manager/zed.nix; + }; + + nixos = { + bootloader = ./nixos/bootloader.nix; + nvidia = ./nixos/gaming/nvidia.nix; + starCitizen = ./nixos/gaming/starCitizen.nix; + steam = ./nixos/gaming/steam.nix; + locale = ./nixos/locale.nix; + secrets = ./nixos/secrets.nix; + swap = ./nixos/swap.nix; + wireless = ./nixos/wireless.nix; + xfce = ./nixos/xfce.nix; + }; + + macos = { + ollama = ./macos/ollama.nix; + vesktop = ./macos/vesktop.nix; + }; +}