diff --git a/home/base/desktop/container/default.nix b/home/base/desktop/container/default.nix index 3a11d23f..eeb48a40 100644 --- a/home/base/desktop/container/default.nix +++ b/home/base/desktop/container/default.nix @@ -1,6 +1,3 @@ -{...}: { - imports = [ - ./container.nix - ./kubernetes.nix - ]; +{mylib, ...}: { + imports = mylib.scanPaths ./.; } diff --git a/home/base/desktop/default.nix b/home/base/desktop/default.nix index f1720493..eeb48a40 100644 --- a/home/base/desktop/default.nix +++ b/home/base/desktop/default.nix @@ -1,16 +1,3 @@ -{...}: { - imports = [ - ../server - - ./cloud - ./container - ./neovim - ./terminal - - ./development.nix - ./helix.nix - ./media.nix - ./shell.nix - ./yazi.nix - ]; +{mylib, ...}: { + imports = mylib.scanPaths ./.; } diff --git a/home/base/desktop/neovim/default.nix b/home/base/desktop/neovim/default.nix index 9524b092..5faa3f48 100644 --- a/home/base/desktop/neovim/default.nix +++ b/home/base/desktop/neovim/default.nix @@ -11,7 +11,10 @@ { xdg.configFile = { # astronvim's config - "nvim".source = astronvim; + "nvim" = { + source = astronvim; + force = true; + }; # my custom astronvim config, astronvim will load it after base config # https://github.com/AstroNvim/AstroNvim/blob/v3.32.0/lua/astronvim/bootstrap.lua#L15-L16 diff --git a/home/base/desktop/terminal/default.nix b/home/base/desktop/terminal/default.nix index a69bc60a..eeb48a40 100644 --- a/home/base/desktop/terminal/default.nix +++ b/home/base/desktop/terminal/default.nix @@ -1,7 +1,3 @@ -{...}: { - imports = [ - ./alacritty.nix - ./kitty.nix - ./wezterm.nix - ]; +{mylib, ...}: { + imports = mylib.scanPaths ./.; } diff --git a/home/base/server/default.nix b/home/base/server/default.nix index 563835d7..eeb48a40 100644 --- a/home/base/server/default.nix +++ b/home/base/server/default.nix @@ -1,13 +1,3 @@ -{...}: { - imports = [ - ./shells - ./tmux - ./zellij - - ./bat.nix - ./btop.nix - ./core.nix - ./git.nix - ./starship.nix - ]; +{mylib, ...}: { + imports = mylib.scanPaths ./.; } diff --git a/home/darwin/default.nix b/home/darwin/default.nix index e59839f3..268ed41e 100644 --- a/home/darwin/default.nix +++ b/home/darwin/default.nix @@ -1,11 +1,8 @@ -{username, ...}: { - imports = [ - ../base/desktop - ../base/core.nix - - ./proxychains - ./core.nix - ./rime-squirrel.nix - ./shell.nix - ]; +{mylib, ...}: { + imports = + (mylib.scanPaths ./.) + // [ + ../base/desktop + ../base/core.nix + ]; } diff --git a/home/linux/base/default.nix b/home/linux/base/default.nix index 60e82c2e..eeb48a40 100644 --- a/home/linux/base/default.nix +++ b/home/linux/base/default.nix @@ -1,6 +1,3 @@ -{ - imports = [ - ./shell.nix - ./system-tools.nix - ]; +{mylib, ...}: { + imports = mylib.scanPaths ./.; } diff --git a/home/linux/base/shell.nix b/home/linux/base/shell.nix index 993d29c6..69cbf6b3 100644 --- a/home/linux/base/shell.nix +++ b/home/linux/base/shell.nix @@ -1,8 +1,4 @@ -{ - config, - nushell-scripts, - ... -}: let +{config, ...}: let d = config.xdg.dataHome; c = config.xdg.configHome; cache = config.xdg.cacheHome; diff --git a/home/linux/desktop.nix b/home/linux/desktop.nix index c427cbf9..4232460f 100644 --- a/home/linux/desktop.nix +++ b/home/linux/desktop.nix @@ -1,10 +1,10 @@ { imports = [ + ../base/server ../base/desktop ../base/core.nix ./base - ./fcitx5 ./desktop ]; } diff --git a/home/linux/desktop/creative.nix b/home/linux/desktop/base/creative.nix similarity index 100% rename from home/linux/desktop/creative.nix rename to home/linux/desktop/base/creative.nix diff --git a/home/linux/desktop/base/default.nix b/home/linux/desktop/base/default.nix new file mode 100644 index 00000000..eeb48a40 --- /dev/null +++ b/home/linux/desktop/base/default.nix @@ -0,0 +1,3 @@ +{mylib, ...}: { + imports = mylib.scanPaths ./.; +} diff --git a/home/linux/desktop/eye-protection.nix b/home/linux/desktop/base/eye-protection.nix similarity index 100% rename from home/linux/desktop/eye-protection.nix rename to home/linux/desktop/base/eye-protection.nix diff --git a/home/linux/fcitx5/classicui.conf b/home/linux/desktop/base/fcitx5/classicui.conf similarity index 100% rename from home/linux/fcitx5/classicui.conf rename to home/linux/desktop/base/fcitx5/classicui.conf diff --git a/home/linux/fcitx5/default.nix b/home/linux/desktop/base/fcitx5/default.nix similarity index 100% rename from home/linux/fcitx5/default.nix rename to home/linux/desktop/base/fcitx5/default.nix diff --git a/home/linux/fcitx5/profile b/home/linux/desktop/base/fcitx5/profile similarity index 100% rename from home/linux/fcitx5/profile rename to home/linux/desktop/base/fcitx5/profile diff --git a/home/linux/desktop/gtk.nix b/home/linux/desktop/base/gtk.nix similarity index 100% rename from home/linux/desktop/gtk.nix rename to home/linux/desktop/base/gtk.nix diff --git a/home/linux/desktop/immutable-file.nix b/home/linux/desktop/base/immutable-file.nix similarity index 100% rename from home/linux/desktop/immutable-file.nix rename to home/linux/desktop/base/immutable-file.nix diff --git a/home/linux/desktop/media.nix b/home/linux/desktop/base/media.nix similarity index 100% rename from home/linux/desktop/media.nix rename to home/linux/desktop/base/media.nix diff --git a/home/linux/desktop/base/misc.nix b/home/linux/desktop/base/misc.nix new file mode 100644 index 00000000..42b6b6f9 --- /dev/null +++ b/home/linux/desktop/base/misc.nix @@ -0,0 +1,30 @@ +{ + pkgs, + ... +}: { + + home.packages = with pkgs; [ + # GUI apps + # e-book viewer(.epub/.mobi/...) + # do not support .pdf + foliate + + # instant messaging + telegram-desktop + discord + qq # https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/networking/instant-messengers/qq + + # remote desktop(rdp connect) + remmina + freerdp # required by remmina + + # misc + flameshot + ventoy # multi-boot usb creator + ]; + + # GitHub CLI tool + programs.gh = { + enable = true; + }; +} diff --git a/home/linux/desktop/ssh.nix b/home/linux/desktop/base/ssh.nix similarity index 100% rename from home/linux/desktop/ssh.nix rename to home/linux/desktop/base/ssh.nix diff --git a/home/linux/desktop/wallpaper/default.nix b/home/linux/desktop/base/wallpaper/default.nix similarity index 100% rename from home/linux/desktop/wallpaper/default.nix rename to home/linux/desktop/base/wallpaper/default.nix diff --git a/home/linux/desktop/wallpaper/wallpaper-switcher.py b/home/linux/desktop/base/wallpaper/wallpaper-switcher.py similarity index 100% rename from home/linux/desktop/wallpaper/wallpaper-switcher.py rename to home/linux/desktop/base/wallpaper/wallpaper-switcher.py diff --git a/home/linux/desktop/xdg.nix b/home/linux/desktop/base/xdg.nix similarity index 100% rename from home/linux/desktop/xdg.nix rename to home/linux/desktop/base/xdg.nix diff --git a/home/linux/desktop/default.nix b/home/linux/desktop/default.nix index c956e98d..eeb48a40 100644 --- a/home/linux/desktop/default.nix +++ b/home/linux/desktop/default.nix @@ -1,38 +1,3 @@ -{pkgs, ...}: { - imports = [ - ./wallpaper - - ./creative.nix - ./gtk.nix - ./immutable-file.nix - ./media.nix - ./ssh.nix - ./xdg.nix - ./eye-protection.nix - ]; - - home.packages = with pkgs; [ - # GUI apps - # e-book viewer(.epub/.mobi/...) - # do not support .pdf - foliate - - # instant messaging - telegram-desktop - discord - qq # https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/networking/instant-messengers/qq - - # remote desktop(rdp connect) - remmina - freerdp # required by remmina - - # misc - flameshot - ventoy # multi-boot usb creator - ]; - - # GitHub CLI tool - programs.gh = { - enable = true; - }; +{mylib, ...}: { + imports = mylib.scanPaths ./.; } diff --git a/home/linux/hyprland/anyrun.nix b/home/linux/desktop/hyprland/anyrun.nix similarity index 96% rename from home/linux/hyprland/anyrun.nix rename to home/linux/desktop/hyprland/anyrun.nix index 9272e7a4..403f57ba 100644 --- a/home/linux/hyprland/anyrun.nix +++ b/home/linux/desktop/hyprland/anyrun.nix @@ -3,10 +3,6 @@ anyrun, ... }: { - imports = [ - anyrun.homeManagerModules.default - ]; - programs.anyrun = { enable = true; config = { diff --git a/home/linux/desktop/hyprland/default.nix b/home/linux/desktop/hyprland/default.nix new file mode 100644 index 00000000..56d022ac --- /dev/null +++ b/home/linux/desktop/hyprland/default.nix @@ -0,0 +1,30 @@ +{ + pkgs, + config, + lib, + anyrun, + ... +} @ args: +with lib; let + cfg = config.modules.desktop.hyprland; +in { + imports = [ + anyrun.homeManagerModules.default + ]; + + options.modules.desktop.hyprland = { + enable = mkEnableOption "hyprland compositor"; + }; + + config = mkIf cfg.enable ( + mkMerge + (map + (path: import path args) + [ + ./hyprland.nix + ./packages.nix + ./anyrun.nix + ./wayland-apps.nix + ]) + ); +} diff --git a/home/linux/hyprland/hypr-conf/hyprland.conf b/home/linux/desktop/hyprland/hypr-conf/hyprland.conf similarity index 100% rename from home/linux/hyprland/hypr-conf/hyprland.conf rename to home/linux/desktop/hyprland/hypr-conf/hyprland.conf diff --git a/home/linux/hyprland/hypr-conf/mako/config b/home/linux/desktop/hyprland/hypr-conf/mako/config similarity index 100% rename from home/linux/hyprland/hypr-conf/mako/config rename to home/linux/desktop/hyprland/hypr-conf/mako/config diff --git a/home/linux/hyprland/hypr-conf/mako/icons/brightness-100.png b/home/linux/desktop/hyprland/hypr-conf/mako/icons/brightness-100.png similarity index 100% rename from home/linux/hyprland/hypr-conf/mako/icons/brightness-100.png rename to home/linux/desktop/hyprland/hypr-conf/mako/icons/brightness-100.png diff --git a/home/linux/hyprland/hypr-conf/mako/icons/brightness-20.png b/home/linux/desktop/hyprland/hypr-conf/mako/icons/brightness-20.png similarity index 100% rename from home/linux/hyprland/hypr-conf/mako/icons/brightness-20.png rename to home/linux/desktop/hyprland/hypr-conf/mako/icons/brightness-20.png diff --git a/home/linux/hyprland/hypr-conf/mako/icons/brightness-40.png b/home/linux/desktop/hyprland/hypr-conf/mako/icons/brightness-40.png similarity index 100% rename from home/linux/hyprland/hypr-conf/mako/icons/brightness-40.png rename to home/linux/desktop/hyprland/hypr-conf/mako/icons/brightness-40.png diff --git a/home/linux/hyprland/hypr-conf/mako/icons/brightness-60.png b/home/linux/desktop/hyprland/hypr-conf/mako/icons/brightness-60.png similarity index 100% rename from home/linux/hyprland/hypr-conf/mako/icons/brightness-60.png rename to home/linux/desktop/hyprland/hypr-conf/mako/icons/brightness-60.png diff --git a/home/linux/hyprland/hypr-conf/mako/icons/brightness-80.png b/home/linux/desktop/hyprland/hypr-conf/mako/icons/brightness-80.png similarity index 100% rename from home/linux/hyprland/hypr-conf/mako/icons/brightness-80.png rename to home/linux/desktop/hyprland/hypr-conf/mako/icons/brightness-80.png diff --git a/home/linux/hyprland/hypr-conf/mako/icons/dropper.png b/home/linux/desktop/hyprland/hypr-conf/mako/icons/dropper.png similarity index 100% rename from home/linux/hyprland/hypr-conf/mako/icons/dropper.png rename to home/linux/desktop/hyprland/hypr-conf/mako/icons/dropper.png diff --git a/home/linux/hyprland/hypr-conf/mako/icons/microphone-mute.png b/home/linux/desktop/hyprland/hypr-conf/mako/icons/microphone-mute.png similarity index 100% rename from home/linux/hyprland/hypr-conf/mako/icons/microphone-mute.png rename to home/linux/desktop/hyprland/hypr-conf/mako/icons/microphone-mute.png diff --git a/home/linux/hyprland/hypr-conf/mako/icons/microphone.png b/home/linux/desktop/hyprland/hypr-conf/mako/icons/microphone.png similarity index 100% rename from home/linux/hyprland/hypr-conf/mako/icons/microphone.png rename to home/linux/desktop/hyprland/hypr-conf/mako/icons/microphone.png diff --git a/home/linux/hyprland/hypr-conf/mako/icons/music.png b/home/linux/desktop/hyprland/hypr-conf/mako/icons/music.png similarity index 100% rename from home/linux/hyprland/hypr-conf/mako/icons/music.png rename to home/linux/desktop/hyprland/hypr-conf/mako/icons/music.png diff --git a/home/linux/hyprland/hypr-conf/mako/icons/palette.png b/home/linux/desktop/hyprland/hypr-conf/mako/icons/palette.png similarity index 100% rename from home/linux/hyprland/hypr-conf/mako/icons/palette.png rename to home/linux/desktop/hyprland/hypr-conf/mako/icons/palette.png diff --git a/home/linux/hyprland/hypr-conf/mako/icons/picture.png b/home/linux/desktop/hyprland/hypr-conf/mako/icons/picture.png similarity index 100% rename from home/linux/hyprland/hypr-conf/mako/icons/picture.png rename to home/linux/desktop/hyprland/hypr-conf/mako/icons/picture.png diff --git a/home/linux/hyprland/hypr-conf/mako/icons/timer.png b/home/linux/desktop/hyprland/hypr-conf/mako/icons/timer.png similarity index 100% rename from home/linux/hyprland/hypr-conf/mako/icons/timer.png rename to home/linux/desktop/hyprland/hypr-conf/mako/icons/timer.png diff --git a/home/linux/hyprland/hypr-conf/mako/icons/volume-high.png b/home/linux/desktop/hyprland/hypr-conf/mako/icons/volume-high.png similarity index 100% rename from home/linux/hyprland/hypr-conf/mako/icons/volume-high.png rename to home/linux/desktop/hyprland/hypr-conf/mako/icons/volume-high.png diff --git a/home/linux/hyprland/hypr-conf/mako/icons/volume-low.png b/home/linux/desktop/hyprland/hypr-conf/mako/icons/volume-low.png similarity index 100% rename from home/linux/hyprland/hypr-conf/mako/icons/volume-low.png rename to home/linux/desktop/hyprland/hypr-conf/mako/icons/volume-low.png diff --git a/home/linux/hyprland/hypr-conf/mako/icons/volume-mid.png b/home/linux/desktop/hyprland/hypr-conf/mako/icons/volume-mid.png similarity index 100% rename from home/linux/hyprland/hypr-conf/mako/icons/volume-mid.png rename to home/linux/desktop/hyprland/hypr-conf/mako/icons/volume-mid.png diff --git a/home/linux/hyprland/hypr-conf/mako/icons/volume-mute.png b/home/linux/desktop/hyprland/hypr-conf/mako/icons/volume-mute.png similarity index 100% rename from home/linux/hyprland/hypr-conf/mako/icons/volume-mute.png rename to home/linux/desktop/hyprland/hypr-conf/mako/icons/volume-mute.png diff --git a/home/linux/hyprland/hypr-conf/scripts/brightness b/home/linux/desktop/hyprland/hypr-conf/scripts/brightness similarity index 100% rename from home/linux/hyprland/hypr-conf/scripts/brightness rename to home/linux/desktop/hyprland/hypr-conf/scripts/brightness diff --git a/home/linux/hyprland/hypr-conf/scripts/colorpicker b/home/linux/desktop/hyprland/hypr-conf/scripts/colorpicker similarity index 100% rename from home/linux/hyprland/hypr-conf/scripts/colorpicker rename to home/linux/desktop/hyprland/hypr-conf/scripts/colorpicker diff --git a/home/linux/hyprland/hypr-conf/scripts/lockscreen b/home/linux/desktop/hyprland/hypr-conf/scripts/lockscreen similarity index 100% rename from home/linux/hyprland/hypr-conf/scripts/lockscreen rename to home/linux/desktop/hyprland/hypr-conf/scripts/lockscreen diff --git a/home/linux/hyprland/hypr-conf/scripts/menu b/home/linux/desktop/hyprland/hypr-conf/scripts/menu similarity index 100% rename from home/linux/hyprland/hypr-conf/scripts/menu rename to home/linux/desktop/hyprland/hypr-conf/scripts/menu diff --git a/home/linux/hyprland/hypr-conf/scripts/notifications b/home/linux/desktop/hyprland/hypr-conf/scripts/notifications similarity index 100% rename from home/linux/hyprland/hypr-conf/scripts/notifications rename to home/linux/desktop/hyprland/hypr-conf/scripts/notifications diff --git a/home/linux/hyprland/hypr-conf/scripts/screenshot b/home/linux/desktop/hyprland/hypr-conf/scripts/screenshot similarity index 100% rename from home/linux/hyprland/hypr-conf/scripts/screenshot rename to home/linux/desktop/hyprland/hypr-conf/scripts/screenshot diff --git a/home/linux/hyprland/hypr-conf/scripts/startup b/home/linux/desktop/hyprland/hypr-conf/scripts/startup similarity index 100% rename from home/linux/hyprland/hypr-conf/scripts/startup rename to home/linux/desktop/hyprland/hypr-conf/scripts/startup diff --git a/home/linux/hyprland/hypr-conf/scripts/statusbar b/home/linux/desktop/hyprland/hypr-conf/scripts/statusbar similarity index 100% rename from home/linux/hyprland/hypr-conf/scripts/statusbar rename to home/linux/desktop/hyprland/hypr-conf/scripts/statusbar diff --git a/home/linux/hyprland/hypr-conf/scripts/volume b/home/linux/desktop/hyprland/hypr-conf/scripts/volume similarity index 100% rename from home/linux/hyprland/hypr-conf/scripts/volume rename to home/linux/desktop/hyprland/hypr-conf/scripts/volume diff --git a/home/linux/hyprland/hypr-conf/scripts/wlogout b/home/linux/desktop/hyprland/hypr-conf/scripts/wlogout similarity index 100% rename from home/linux/hyprland/hypr-conf/scripts/wlogout rename to home/linux/desktop/hyprland/hypr-conf/scripts/wlogout diff --git a/home/linux/hyprland/hypr-conf/waybar/config.jsonc b/home/linux/desktop/hyprland/hypr-conf/waybar/config.jsonc similarity index 100% rename from home/linux/hyprland/hypr-conf/waybar/config.jsonc rename to home/linux/desktop/hyprland/hypr-conf/waybar/config.jsonc diff --git a/home/linux/hyprland/hypr-conf/waybar/style.css b/home/linux/desktop/hyprland/hypr-conf/waybar/style.css similarity index 100% rename from home/linux/hyprland/hypr-conf/waybar/style.css rename to home/linux/desktop/hyprland/hypr-conf/waybar/style.css diff --git a/home/linux/hyprland/hypr-conf/wlogout/icons/hibernate.png b/home/linux/desktop/hyprland/hypr-conf/wlogout/icons/hibernate.png similarity index 100% rename from home/linux/hyprland/hypr-conf/wlogout/icons/hibernate.png rename to home/linux/desktop/hyprland/hypr-conf/wlogout/icons/hibernate.png diff --git a/home/linux/hyprland/hypr-conf/wlogout/icons/lock.png b/home/linux/desktop/hyprland/hypr-conf/wlogout/icons/lock.png similarity index 100% rename from home/linux/hyprland/hypr-conf/wlogout/icons/lock.png rename to home/linux/desktop/hyprland/hypr-conf/wlogout/icons/lock.png diff --git a/home/linux/hyprland/hypr-conf/wlogout/icons/logout.png b/home/linux/desktop/hyprland/hypr-conf/wlogout/icons/logout.png similarity index 100% rename from home/linux/hyprland/hypr-conf/wlogout/icons/logout.png rename to home/linux/desktop/hyprland/hypr-conf/wlogout/icons/logout.png diff --git a/home/linux/hyprland/hypr-conf/wlogout/icons/reboot.png b/home/linux/desktop/hyprland/hypr-conf/wlogout/icons/reboot.png similarity index 100% rename from home/linux/hyprland/hypr-conf/wlogout/icons/reboot.png rename to home/linux/desktop/hyprland/hypr-conf/wlogout/icons/reboot.png diff --git a/home/linux/hyprland/hypr-conf/wlogout/icons/shutdown.png b/home/linux/desktop/hyprland/hypr-conf/wlogout/icons/shutdown.png similarity index 100% rename from home/linux/hyprland/hypr-conf/wlogout/icons/shutdown.png rename to home/linux/desktop/hyprland/hypr-conf/wlogout/icons/shutdown.png diff --git a/home/linux/hyprland/hypr-conf/wlogout/icons/suspend.png b/home/linux/desktop/hyprland/hypr-conf/wlogout/icons/suspend.png similarity index 100% rename from home/linux/hyprland/hypr-conf/wlogout/icons/suspend.png rename to home/linux/desktop/hyprland/hypr-conf/wlogout/icons/suspend.png diff --git a/home/linux/hyprland/hypr-conf/wlogout/layout b/home/linux/desktop/hyprland/hypr-conf/wlogout/layout similarity index 100% rename from home/linux/hyprland/hypr-conf/wlogout/layout rename to home/linux/desktop/hyprland/hypr-conf/wlogout/layout diff --git a/home/linux/hyprland/hypr-conf/wlogout/style.css b/home/linux/desktop/hyprland/hypr-conf/wlogout/style.css similarity index 100% rename from home/linux/hyprland/hypr-conf/wlogout/style.css rename to home/linux/desktop/hyprland/hypr-conf/wlogout/style.css diff --git a/home/linux/hyprland/default.nix b/home/linux/desktop/hyprland/hyprland.nix similarity index 96% rename from home/linux/hyprland/default.nix rename to home/linux/desktop/hyprland/hyprland.nix index 6b4672a1..825ec7d3 100644 --- a/home/linux/hyprland/default.nix +++ b/home/linux/desktop/hyprland/hyprland.nix @@ -1,16 +1,10 @@ { - lib, pkgs, + lib, hyprland, nur-ryan4yin, ... }: { - imports = [ - ./anyrun.nix - ./wayland-apps.nix - ./packages.nix - ]; - # NOTE: # We have to enable hyprland/i3's systemd user service in home-manager, # so that gammastep/wallpaper-switcher's user service can be start correctly! diff --git a/home/linux/hyprland/mpd/mpd.conf b/home/linux/desktop/hyprland/mpd/mpd.conf similarity index 100% rename from home/linux/hyprland/mpd/mpd.conf rename to home/linux/desktop/hyprland/mpd/mpd.conf diff --git a/home/linux/hyprland/packages.nix b/home/linux/desktop/hyprland/packages.nix similarity index 100% rename from home/linux/hyprland/packages.nix rename to home/linux/desktop/hyprland/packages.nix diff --git a/home/linux/hyprland/wayland-apps.nix b/home/linux/desktop/hyprland/wayland-apps.nix similarity index 97% rename from home/linux/hyprland/wayland-apps.nix rename to home/linux/desktop/hyprland/wayland-apps.nix index 246ebd90..728797f9 100644 --- a/home/linux/hyprland/wayland-apps.nix +++ b/home/linux/desktop/hyprland/wayland-apps.nix @@ -8,7 +8,7 @@ commandLineArgs = [ # make it use GTK_IM_MODULE if it runs with Gtk4, so fcitx5 can work with it. # (only supported by chromium/chrome at this time, not electron) - "--gtk-version=5" + "--gtk-version=4" "--enable-features=UseOzonePlatform" "--ozone-platform=wayland" # make it use text-input-v1, which works for kwin 5.27 and weston diff --git a/home/linux/i3/bin/bright b/home/linux/desktop/i3/bin/bright similarity index 100% rename from home/linux/i3/bin/bright rename to home/linux/desktop/i3/bin/bright diff --git a/home/linux/i3/bin/logout b/home/linux/desktop/i3/bin/logout similarity index 100% rename from home/linux/i3/bin/logout rename to home/linux/desktop/i3/bin/logout diff --git a/home/linux/desktop/i3/default.nix b/home/linux/desktop/i3/default.nix new file mode 100644 index 00000000..e9386eaf --- /dev/null +++ b/home/linux/desktop/i3/default.nix @@ -0,0 +1,24 @@ +{ + pkgs, + config, + lib, + ... +} @ args: +with lib; let + cfg = config.modules.desktop.i3; +in { + options.modules.desktop.i3 = { + enable = mkEnableOption "i3 window manager"; + }; + + config = mkIf cfg.enable ( + mkMerge + (map + (path: import path args) + [ + ./i3.nix + ./packages.nix + ./x11-apps.nix + ]) + ); +} diff --git a/home/linux/i3/dual-monitor-4k-1080p.sh b/home/linux/desktop/i3/dual-monitor-4k-1080p.sh similarity index 100% rename from home/linux/i3/dual-monitor-4k-1080p.sh rename to home/linux/desktop/i3/dual-monitor-4k-1080p.sh diff --git a/home/linux/i3/config b/home/linux/desktop/i3/i3-config similarity index 100% rename from home/linux/i3/config rename to home/linux/desktop/i3/i3-config diff --git a/home/linux/i3/default.nix b/home/linux/desktop/i3/i3.nix similarity index 94% rename from home/linux/i3/default.nix rename to home/linux/desktop/i3/i3.nix index c8c70cbc..2fac9409 100644 --- a/home/linux/i3/default.nix +++ b/home/linux/desktop/i3/i3.nix @@ -1,11 +1,6 @@ _: { # i3 window manager's config, based on https://github.com/endeavouros-team/endeavouros-i3wm-setup - imports = [ - ./packages.nix - ./x11-apps.nix - ]; - # NOTE: # We have to enable hyprland/i3's systemd user service in home-manager, # so that gammastep/wallpaper-switcher's user service can be start correctly! @@ -14,7 +9,7 @@ _: { enable = true; windowManager.i3 = { enable = true; - extraConfig = builtins.readFile ./config; + extraConfig = builtins.readFile ./i3-config; }; # Path, relative to HOME, where Home Manager should write the X session script. # and NixOS will use it to start xorg session when system boot up diff --git a/home/linux/i3/i3blocks.conf b/home/linux/desktop/i3/i3blocks.conf similarity index 100% rename from home/linux/i3/i3blocks.conf rename to home/linux/desktop/i3/i3blocks.conf diff --git a/home/linux/i3/layouts/README.md b/home/linux/desktop/i3/layouts/README.md similarity index 100% rename from home/linux/i3/layouts/README.md rename to home/linux/desktop/i3/layouts/README.md diff --git a/home/linux/i3/layouts/idols-monitor.json b/home/linux/desktop/i3/layouts/idols-monitor.json similarity index 100% rename from home/linux/i3/layouts/idols-monitor.json rename to home/linux/desktop/i3/layouts/idols-monitor.json diff --git a/home/linux/i3/packages.nix b/home/linux/desktop/i3/packages.nix similarity index 100% rename from home/linux/i3/packages.nix rename to home/linux/desktop/i3/packages.nix diff --git a/home/linux/i3/rofi-conf/arc_dark_colors.rasi b/home/linux/desktop/i3/rofi-conf/arc_dark_colors.rasi similarity index 100% rename from home/linux/i3/rofi-conf/arc_dark_colors.rasi rename to home/linux/desktop/i3/rofi-conf/arc_dark_colors.rasi diff --git a/home/linux/i3/rofi-conf/arc_dark_transparent_colors.rasi b/home/linux/desktop/i3/rofi-conf/arc_dark_transparent_colors.rasi similarity index 100% rename from home/linux/i3/rofi-conf/arc_dark_transparent_colors.rasi rename to home/linux/desktop/i3/rofi-conf/arc_dark_transparent_colors.rasi diff --git a/home/linux/i3/rofi-conf/power-profiles.rasi b/home/linux/desktop/i3/rofi-conf/power-profiles.rasi similarity index 100% rename from home/linux/i3/rofi-conf/power-profiles.rasi rename to home/linux/desktop/i3/rofi-conf/power-profiles.rasi diff --git a/home/linux/i3/rofi-conf/powermenu.rasi b/home/linux/desktop/i3/rofi-conf/powermenu.rasi similarity index 100% rename from home/linux/i3/rofi-conf/powermenu.rasi rename to home/linux/desktop/i3/rofi-conf/powermenu.rasi diff --git a/home/linux/i3/rofi-conf/rofidmenu.rasi b/home/linux/desktop/i3/rofi-conf/rofidmenu.rasi similarity index 100% rename from home/linux/i3/rofi-conf/rofidmenu.rasi rename to home/linux/desktop/i3/rofi-conf/rofidmenu.rasi diff --git a/home/linux/i3/rofi-conf/rofikeyhint.rasi b/home/linux/desktop/i3/rofi-conf/rofikeyhint.rasi similarity index 100% rename from home/linux/i3/rofi-conf/rofikeyhint.rasi rename to home/linux/desktop/i3/rofi-conf/rofikeyhint.rasi diff --git a/home/linux/i3/scripts/README.md b/home/linux/desktop/i3/scripts/README.md similarity index 100% rename from home/linux/i3/scripts/README.md rename to home/linux/desktop/i3/scripts/README.md diff --git a/home/linux/i3/scripts/bandwidth b/home/linux/desktop/i3/scripts/bandwidth similarity index 100% rename from home/linux/i3/scripts/bandwidth rename to home/linux/desktop/i3/scripts/bandwidth diff --git a/home/linux/i3/scripts/blur-lock b/home/linux/desktop/i3/scripts/blur-lock similarity index 100% rename from home/linux/i3/scripts/blur-lock rename to home/linux/desktop/i3/scripts/blur-lock diff --git a/home/linux/i3/scripts/empty_workspace b/home/linux/desktop/i3/scripts/empty_workspace similarity index 100% rename from home/linux/i3/scripts/empty_workspace rename to home/linux/desktop/i3/scripts/empty_workspace diff --git a/home/linux/i3/scripts/power-profiles b/home/linux/desktop/i3/scripts/power-profiles similarity index 100% rename from home/linux/i3/scripts/power-profiles rename to home/linux/desktop/i3/scripts/power-profiles diff --git a/home/linux/i3/scripts/powermenu b/home/linux/desktop/i3/scripts/powermenu similarity index 100% rename from home/linux/i3/scripts/powermenu rename to home/linux/desktop/i3/scripts/powermenu diff --git a/home/linux/i3/scripts/restore-idols-monitor.sh b/home/linux/desktop/i3/scripts/restore-idols-monitor.sh similarity index 100% rename from home/linux/i3/scripts/restore-idols-monitor.sh rename to home/linux/desktop/i3/scripts/restore-idols-monitor.sh diff --git a/home/linux/i3/x11-apps.nix b/home/linux/desktop/i3/x11-apps.nix similarity index 100% rename from home/linux/i3/x11-apps.nix rename to home/linux/desktop/i3/x11-apps.nix diff --git a/lib/attrs.nix b/lib/attrs.nix index f1c067d9..6421e095 100644 --- a/lib/attrs.nix +++ b/lib/attrs.nix @@ -1,6 +1,4 @@ -{ lib, ... }: - -rec { +{lib, ...}: { # Generate an attribute set from a list. # # lib.genAttrs [ "foo" "bar" ] (name: "x_" + name) @@ -8,7 +6,7 @@ rec { listToAttrs = lib.genAttrs; # Update only the values of the given attribute set. - # + # # mapAttrs # (name: value: ("bar-" + value)) # { x = "a"; y = "b"; } @@ -16,7 +14,7 @@ rec { mapAttrs = lib.attrsets.mapAttrs; # Update both the names and values of the given attribute set. - # + # # mapAttrs' # (name: value: nameValuePair ("foo_" + name) ("bar-" + value)) # { x = "a"; y = "b"; } @@ -24,6 +22,7 @@ rec { mapAttrs' = lib.attrsets.mapAttrs'; # Merge a list of attribute sets into one. smilar to the operator `a // b`, but for a list of attribute sets. + # NOTE: the later attribute set overrides the former one! # # mergeAttrsList # [ { x = "a"; y = "b"; } { x = "c"; z = "d"; } { g = "e"; } ] @@ -31,7 +30,7 @@ rec { mergeAttrsList = lib.attrsets.mergeAttrsList; # Generate a string from an attribute set. - # + # # attrsets.foldlAttrs # (acc: name: value: acc + "\nexport ${name}=${value}") # "# A shell script" diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 00000000..ce4fce09 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,18 @@ +{lib, ...}: { + colmenaSystem = import ./colmenaSystem.nix; + macosSystem = import ./macosSystem.nix; + nixosSystem = import ./nixosSystem.nix; + attrs = import ./attrs.nix {inherit lib;}; + scanPaths = path: + builtins.map + (f: (path + "/${f}")) + (builtins.filter # find all overlay files in the current directory + + ( + f: + f + != "default.nix" # ignore default.nix + && f != "README.md" # ignore README.md + ) + (builtins.attrNames (builtins.readDir path))); +} diff --git a/modules/base.nix b/modules/base.nix index 2f7c4215..ce9f69e2 100644 --- a/modules/base.nix +++ b/modules/base.nix @@ -32,7 +32,4 @@ ]; builders-use-substitutes = true; }; - - # Allow unfree packages - nixpkgs.config.allowUnfree = lib.mkDefault false; } diff --git a/modules/nixos/base/default.nix b/modules/nixos/base/default.nix new file mode 100644 index 00000000..eeb48a40 --- /dev/null +++ b/modules/nixos/base/default.nix @@ -0,0 +1,3 @@ +{mylib, ...}: { + imports = mylib.scanPaths ./.; +} diff --git a/modules/nixos/base/misc.nix b/modules/nixos/base/misc.nix index 737be3d6..df6f0783 100644 --- a/modules/nixos/base/misc.nix +++ b/modules/nixos/base/misc.nix @@ -11,7 +11,7 @@ ################################################################################### # to install chrome, you need to enable unfree packages - nixpkgs.config.allowUnfree = true; + nixpkgs.config.allowUnfree = lib.mkForce true; # for nix server, we do not need to keep too much generations boot.loader.systemd-boot.configurationLimit = lib.mkDefault 10; diff --git a/modules/nixos/desktop.nix b/modules/nixos/desktop.nix new file mode 100644 index 00000000..6d4a475b --- /dev/null +++ b/modules/nixos/desktop.nix @@ -0,0 +1,103 @@ +{ + pkgs, + config, + lib, + username, + ... +}: +with lib; let + cfgWayland = config.modules.desktop.wayland; + cfgXorg = config.modules.desktop.xorg; +in { + imports = [ + ./base + ../base.nix + + ./desktop + ]; + + options.modules.desktop = { + wayland = { + enable = mkEnableOption "Wayland Display Server"; + }; + xorg = { + enable = mkEnableOption "Xorg Display Server"; + }; + }; + + config = mkMerge [ + (mkIf cfgWayland.enable { + #################################################################### + # NixOS's Configuration for Wayland based Window Manager + #################################################################### + xdg.portal = { + enable = true; + wlr.enable = true; + extraPortals = with pkgs; [ + xdg-desktop-portal-wlr + ]; + }; + + services = { + xserver.enable = false; # disable xorg server + # https://wiki.archlinux.org/title/Greetd + greetd = { + enable = true; + settings = { + default_session = { + # Wayland Desktop Manager is installed only for user ryan via home-manager! + user = username; + # .wayland-session is a script generated by home-manager, which links to the current wayland compositor(sway/hyprland or others). + # with such a vendor-no-locking script, we can switch to another wayland compositor without modifying greetd's config here. + command = "$HOME/.wayland-session"; # start a wayland session directly without a login manager + # command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd $HOME/.wayland-session"; # start wayland session with a TUI login manager + }; + }; + }; + }; + + # fix https://github.com/ryan4yin/nix-config/issues/10 + security.pam.services.swaylock = {}; + }) + + (mkIf cfgXorg.enable { + #################################################################### + # NixOS's Configuration for Xorg Server + #################################################################### + + services = { + gvfs.enable = true; # Mount, trash, and other functionalities + tumbler.enable = true; # Thumbnail support for images + + xserver = { + enable = true; + displayManager = { + lightdm.enable = true; + autoLogin = { + enable = true; + user = username; + }; + # use a fake session to skip desktop manager + # and let Home Manager take care of the X session + defaultSession = "hm-session"; + }; + desktopManager = { + runXdgAutostartIfNone = true; + session = [ + { + name = "hm-session"; + manage = "window"; + start = '' + ${pkgs.runtimeShell} $HOME/.xsession & + waitPID=$! + ''; + } + ]; + }; + # Configure keymap in X11 + xkb.layout = "us"; + }; + }; + }) + ]; +} diff --git a/modules/nixos/server.nix b/modules/nixos/server.nix index 6a1f9c47..2a404721 100644 --- a/modules/nixos/server.nix +++ b/modules/nixos/server.nix @@ -1,12 +1,6 @@ { imports = [ - ./base/i18n.nix - ./base/misc.nix - ./base/networking.nix - ./base/remote-building.nix - ./base/user-group.nix - ./base/visualisation.nix - + ./base ../base.nix ]; } diff --git a/modules/nixos/wayland.nix b/modules/nixos/wayland.nix deleted file mode 100644 index 06507635..00000000 --- a/modules/nixos/wayland.nix +++ /dev/null @@ -1,50 +0,0 @@ -{pkgs, ...}: { - ########################################################################################################## - # - # NixOS's Configuration for Wayland based Window Manager - # - # hyprland: project starts from 2022, support Wayland, envolving fast, good looking, support Nvidia GPU. - # - ########################################################################################################## - - imports = [ - ./base/i18n.nix - ./base/misc.nix - ./base/networking.nix - ./base/remote-building.nix - ./base/user-group.nix - ./base/visualisation.nix - - ./desktop - ../base.nix - ]; - - xdg.portal = { - enable = true; - wlr.enable = true; - extraPortals = with pkgs; [ - xdg-desktop-portal-wlr - ]; - }; - - services = { - xserver.enable = false; # disable xorg server - # https://wiki.archlinux.org/title/Greetd - greetd = { - enable = true; - settings = { - default_session = { - # Wayland Desktop Manager is installed only for user ryan via home-manager! - user = "ryan"; - # .wayland-session is a script generated by home-manager, which links to the current wayland compositor(sway/hyprland or others). - # with such a vendor-no-locking script, we can switch to another wayland compositor without modifying greetd's config here. - command = "$HOME/.wayland-session"; # start a wayland session directly without a login manager - # command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd $HOME/.wayland-session"; # start wayland session with a TUI login manager - }; - }; - }; - }; - - # fix https://github.com/ryan4yin/nix-config/issues/10 - security.pam.services.swaylock = {}; -} diff --git a/modules/nixos/xorg.nix b/modules/nixos/xorg.nix deleted file mode 100644 index b0e3f7ad..00000000 --- a/modules/nixos/xorg.nix +++ /dev/null @@ -1,53 +0,0 @@ -{pkgs, ...}: { - #################################################################### - # - # NixOS's Configuration for Xorg Server - # - #################################################################### - - imports = [ - ./base/i18n.nix - ./base/misc.nix - ./base/networking.nix - ./base/remote-building.nix - ./base/user-group.nix - ./base/visualisation.nix - - ./desktop - ../base.nix - ]; - - services = { - gvfs.enable = true; # Mount, trash, and other functionalities - tumbler.enable = true; # Thumbnail support for images - - xserver = { - enable = true; - displayManager = { - lightdm.enable = true; - autoLogin = { - enable = true; - user = "ryan"; - }; - # use a fake session to skip desktop manager - # and let Home Manager take care of the X session - defaultSession = "hm-session"; - }; - desktopManager = { - runXdgAutostartIfNone = true; - session = [ - { - name = "hm-session"; - manage = "window"; - start = '' - ${pkgs.runtimeShell} $HOME/.xsession & - waitPID=$! - ''; - } - ]; - }; - # Configure keymap in X11 - xkb.layout = "us"; - }; - }; -} diff --git a/systems/colmena.nix b/systems/colmena.nix index 94302c13..5775df22 100644 --- a/systems/colmena.nix +++ b/systems/colmena.nix @@ -1,7 +1,7 @@ args: with args; +with mylib; with allSystemAttrs; let - colmenaSystem = import ../lib/colmenaSystem.nix; # x86_64 related x64_base_args = { inherit home-manager; @@ -65,36 +65,36 @@ in { }; # proxmox virtual machines(x86_64) - aquamarine = colmenaSystem (libAttrs.mergeAttrsList [ + aquamarine = colmenaSystem (attrs.mergeAttrsList [ x64_base_args idol_aquamarine_modules {host_tags = idol_aquamarine_tags;} ]); - ruby = colmenaSystem (libAttrs.mergeAttrsList [ + ruby = colmenaSystem (attrs.mergeAttrsList [ x64_base_args idol_ruby_modules {host_tags = idol_ruby_tags;} ]); - kana = colmenaSystem (libAttrs.mergeAttrsList [ + kana = colmenaSystem (attrs.mergeAttrsList [ x64_base_args idol_kana_modules {host_tags = idol_kana_tags;} ]); # riscv64 SBCs - nozomi = colmenaSystem (libAttrs.mergeAttrsList [ + nozomi = colmenaSystem (attrs.mergeAttrsList [ lpi4a_base_args rolling_nozomi_modules {host_tags = rolling_nozomi_tags;} ]); - yukina = colmenaSystem (libAttrs.mergeAttrsList [ + yukina = colmenaSystem (attrs.mergeAttrsList [ lpi4a_base_args rolling_yukina_modules {host_tags = rolling_yukina_tags;} ]); # aarch64 SBCs - suzu = colmenaSystem (libAttrs.mergeAttrsList [ + suzu = colmenaSystem (attrs.mergeAttrsList [ rk3588_base_args _12kingdoms_suzu_modules {host_tags = _12kingdoms_suzu_tags;} diff --git a/systems/darwin.nix b/systems/darwin.nix index a26616f7..0bd44b77 100644 --- a/systems/darwin.nix +++ b/systems/darwin.nix @@ -1,7 +1,7 @@ args: with args; +with mylib; with allSystemAttrs; let - macosSystem = import ../lib/macosSystem.nix; base_args = { inherit nix-darwin home-manager; nixpkgs = nixpkgs-darwin; @@ -10,7 +10,7 @@ in { # macOS's configuration darwinConfigurations = { harmonica = macosSystem ( - libAttrs.mergeAttrsList [ + attrs.mergeAttrsList [ base_args darwin_harmonica_modules { @@ -21,7 +21,7 @@ in { ); fern = macosSystem ( - libAttrs.mergeAttrsList [ + attrs.mergeAttrsList [ base_args darwin_fern_modules { diff --git a/systems/default.nix b/systems/default.nix index 43dfce22..d937da33 100644 --- a/systems/default.nix +++ b/systems/default.nix @@ -4,13 +4,13 @@ constants, }: let inherit (inputs.nixpkgs) lib; - libAttrs = import ../lib/attrs.nix {inherit lib;}; + mylib = import ../lib { inherit lib; }; vars = import ./vars.nix; specialArgsForSystem = system: { inherit (constants) username userfullname useremail; - inherit libAttrs; + inherit mylib; # use unstable branch for some packages to get the latest updates pkgs-unstable = import inputs.nixpkgs-unstable { inherit system; # refer the `system` parameter form outer scope recursively @@ -21,18 +21,18 @@ // inputs; allSystemSpecialArgs = - libAttrs.mapAttrs + mylib.attrs.mapAttrs (_: specialArgsForSystem) constants.allSystemAttrs; - args = libAttrs.mergeAttrsList [ + args = mylib.attrs.mergeAttrsList [ inputs constants vars - {inherit self lib libAttrs allSystemSpecialArgs;} + {inherit self lib mylib allSystemSpecialArgs;} ]; in - libAttrs.mergeAttrsList [ + mylib.attrs.mergeAttrsList [ (import ./nixos.nix args) (import ./darwin.nix args) (import ./colmena.nix args) diff --git a/systems/nixos.nix b/systems/nixos.nix index 796dfdf0..ee34f67a 100644 --- a/systems/nixos.nix +++ b/systems/nixos.nix @@ -1,8 +1,7 @@ args: with args; +with mylib; with allSystemAttrs; let - nixosSystem = import ../lib/nixosSystem.nix; - base_args = { inherit home-manager nixos-generators; inherit nixpkgs; # or nixpkgs-unstable @@ -24,9 +23,9 @@ in { # take system images for idols # https://github.com/nix-community/nixos-generators - packages."${x64_system}" = libAttrs.mergeAttrsList [ + packages."${x64_system}" = attrs.mergeAttrsList [ ( - libAttrs.listToAttrs + attrs.listToAttrs [ "ai_i3" "ai_hyprland" @@ -36,7 +35,7 @@ in { ) ( - libAttrs.listToAttrs + attrs.listToAttrs [ "aquamarine" "ruby" diff --git a/systems/vars.nix b/systems/vars.nix index f6f46d65..52ee8acc 100644 --- a/systems/vars.nix +++ b/systems/vars.nix @@ -1,30 +1,30 @@ -{ +rec { # 星野 アイ, Hoshino Ai + __idol_ai_base_nixos_modules = [ + ../hosts/idols/ai + ../secrets/nixos.nix + ../modules/nixos/desktop.nix + ]; + __idol_ai_base_home_modules = [ + ../home/linux/desktop.nix + ]; + idol_ai_modules_i3 = { - nixos-modules = [ - ../hosts/idols/ai - ../secrets/nixos.nix - ../modules/nixos/xorg.nix - ]; - home-module = { - imports = [ - ../home/linux/desktop.nix - ../home/linux/i3 - ]; - }; + nixos-modules = + [{modules.desktop.xorg.enable = true;}] + ++ __idol_ai_base_nixos_modules; + home-module.imports = + [{modules.desktop.i3.enable = true;}] + ++ __idol_ai_base_home_modules; }; + idol_ai_modules_hyprland = { - nixos-modules = [ - ../hosts/idols/ai - ../secrets/nixos.nix - ../modules/nixos/wayland.nix - ]; - home-module = { - imports = [ - ../home/linux/desktop.nix - ../home/linux/hyprland - ]; - }; + nixos-modules = + [{modules.desktop.wayland.enable = true;}] + ++ __idol_ai_base_nixos_modules; + home-module.imports = + [{modules.desktop.hyprland.enable = true;}] + ++ __idol_ai_base_home_modules; }; # 星野 愛久愛海, Hoshino Akuamarin