diff --git a/flake.nix b/flake.nix index b01fb6f6..670f9c0b 100644 --- a/flake.nix +++ b/flake.nix @@ -276,6 +276,7 @@ "https://mirrors.ustc.edu.cn/nix-channels/store" "https://cache.nixos.org" "https://anyrun.cachix.org" + "https://hyprland.cachix.org" ]; # nix community's cache server @@ -288,6 +289,7 @@ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA=" "anyrun.cachix.org-1:pqBobmOjI7nKlsUMV25u9QHa9btJK65/C8vnO3p346s=" + "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" ]; }; } diff --git a/home/linux/hyprland/default.nix b/home/linux/hyprland/default.nix index eadfba7d..28e692a9 100644 --- a/home/linux/hyprland/default.nix +++ b/home/linux/hyprland/default.nix @@ -1,13 +1,12 @@ -{pkgs, catppuccin-hyprland, ...}: { +{pkgs, hyprland, catppuccin-hyprland, ...}: { imports = [ + hyprland.homeManagerModules.default + ./anyrun.nix ./wayland-apps.nix ]; - # Only available on home-manager's master branch(2023/7/25) - # wayland.windowManager.hyprland = { - # enable = true; - # }; + wayland.windowManager.hyprland.enable = true; # hyprland configs, based on https://github.com/notwidow/hyprland home.file.".config/hypr" = { diff --git a/modules/nixos/core-desktop.nix b/modules/nixos/core-desktop.nix index e1c9765c..7bc8fa95 100644 --- a/modules/nixos/core-desktop.nix +++ b/modules/nixos/core-desktop.nix @@ -16,8 +16,151 @@ # to install chrome, you need to enable unfree packages nixpkgs.config.allowUnfree = lib.mkForce true; - # Enable CUPS to print documents. - services.printing.enable = true; + # add user's shell into /etc/shells + environment.shells = with pkgs; [ + bash + nushell + ]; + # set user's default shell system-wide + users.defaultUserShell = pkgs.nushell; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + # python, some times I may need to use python with root permission. + (python310.withPackages (ps: + with ps; [ + ipython + pandas + requests + pyquery + pyyaml + ] + )) + psmisc # killall/pstree/prtstat/fuser/... + ]; + + programs = { + # android development tools, this will install adb/fastboot and other android tools and udev rules + # see https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/programs/adb.nix + adb.enable = true; + # The OpenSSH agent remembers private keys for you + # so that you don’t have to type in passphrases every time you make an SSH connection. + # Use `ssh-add` to add a key to the agent. + ssh.startAgent = true; + # dconf is a low-level configuration system. + dconf.enable = true; + }; + + # A key remapping daemon for linux. + # https://github.com/rvaiya/keyd + services.keyd = { + enable = true; + settings = { + main = { + # overloads the capslock key to function as both escape (when tapped) and control (when held) + capslock = "overload(control, esc)"; + }; + }; + }; + + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + networking.firewall.enable = false; + + # Enable the OpenSSH daemon. + services.openssh = { + enable = true; + settings = { + X11Forwarding = true; + PermitRootLogin = "no"; # disable root login + PasswordAuthentication = false; # disable password login + }; + openFirewall = true; + }; + + # PipeWire is a new low-level multimedia framework. + # It aims to offer capture and playback for both audio and video with minimal latency. + # It support for PulseAudio-, JACK-, ALSA- and GStreamer-based applications. + # PipeWire has a great bluetooth support, it can be a good alternative to PulseAudio. + # https://nixos.wiki/wiki/PipeWire + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + # jack.enable = true; + + # use the example session manager (no others are packaged yet so this is enabled by default, + # no need to redefine it in your config for now) + #media-session.enable = true; + }; + # rtkit is optional but recommended + security.rtkit.enable = true; + # Remove sound.enable or turn it off if you had it set previously, it seems to cause conflicts with pipewire + sound.enable = false; + # Disable pulseaudio, it conflicts with pipewire too. + hardware.pulseaudio.enable = false; + + # enable bluetooth & gui paring tools - blueman + # or you can use cli: + # $ bluetoothctl + # [bluetooth] # power on + # [bluetooth] # agent on + # [bluetooth] # default-agent + # [bluetooth] # scan on + # ...put device in pairing mode and wait [hex-address] to appear here... + # [bluetooth] # pair [hex-address] + # [bluetooth] # connect [hex-address] + # Bluetooth devices automatically connect with bluetoothctl as well: + # [bluetooth] # trust [hex-address] + hardware.bluetooth.enable = true; + services.blueman.enable = true; + + # security with polkit + services.power-profiles-daemon = { + enable = true; + }; + security.polkit.enable = true; + # security with gnome-kering + services.gnome.gnome-keyring.enable = true; + security.pam.services.greetd.enableGnomeKeyring = true; + + services = { + # Enable CUPS to print documents. + printing.enable = true; + + # https://flatpak.org/setup/NixOS + flatpak.enable = true; + + dbus.packages = [pkgs.gcr]; + geoclue2.enable = true; + + udev.packages = with pkgs; [ + gnome.gnome-settings-daemon + platformio # udev rules for platformio + openocd # required by paltformio, see https://github.com/NixOS/nixpkgs/issues/224895 + android-udev-rules + ]; + }; + + + xdg.portal = { + enable = true; + # Sets environment variable NIXOS_XDG_OPEN_USE_PORTAL to 1 + # This will make xdg-open use the portal to open programs, + # which resolves bugs involving programs opening inside FHS envs or with unexpected env vars set from wrappers. + # xdg-open is used by almost all programs to open a unknown file/uri + # alacritty as an example, it use xdg-open as default, but you can also custom this behavior + # and vscode has open like `External Uri Openers` + xdgOpenUsePortal = false; + extraPortals = with pkgs; [ + xdg-desktop-portal-gtk # for gtk + # xdg-desktop-portal-kde # for kde + ]; + }; # all fonts are linked to /nix/var/nix/profiles/system/sw/share/X11/fonts fonts = { @@ -66,149 +209,4 @@ emoji = ["Noto Color Emoji"]; }; }; - - # dconf is a low-level configuration system. - programs.dconf.enable = true; - - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - networking.firewall.enable = false; - - # Enable the OpenSSH daemon. - services.openssh = { - enable = true; - settings = { - X11Forwarding = true; - PermitRootLogin = "no"; # disable root login - PasswordAuthentication = false; # disable password login - }; - openFirewall = true; - }; - - # The OpenSSH agent remembers private keys for you - # so that you don’t have to type in passphrases every time you make an SSH connection. - # Use `ssh-add` to add a key to the agent. - programs.ssh.startAgent = true; - - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - # python, some times I may need to use python with root permission. - (python310.withPackages (ps: - with ps; [ - ipython - pandas - requests - pyquery - pyyaml - ] - )) - psmisc # killall/pstree/prtstat/fuser/... - ]; - - # PipeWire is a new low-level multimedia framework. - # It aims to offer capture and playback for both audio and video with minimal latency. - # It support for PulseAudio-, JACK-, ALSA- and GStreamer-based applications. - # PipeWire has a great bluetooth support, it can be a good alternative to PulseAudio. - # https://nixos.wiki/wiki/PipeWire - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - # If you want to use JACK applications, uncomment this - # jack.enable = true; - - # use the example session manager (no others are packaged yet so this is enabled by default, - # no need to redefine it in your config for now) - #media-session.enable = true; - }; - # rtkit is optional but recommended - security.rtkit.enable = true; - # Remove sound.enable or turn it off if you had it set previously, it seems to cause conflicts with pipewire - sound.enable = false; - # Disable pulseaudio, it conflicts with pipewire too. - hardware.pulseaudio.enable = false; - - # enable bluetooth & gui paring tools - blueman - # or you can use cli: - # $ bluetoothctl - # [bluetooth] # power on - # [bluetooth] # agent on - # [bluetooth] # default-agent - # [bluetooth] # scan on - # ...put device in pairing mode and wait [hex-address] to appear here... - # [bluetooth] # pair [hex-address] - # [bluetooth] # connect [hex-address] - # Bluetooth devices automatically connect with bluetoothctl as well: - # [bluetooth] # trust [hex-address] - hardware.bluetooth.enable = true; - services.blueman.enable = true; - - # https://flatpak.org/setup/NixOS - services.flatpak.enable = true; - - # security with polkit - services.power-profiles-daemon = { - enable = true; - }; - security.polkit.enable = true; - # security with gnome-kering - services.gnome.gnome-keyring.enable = true; - security.pam.services.greetd.enableGnomeKeyring = true; - - # A key remapping daemon for linux. - # https://github.com/rvaiya/keyd - services.keyd = { - enable = true; - settings = { - main = { - # overloads the capslock key to function as both escape (when tapped) and control (when held) - capslock = "overload(control, esc)"; - }; - }; - }; - - services = { - dbus.packages = [pkgs.gcr]; - - geoclue2.enable = true; - - udev.packages = with pkgs; [ - gnome.gnome-settings-daemon - platformio # udev rules for platformio - openocd # required by paltformio, see https://github.com/NixOS/nixpkgs/issues/224895 - android-udev-rules - ]; - }; - - # android development tools, this will install adb/fastboot and other android tools and udev rules - # see https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/programs/adb.nix - programs.adb.enable = true; - - xdg.portal = { - enable = true; - wlr.enable = true; - # Sets environment variable NIXOS_XDG_OPEN_USE_PORTAL to 1 - # This will make xdg-open use the portal to open programs, - # which resolves bugs involving programs opening inside FHS envs or with unexpected env vars set from wrappers. - # xdg-open is used by almost all programs to open a unknown file/uri - # alacritty as an example, it use xdg-open as default, but you can also custom this behavior - # and vscode has open like `External Uri Openers` - xdgOpenUsePortal = false; - extraPortals = with pkgs; [ - xdg-desktop-portal-wlr # for wlroots based compositors(hyprland/sway) - xdg-desktop-portal-gtk # for gtk - # xdg-desktop-portal-kde # for kde - ]; - }; - - # add user's shell into /etc/shells - environment.shells = with pkgs; [ - bash - nushell - ]; - # set user's default shell system-wide - users.defaultUserShell = pkgs.nushell; } diff --git a/modules/nixos/core-server.nix b/modules/nixos/core-server.nix index 3368152b..5658871a 100644 --- a/modules/nixos/core-server.nix +++ b/modules/nixos/core-server.nix @@ -62,6 +62,13 @@ }; openFirewall = true; }; + # for power management + services = { + power-profiles-daemon = { + enable = true; + }; + upower.enable = true; + }; # List packages installed in system profile. To search, run: # $ nix search wget @@ -95,10 +102,4 @@ virtualisation.docker = { enable = true; }; - - # for power management - services.power-profiles-daemon = { - enable = true; - }; - services.upower.enable = true; } diff --git a/modules/nixos/hyprland.nix b/modules/nixos/hyprland.nix index 3f517acf..8f2d9782 100644 --- a/modules/nixos/hyprland.nix +++ b/modules/nixos/hyprland.nix @@ -1,4 +1,4 @@ -{pkgs, ...}: { +{pkgs, hyprland, ...}: { ########################################################################################################## # # NixOS's Configuration for Hyprland Window Manager @@ -9,43 +9,53 @@ # ########################################################################################################## + imports = [ + hyprland.nixosModules.default + ]; + environment.pathsToLink = ["/libexec"]; # links /libexec from derivations to /run/current-system/sw - services.xserver = { - enable = true; + services = { + gvfs.enable = true; # Mount, trash, and other functionalities + tumbler.enable = true; # Thumbnail support for images + xserver = { + enable = true; - desktopManager = { - xterm.enable = false; - }; + desktopManager = { + xterm.enable = false; + }; - displayManager = { - defaultSession = "hyprland"; - lightdm.enable = false; - gdm = { - enable = true; - wayland = true; + displayManager = { + defaultSession = "hyprland"; + lightdm.enable = false; + gdm = { + enable = true; + wayland = true; + }; }; }; }; - programs.hyprland = { - enable = true; - - xwayland = { + programs = { + hyprland = { enable = true; - hidpi = true; + + xwayland = { + enable = true; + hidpi = true; + }; + + nvidiaPatches = true; }; - nvidiaPatches = true; - }; - programs.light.enable = true; # monitor backlight control + # monitor backlight control + light.enable = true; - # thunar file manager(part of xfce) related options - programs.thunar.plugins = with pkgs.xfce; [ - thunar-archive-plugin - thunar-volman - ]; - services.gvfs.enable = true; # Mount, trash, and other functionalities - services.tumbler.enable = true; # Thumbnail support for images + # thunar file manager(part of xfce) related options + thunar.plugins = with pkgs.xfce; [ + thunar-archive-plugin + thunar-volman + ]; + }; # List packages installed in system profile. To search, run: # $ nix search wget diff --git a/modules/nixos/i3.nix b/modules/nixos/i3.nix index 577c2e51..ee6f71eb 100644 --- a/modules/nixos/i3.nix +++ b/modules/nixos/i3.nix @@ -7,48 +7,52 @@ # i3 related options environment.pathsToLink = ["/libexec"]; # links /libexec from derivations to /run/current-system/sw - services.xserver = { - enable = true; - - desktopManager = { - xterm.enable = false; - }; - - displayManager = { - defaultSession = "none+i3"; - lightdm.enable = false; - gdm.enable = true; - }; - - windowManager.i3 = { + services = { + gvfs.enable = true; # Mount, trash, and other functionalities + tumbler.enable = true; # Thumbnail support for images + xserver = { enable = true; - extraPackages = with pkgs; [ - rofi # application launcher, the same as dmenu - dunst # notification daemon - i3blocks # status bar - i3lock # default i3 screen locker - xautolock # lock screen after some time - i3status # provide information to i3bar - i3-gaps # i3 with gaps - picom # transparency and shadows - feh # set wallpaper - acpi # battery information - arandr # screen layout manager - dex # autostart applications - xbindkeys # bind keys to commands - xorg.xbacklight # control screen brightness, the same as light - xorg.xdpyinfo # get screen information - scrot # minimal screen capture tool, used by i3 blur lock to take a screenshot - sysstat # get system information - alsa-utils # provides amixer/alsamixer/... - xfce.thunar # xfce4's file manager - ]; + desktopManager = { + xterm.enable = false; + }; + + displayManager = { + defaultSession = "none+i3"; + lightdm.enable = false; + gdm.enable = true; + }; + + windowManager.i3 = { + enable = true; + extraPackages = with pkgs; [ + rofi # application launcher, the same as dmenu + dunst # notification daemon + i3blocks # status bar + i3lock # default i3 screen locker + xautolock # lock screen after some time + i3status # provide information to i3bar + i3-gaps # i3 with gaps + picom # transparency and shadows + feh # set wallpaper + acpi # battery information + arandr # screen layout manager + dex # autostart applications + xbindkeys # bind keys to commands + xorg.xbacklight # control screen brightness, the same as light + xorg.xdpyinfo # get screen information + scrot # minimal screen capture tool, used by i3 blur lock to take a screenshot + sysstat # get system information + alsa-utils # provides amixer/alsamixer/... + + xfce.thunar # xfce4's file manager + ]; + }; + + # Configure keymap in X11 + layout = "us"; + xkbVariant = ""; }; - - # Configure keymap in X11 - layout = "us"; - xkbVariant = ""; }; # thunar file manager(part of xfce) related options @@ -56,6 +60,4 @@ thunar-archive-plugin thunar-volman ]; - services.gvfs.enable = true; # Mount, trash, and other functionalities - services.tumbler.enable = true; # Thumbnail support for images }