diff --git a/hosts/eirene/base/card.sh b/hosts/eirene/base/card.sh new file mode 100644 index 0000000..c10367c --- /dev/null +++ b/hosts/eirene/base/card.sh @@ -0,0 +1,10 @@ +AMD=/dev/dri/by-path/pci-0000:06:00.0-card +NVIDIA=/dev/dri/by-path/pci-0000:01:00.0-card + +if [ -e $AMD ]; then + CARD=$AMD +else + CARD=$NVIDIA +fi + +ln -sf $CARD $HOME/.config/hypr/card diff --git a/hosts/eirene/base/default.nix b/hosts/eirene/base/default.nix index a75e207..2b28a20 100644 --- a/hosts/eirene/base/default.nix +++ b/hosts/eirene/base/default.nix @@ -58,18 +58,7 @@ }]; }; - programs.zsh.loginExtra = lib.mkBefore '' - AMD=/dev/dri/by-path/pci-0000:06:00.0-card - NVIDIA=/dev/dri/by-path/pci-0000:01:00.0-card - - if [ -e $AMD ]; then - CARD=$AMD - else - CARD=$NVIDIA - fi - - ln -sf $CARD $HOME/.config/hypr/card - ''; + programs.zsh.loginExtra = lib.mkBefore (builtins.readFile ./card.sh); theme = { cursor.size = 24; diff --git a/users/common/options/home-manager/hyprland/default.nix b/users/common/options/home-manager/hyprland/default.nix index 71e6170..3cfce48 100644 --- a/users/common/options/home-manager/hyprland/default.nix +++ b/users/common/options/home-manager/hyprland/default.nix @@ -21,16 +21,12 @@ in config = { wayland.windowManager.hyprland.settings.exec-once = lib.meta.getExe (pkgs.writeShellApplication { name = "init-hyprland"; - text = '' - ${cfg.initExtraConfig} - ''; + text = cfg.initExtraConfig; }); wayland.windowManager.hyprland.settings.exec = lib.meta.getExe (pkgs.writeShellApplication { name = "reload-hyprland"; - text = '' - ${cfg.reloadExtraConfig} - ''; + text = cfg.reloadExtraConfig; }); }; } diff --git a/users/common/options/home-manager/theme/default.nix b/users/common/options/home-manager/theme/default.nix index dcef887..1cb1729 100644 --- a/users/common/options/home-manager/theme/default.nix +++ b/users/common/options/home-manager/theme/default.nix @@ -6,106 +6,13 @@ let name = "theme"; runtimeInputs = with pkgs; [ coreutils-full ]; bashOptions = [ "nounset" "pipefail" ]; - text = '' - [ ! -L "${cfg.configDir}/wallpaper" ] && ln -sf "${cfg.wallpaper}" "${cfg.configDir}/wallpaper" - [ ! -f "${cfg.configDir}/mode" ] && echo "${cfg.mode}" > "${cfg.configDir}/mode" - - set_wallpaper() { - if [ -f "$1" ]; then - WALLPAPER="$1" - else - echo "Invalid wallpaper path: $1" - exit 1 - fi - } - - set_mode() { - if [ "$1" = "light" ] || [ "$1" = "dark" ]; then - MODE="$1" - else - echo "Invalid mode: $1. Use 'light' or 'dark'." - exit 1 - fi - } - - toggle_mode() { - if [ "$(cat "${cfg.configDir}/mode")" = "light" ]; then - MODE="dark" - else - MODE="light" - fi - } - - show_usage() { - echo "Usage: theme {toggle|light|dark|mode |wallpaper [mode]}" - } - - finish() { - [ -n "$WALLPAPER" ] && ln -sf "$WALLPAPER" "${cfg.configDir}/wallpaper" - [ -n "$MODE" ] && echo "$MODE" > "${cfg.configDir}/mode" - - { - ${cfg.extraConfig} - } > /dev/null - } - - WALLPAPER="" - MODE="" - - if [ $# -eq 0 ]; then - finish - else - case "$1" in - toggle) - if [ $# -eq 1 ]; then - toggle_mode - else - show_usage - exit 1 - fi - ;; - light) - if [ $# -eq 1 ]; then - set_mode "light" - else - show_usage - exit 1 - fi - ;; - dark) - if [ $# -eq 1 ]; then - set_mode "dark" - else - show_usage - exit 1 - fi - ;; - mode) - if [ $# -eq 2 ]; then - set_mode "$2" - else - show_usage - exit 1 - fi - ;; - wallpaper) - if [ $# -ge 2 ] && [ $# -le 3 ]; then - set_wallpaper "$2" - [ $# -eq 3 ] && set_mode "$3" - else - show_usage - exit 1 - fi - ;; - *) - show_usage - exit 1 - ;; - esac - - finish - fi - ''; + runtimeEnv = { + CONFIG = cfg.configDir; + DEFAULT_WALLPAPER = cfg.wallpaper; + DEFAULT_MODE = cfg.mode; + SWITCH = lib.meta.getExe (pkgs.writeShellScriptBin "themeExtraConfig" cfg.extraConfig); + }; + text = builtins.readFile ./theme.sh; }; in { diff --git a/users/common/options/home-manager/theme/theme.sh b/users/common/options/home-manager/theme/theme.sh new file mode 100644 index 0000000..81ecd3c --- /dev/null +++ b/users/common/options/home-manager/theme/theme.sh @@ -0,0 +1,98 @@ +[ ! -L "$CONFIG"/wallpaper ] && ln -sf "$DEFAULT_WALLPAPER" "$CONFIG"/wallpaper +[ ! -f "$CONFIG"/mode ] && echo "$DEFAULT_MODE" > "$CONFIG"/mode + +set_wallpaper() { + if [ -f "$1" ]; then + WALLPAPER="$1" + else + echo "Invalid wallpaper path: $1" + exit 1 + fi +} + +set_mode() { + if [ "$1" = "light" ] || [ "$1" = "dark" ]; then + MODE="$1" + else + echo "Invalid mode: $1. Use 'light' or 'dark'." + exit 1 + fi +} + +toggle_mode() { + if [ "$(cat "$CONFIG"/mode)" = "light" ]; then + MODE="dark" + else + MODE="light" + fi +} + +show_usage() { + echo "Usage: theme {toggle|light|dark|mode |wallpaper [mode]}" +} + +finish() { + [ -n "$WALLPAPER" ] && ln -sf "$WALLPAPER" "$CONFIG"/wallpaper + [ -n "$MODE" ] && echo "$MODE" > "$CONFIG"/mode + + { + "$SWITCH" + } > /dev/null +} + +WALLPAPER="" +MODE="" + +if [ $# -eq 0 ]; then + finish +else + case "$1" in + toggle) + if [ $# -eq 1 ]; then + toggle_mode + else + show_usage + exit 1 + fi + ;; + light) + if [ $# -eq 1 ]; then + set_mode "light" + else + show_usage + exit 1 + fi + ;; + dark) + if [ $# -eq 1 ]; then + set_mode "dark" + else + show_usage + exit 1 + fi + ;; + mode) + if [ $# -eq 2 ]; then + set_mode "$2" + else + show_usage + exit 1 + fi + ;; + wallpaper) + if [ $# -ge 2 ] && [ $# -le 3 ]; then + set_wallpaper "$2" + [ $# -eq 3 ] && set_mode "$3" + else + show_usage + exit 1 + fi + ;; + *) + show_usage + exit 1 + ;; + esac + + finish +fi diff --git a/users/configs/ags/default.nix b/users/configs/ags/default.nix index cb00a8f..895e389 100644 --- a/users/configs/ags/default.nix +++ b/users/configs/ags/default.nix @@ -1,11 +1,11 @@ { user ? throw "user argument is required" }: { config, lib, pkgs, ... }: let - hmConfig = config.home-manager.users."${user.name}"; + hmConfig = config.home-manager.users.${user.name}; agsConfig = (import ./config { inherit pkgs; }); in { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { home.packages = with pkgs; [ ags ]; xdg.configFile.ags = { @@ -27,9 +27,7 @@ in nixos-icons rofi-wayland ]; - text = '' - ags &> /tmp/ags.log - ''; + text = "ags &> /tmp/ags.log"; })} &"; }; } diff --git a/users/configs/brightnessctl/default.nix b/users/configs/brightnessctl/default.nix index 0cb9720..82ff0ea 100644 --- a/users/configs/brightnessctl/default.nix +++ b/users/configs/brightnessctl/default.nix @@ -1,7 +1,7 @@ { user ? throw "user argument is required" }: { lib, pkgs, ... }: { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { home.packages = with pkgs; [ brightnessctl ]; wayland.windowManager.hyprland.settings.bindle = diff --git a/users/configs/btop/default.nix b/users/configs/btop/default.nix index 209172f..2b1834a 100644 --- a/users/configs/btop/default.nix +++ b/users/configs/btop/default.nix @@ -1,10 +1,10 @@ { user ? throw "user argument is required", gpu ? false }: { config, lib, pkgs, ... }: let - hmConfig = config.home-manager.users."${user.name}"; + hmConfig = config.home-manager.users.${user.name}; in { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { programs = { btop = { enable = true; @@ -30,9 +30,7 @@ in theme.extraConfig = "${lib.meta.getExe (pkgs.writeShellApplication { name = "reload-btop"; runtimeInputs = with pkgs; [ procps ]; - text = '' - pkill btop -SIGUSR2 - ''; + text = "pkill btop -SIGUSR2"; })} &"; }; } diff --git a/users/configs/firefox/default.nix b/users/configs/firefox/default.nix index 79c4b4d..2921bd6 100644 --- a/users/configs/firefox/default.nix +++ b/users/configs/firefox/default.nix @@ -1,7 +1,7 @@ { user ? throw "user argument is required" }: { lib, pkgs, ... }: { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { programs.firefox = { enable = true; diff --git a/users/configs/git/default.nix b/users/configs/git/default.nix index 148e8fe..e882007 100644 --- a/users/configs/git/default.nix +++ b/users/configs/git/default.nix @@ -1,10 +1,10 @@ { user ? throw "user argument is required" }: { config, lib, pkgs, ... }: let - hmConfig = config.home-manager.users."${user.name}"; + hmConfig = config.home-manager.users.${user.name}; in { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { programs.git = { enable = true; lfs.enable = true; diff --git a/users/configs/gpg-agent/default.nix b/users/configs/gpg-agent/default.nix index 7fd3f16..262ca1c 100644 --- a/users/configs/gpg-agent/default.nix +++ b/users/configs/gpg-agent/default.nix @@ -1,11 +1,11 @@ { user ? throw "user argument is required" }: { config, lib, pkgs, ... }: let - hmConfig = config.home-manager.users."${user.name}"; + hmConfig = config.home-manager.users.${user.name}; gpgPath = "${hmConfig.xdg.dataHome}/gnupg"; in { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { programs.gpg = { enable = true; homedir = gpgPath; diff --git a/users/configs/gtk/default.nix b/users/configs/gtk/default.nix index 94346de..69565c6 100644 --- a/users/configs/gtk/default.nix +++ b/users/configs/gtk/default.nix @@ -1,10 +1,10 @@ { user ? throw "user argument is required" }: { config, lib, pkgs, ... }: let - hmConfig = config.home-manager.users."${user.name}"; + hmConfig = config.home-manager.users.${user.name}; in { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { gtk = { enable = true; diff --git a/users/configs/hyprland/default.nix b/users/configs/hyprland/default.nix index a32b637..b42e488 100644 --- a/users/configs/hyprland/default.nix +++ b/users/configs/hyprland/default.nix @@ -1,12 +1,12 @@ { user ? throw "user argument is required" }: { config, lib, pkgs, ... }: let - hmConfig = config.home-manager.users."${user.name}"; + hmConfig = config.home-manager.users.${user.name}; in { programs.hyprland.enable = true; - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { wayland.windowManager.hyprland = { enable = true; @@ -110,9 +110,7 @@ in input.touchpad.natural_scroll = true; }; - extraConfig = '' - source = ./theme.conf - ''; + extraConfig = "source = ./theme.conf"; }; programs = { @@ -131,9 +129,7 @@ in theme.extraConfig = "${lib.meta.getExe (pkgs.writeShellApplication { name = "reload-hyprland"; runtimeInputs = with pkgs; [ hyprland ]; - text = '' - hyprctl reload - ''; + text = "hyprctl reload"; })} &"; home.sessionVariables.NIXOS_OZONE_WL = "1"; diff --git a/users/configs/hyprshot/default.nix b/users/configs/hyprshot/default.nix index 3bfa3f6..2821ee1 100644 --- a/users/configs/hyprshot/default.nix +++ b/users/configs/hyprshot/default.nix @@ -1,10 +1,10 @@ { user ? throw "user argument is required" }: { config, lib, pkgs, ... }: let - hmConfig = config.home-manager.users."${user.name}"; + hmConfig = config.home-manager.users.${user.name}; in { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { home = { packages = with pkgs; [ hyprshot swappy ]; sessionVariables.HYPRSHOT_DIR = "${hmConfig.xdg.userDirs.pictures}/screenshots"; @@ -19,9 +19,7 @@ in swappyWrapper = lib.meta.getExe (pkgs.writeShellApplication { name = "swappy-wrapper"; runtimeInputs = with pkgs; [ swappy ]; - text = '' - swappy -f "$1" - ''; + text = "swappy -f \"$1\""; }); in [ diff --git a/users/configs/kitty/default.nix b/users/configs/kitty/default.nix index f043c38..8c7c664 100644 --- a/users/configs/kitty/default.nix +++ b/users/configs/kitty/default.nix @@ -1,10 +1,10 @@ { user ? throw "user argument is required" }: { config, lib, pkgs, ... }: let - hmConfig = config.home-manager.users."${user.name}"; + hmConfig = config.home-manager.users.${user.name}; in { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { programs = { kitty = { enable = true; @@ -23,9 +23,7 @@ in theme.extraConfig = "${lib.meta.getExe (pkgs.writeShellApplication { name = "reload-kitty"; runtimeInputs = with pkgs; [ procps ]; - text = '' - pkill kitty -SIGUSR1 - ''; + text = "pkill kitty -SIGUSR1"; })} &"; home.persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/kitty" ]; diff --git a/users/configs/matugen/default.nix b/users/configs/matugen/default.nix index 0d99909..874f576 100644 --- a/users/configs/matugen/default.nix +++ b/users/configs/matugen/default.nix @@ -1,10 +1,10 @@ { user ? throw "user argument is required" }: { config, lib, pkgs, ... }: let - hmConfig = config.home-manager.users."${user.name}"; + hmConfig = config.home-manager.users.${user.name}; in { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { programs.matugen = { enable = true; settings = { diff --git a/users/configs/neovim/default.nix b/users/configs/neovim/default.nix index 250d349..cd9306b 100644 --- a/users/configs/neovim/default.nix +++ b/users/configs/neovim/default.nix @@ -1,7 +1,7 @@ { user ? throw "user argument is required" }: { ... }: { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { programs.neovim = { enable = true; defaultEditor = true; diff --git a/users/configs/pavucontrol/default.nix b/users/configs/pavucontrol/default.nix index 0bcd65e..15f81b7 100644 --- a/users/configs/pavucontrol/default.nix +++ b/users/configs/pavucontrol/default.nix @@ -1,5 +1,5 @@ { user ? throw "user argument is required" }: { pkgs, ... }: { - home-manager.users."${user.name}".home.packages = with pkgs; [ pavucontrol ]; + home-manager.users.${user.name}.home.packages = with pkgs; [ pavucontrol ]; } diff --git a/users/configs/pipewire/default.nix b/users/configs/pipewire/default.nix index 1711e61..54728a0 100644 --- a/users/configs/pipewire/default.nix +++ b/users/configs/pipewire/default.nix @@ -1,7 +1,7 @@ { user ? throw "user argument is required" }: { pkgs, ... }: { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { wayland.windowManager.hyprland.settings = let wpctl = "${pkgs.wireplumber}/bin/wpctl"; diff --git a/users/configs/playerctl/default.nix b/users/configs/playerctl/default.nix index 9dba29e..d116f48 100644 --- a/users/configs/playerctl/default.nix +++ b/users/configs/playerctl/default.nix @@ -1,7 +1,7 @@ { user ? throw "user argument is required" }: { lib, pkgs, ... }: { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { home.packages = with pkgs; [ playerctl ]; services.playerctld.enable = true; diff --git a/users/configs/qalculate/default.nix b/users/configs/qalculate/default.nix index 9769e54..efd6cf4 100644 --- a/users/configs/qalculate/default.nix +++ b/users/configs/qalculate/default.nix @@ -1,7 +1,7 @@ { user ? throw "user argument is required" }: { lib, config, pkgs, ... }: { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { home.packages = with pkgs; [ qalculate-gtk ]; wayland.windowManager.hyprland.settings.bind = [ diff --git a/users/configs/rofi/default.nix b/users/configs/rofi/default.nix index 2ee8111..3f57dfd 100644 --- a/users/configs/rofi/default.nix +++ b/users/configs/rofi/default.nix @@ -1,10 +1,10 @@ { user ? throw "user argument is required" }: { config, lib, pkgs, ... }: let - hmConfig = config.home-manager.users."${user.name}"; + hmConfig = config.home-manager.users.${user.name}; in { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { home = { packages = with pkgs; [ rofi-wayland ]; persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/rofi" ]; diff --git a/users/configs/swww/default.nix b/users/configs/swww/default.nix index eb46672..35304d4 100644 --- a/users/configs/swww/default.nix +++ b/users/configs/swww/default.nix @@ -1,10 +1,10 @@ { user ? throw "user argument is required" }: { config, lib, pkgs, ... }: let - hmConfig = config.home-manager.users."${user.name}"; + hmConfig = config.home-manager.users.${user.name}; in { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { home = { packages = with pkgs; [ swww ]; persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/swww" ]; @@ -31,9 +31,7 @@ in procps swww ]; - text = '' - swww img "${hmConfig.theme.configDir}/wallpaper" - ''; + text = "swww img \"${hmConfig.theme.configDir}/wallpaper\""; })} &"; }; } diff --git a/users/configs/theme/default.nix b/users/configs/theme/default.nix index 0608ab3..6d0ca78 100644 --- a/users/configs/theme/default.nix +++ b/users/configs/theme/default.nix @@ -1,11 +1,11 @@ { user ? throw "user argument is required" }: { config, inputs, lib, pkgs, ... }: let - hmConfig = config.home-manager.users."${user.name}"; + hmConfig = config.home-manager.users.${user.name}; themeBin = lib.meta.getExe hmConfig.theme.pkg; in { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { theme.enable = true; wayland.windowManager.hyprland.settings.bind = [ @@ -14,10 +14,7 @@ in ]; home = { - activation.themeInit = inputs.home-manager.lib.hm.dag.entryAfter [ "writeBoundary" ] '' - run ${themeBin} - ''; - + activation.themeInit = inputs.home-manager.lib.hm.dag.entryAfter [ "writeBoundary" ] "run ${themeBin}"; persistence."/persist${user.home}".directories = [ "${hmConfig.xdg.relativeConfigHome}/theme" ]; }; }; diff --git a/users/configs/vscode/default.nix b/users/configs/vscode/default.nix index 8d3edbe..c1004b8 100644 --- a/users/configs/vscode/default.nix +++ b/users/configs/vscode/default.nix @@ -1,7 +1,7 @@ { user ? throw "user argument is required" }: { inputs, lib, pkgs, ... }: { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { programs.vscode = { enable = true; mutableExtensionsDir = false; diff --git a/users/configs/wev/default.nix b/users/configs/wev/default.nix index a04227f..d8446f2 100644 --- a/users/configs/wev/default.nix +++ b/users/configs/wev/default.nix @@ -1,5 +1,5 @@ { user ? throw "user argument is required" }: { pkgs, ... }: { - home-manager.users."${user.name}".home.packages = with pkgs; [ wev ]; + home-manager.users.${user.name}.home.packages = with pkgs; [ wev ]; } diff --git a/users/configs/x/default.nix b/users/configs/x/default.nix index cb3997f..6aa8d8b 100644 --- a/users/configs/x/default.nix +++ b/users/configs/x/default.nix @@ -1,10 +1,10 @@ { user ? throw "user argument is required" }: { config, ... }: let - hmConfig = config.home-manager.users."${user.name}"; + hmConfig = config.home-manager.users.${user.name}; in { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { xresources.path = "${hmConfig.xdg.configHome}/X11/xresources"; }; } diff --git a/users/configs/zsh/default.nix b/users/configs/zsh/default.nix index 2091c1c..9e858c4 100644 --- a/users/configs/zsh/default.nix +++ b/users/configs/zsh/default.nix @@ -1,10 +1,10 @@ { user ? throw "user argument is required" }: { config, ... }: let - hmConfig = config.home-manager.users."${user.name}"; + hmConfig = config.home-manager.users.${user.name}; in { - home-manager.users."${user.name}" = { + home-manager.users.${user.name} = { programs.zsh = { enable = true; dotDir = "${hmConfig.xdg.relativeConfigHome}/zsh";