From c5a62858b7d794a8975aaae13a3171e51dbb0e6b Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Tue, 14 Jan 2025 17:35:06 +0800 Subject: [PATCH] add gdm as dm for niri. --- nixos/modules/default.nix | 2 +- nixos/modules/gui.nix | 103 ---------------------------------- nixos/modules/gui/cosmic.nix | 26 +++++++++ nixos/modules/gui/default.nix | 77 +++++++++++++++++++++++++ nixos/modules/gui/niri.nix | 34 +++++++++++ 5 files changed, 138 insertions(+), 104 deletions(-) delete mode 100644 nixos/modules/gui.nix create mode 100644 nixos/modules/gui/cosmic.nix create mode 100644 nixos/modules/gui/default.nix create mode 100644 nixos/modules/gui/niri.nix diff --git a/nixos/modules/default.nix b/nixos/modules/default.nix index b1763c2..b348009 100644 --- a/nixos/modules/default.nix +++ b/nixos/modules/default.nix @@ -21,7 +21,7 @@ ./openssh.nix ./nh.nix ./i18n.nix - ./gui.nix + ./gui ./steam.nix ]; diff --git a/nixos/modules/gui.nix b/nixos/modules/gui.nix deleted file mode 100644 index ce97af9..0000000 --- a/nixos/modules/gui.nix +++ /dev/null @@ -1,103 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: -let - cfg = config.youthlic.gui; -in -{ - options = { - youthlic.gui = { - enabled = lib.mkOption { - type = lib.types.nullOr ( - lib.types.enum [ - "cosmic" - "niri" - ] - ); - default = null; - example = "cosmic"; - }; - }; - }; - config = lib.mkMerge [ - (lib.mkIf (cfg.enabled == "cosmic") { - # Enable the X11 windowing system. - # You can disable this if you're only using the Wayland session. - services.xserver = { - display = 0; - enable = true; - xkb = { - layout = "cn"; - variant = ""; - }; - }; - - services.desktopManager.cosmic.enable = true; - services.displayManager.cosmic-greeter.enable = true; - }) - (lib.mkIf (cfg.enabled == "niri") { - services.displayManager.sddm = { - enable = true; - wayland = { - enable = true; - compositorCommand = "niri"; - }; - }; - programs.niri = { - enable = true; - package = pkgs.niri-unstable; - }; - }) - (lib.mkIf (cfg.enabled != null) { - environment.systemPackages = with pkgs; [ - fontconfig - ]; - programs.firefox.enable = true; - - fonts = { - enableDefaultPackages = false; - packages = with pkgs; [ - nerd-fonts.fira-code - noto-fonts - noto-fonts-cjk-sans - noto-fonts-cjk-serif - noto-fonts-emoji - lxgw-wenkai - ]; - fontconfig.defaultFonts = pkgs.lib.mkForce { - serif = [ - "LXGW WenKai" - "Noto Serif CJK SC" - "Noto Serif" - ]; - sansSerif = [ - "Noto Serif CJK SC" - "Noto Serif" - ]; - monospace = [ - "FiraCode Nerd Font" - ]; - emoji = [ "Noto Color Emoji" ]; - }; - }; - - services.pulseaudio.enable = false; - security.rtkit.enable = true; - 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; - }; - }) - ]; -} diff --git a/nixos/modules/gui/cosmic.nix b/nixos/modules/gui/cosmic.nix new file mode 100644 index 0000000..ef4d0b7 --- /dev/null +++ b/nixos/modules/gui/cosmic.nix @@ -0,0 +1,26 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.youthlic.gui; +in +{ + config = lib.mkIf (cfg.enabled == "cosmic") { + # Enable the X11 windowing system. + # You can disable this if you're only using the Wayland session. + services.xserver = { + display = 0; + enable = true; + xkb = { + layout = "cn"; + variant = ""; + }; + }; + + services.desktopManager.cosmic.enable = true; + services.displayManager.cosmic-greeter.enable = true; + }; +} diff --git a/nixos/modules/gui/default.nix b/nixos/modules/gui/default.nix new file mode 100644 index 0000000..c4f11df --- /dev/null +++ b/nixos/modules/gui/default.nix @@ -0,0 +1,77 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.youthlic.gui; +in +{ + imports = [ + ./niri.nix + ./cosmic.nix + ]; + options = { + youthlic.gui = { + enabled = lib.mkOption { + type = lib.types.nullOr ( + lib.types.enum [ + "cosmic" + "niri" + ] + ); + default = null; + example = "cosmic"; + }; + }; + }; + config = lib.mkIf (cfg.enabled != null) { + environment.systemPackages = with pkgs; [ + fontconfig + ]; + programs.firefox.enable = true; + + fonts = { + enableDefaultPackages = false; + packages = with pkgs; [ + nerd-fonts.fira-code + noto-fonts + noto-fonts-cjk-sans + noto-fonts-cjk-serif + noto-fonts-emoji + lxgw-wenkai + ]; + fontconfig.defaultFonts = pkgs.lib.mkForce { + serif = [ + "LXGW WenKai" + "Noto Serif CJK SC" + "Noto Serif" + ]; + sansSerif = [ + "Noto Serif CJK SC" + "Noto Serif" + ]; + monospace = [ + "FiraCode Nerd Font" + ]; + emoji = [ "Noto Color Emoji" ]; + }; + }; + + services.pulseaudio.enable = false; + security.rtkit.enable = true; + 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; + }; + }; +} diff --git a/nixos/modules/gui/niri.nix b/nixos/modules/gui/niri.nix new file mode 100644 index 0000000..3c3de9b --- /dev/null +++ b/nixos/modules/gui/niri.nix @@ -0,0 +1,34 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.youthlic.gui; +in +{ + config = lib.mkIf (cfg.enabled == "niri") { + environment.systemPackages = with pkgs; [ + bluez + ]; + hardware.bluetooth = { + enable = true; + }; + services.xserver = { + enable = true; + xkb = { + layout = "cn"; + variant = ""; + }; + displayManager.gdm = { + enable = true; + wayland = true; + }; + }; + programs.niri = { + enable = true; + package = pkgs.niri-unstable; + }; + }; +}