From 6d6f665d061199137a6cfbefe166d973d5a3c009 Mon Sep 17 00:00:00 2001 From: Elisiei Yehorov Date: Sun, 16 Nov 2025 21:10:03 +0100 Subject: [PATCH] moved to sway <3 ty esteban --- flake.nix | 6 +- home/home.nix | 3 +- home/modules/{ => wm}/hyprland/default.nix | 0 home/modules/wm/sway/default.nix | 150 +++++++++++++++++++++ nixos/hardware-configuration.nix | 49 ++++--- nixos/modules/fonts.nix | 7 +- nixos/modules/networking.nix | 23 ---- nixos/modules/programs.nix | 13 +- nixos/modules/xserver.nix | 35 ++--- 9 files changed, 218 insertions(+), 68 deletions(-) rename home/modules/{ => wm}/hyprland/default.nix (100%) create mode 100644 home/modules/wm/sway/default.nix diff --git a/flake.nix b/flake.nix index 384c955..194bb32 100644 --- a/flake.nix +++ b/flake.nix @@ -2,15 +2,15 @@ description = "Modular and minimalist NixOS configuration"; inputs = { - # Nixos + # nixos nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable-small"; home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; - # Spotify + # spotify spicetify-nix.url = "github:Gerg-L/spicetify-nix"; - # Nvim + # nvim nixvim = { url = "github:nix-community/nixvim"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/home/home.nix b/home/home.nix index cec255f..5cf39bf 100644 --- a/home/home.nix +++ b/home/home.nix @@ -3,7 +3,8 @@ ./packages.nix # hyprland - ./modules/hyprland/default.nix + # ./modules/hyprland/default.nix + ./modules/wm/sway/default.nix # editors ./modules/ide/nvim/default.nix diff --git a/home/modules/hyprland/default.nix b/home/modules/wm/hyprland/default.nix similarity index 100% rename from home/modules/hyprland/default.nix rename to home/modules/wm/hyprland/default.nix diff --git a/home/modules/wm/sway/default.nix b/home/modules/wm/sway/default.nix new file mode 100644 index 0000000..5ecb4d1 --- /dev/null +++ b/home/modules/wm/sway/default.nix @@ -0,0 +1,150 @@ +{ + config, + pkgs, + lib, + ... +}: +let + wallpaperScript = pkgs.writeShellScriptBin "random-wallpaper" '' + WALP=$(find "$HOME/wallpapers" -type f \( -iname "*.jpg" -o -iname "*.png" \) | shuf -n 1) + [ -n "$WALP" ] && ${pkgs.swaybg}/bin/swaybg -i "$WALP" --mode fill & + ''; +in +{ + home.packages = [ + wallpaperScript + ]; + + wayland.windowManager.sway = { + enable = true; + xwayland = true; + + config = rec { + modifier = "Mod4"; + terminal = "foot"; + menu = "exec $(tofi-drun)"; + + # monitor configuration + output = { + "*" = { + resolution = "1920x1080"; + scale = "1"; + }; + }; + + # startup commands + startup = [ + { command = "${wallpaperScript}/bin/random-wallpaper"; } + ]; + + # input configuration + input = { + "type:keyboard" = { + xkb_layout = "es,ru"; + xkb_options = "grp:alt_space_toggle"; + xkb_numlock = "enabled"; + }; + }; + + # window appearance + gaps = { + inner = 0; + outer = 0; + }; + + window = { + border = 0; + }; + + floating = { + border = 0; + }; + + # focus settings + focus = { + followMouse = true; + }; + + # keybindings + keybindings = lib.mkOptionDefault { + # screenshots + "${modifier}+Shift+Print" = "exec ~/bin/grimblast copy screen"; + "${modifier}+Print" = "exec ~/bin/grimblast copy area"; + + # application launchers + "${modifier}+space" = "exec ${menu}"; + "${modifier}+w" = "exec ${wallpaperScript}/bin/random-wallpaper"; + "${modifier}+s" = "sticky toggle"; + "${modifier}+t" = "exec ${terminal}"; + "${modifier}+z" = "exec librewolf"; + + # Window management + "${modifier}+q" = "kill"; + "${modifier}+Shift+m" = "exit"; + "${modifier}+v" = "floating toggle"; + + # focus movement + "${modifier}+Left" = "focus left"; + "${modifier}+Right" = "focus right"; + "${modifier}+Up" = "focus up"; + "${modifier}+Down" = "focus down"; + + # workspace switching + "${modifier}+1" = "workspace number 1"; + "${modifier}+2" = "workspace number 2"; + "${modifier}+3" = "workspace number 3"; + "${modifier}+4" = "workspace number 4"; + "${modifier}+5" = "workspace number 5"; + "${modifier}+6" = "workspace number 6"; + "${modifier}+7" = "workspace number 7"; + "${modifier}+8" = "workspace number 8"; + "${modifier}+9" = "workspace number 9"; + "${modifier}+0" = "workspace number 10"; + + # move to workspace + "${modifier}+Shift+1" = "move container to workspace number 1"; + "${modifier}+Shift+2" = "move container to workspace number 2"; + "${modifier}+Shift+3" = "move container to workspace number 3"; + "${modifier}+Shift+4" = "move container to workspace number 4"; + "${modifier}+Shift+5" = "move container to workspace number 5"; + "${modifier}+Shift+6" = "move container to workspace number 6"; + "${modifier}+Shift+7" = "move container to workspace number 7"; + "${modifier}+Shift+8" = "move container to workspace number 8"; + "${modifier}+Shift+9" = "move container to workspace number 9"; + "${modifier}+Shift+0" = "move container to workspace number 10"; + }; + + # mouse bindings for moving/resizing windows + modes = { + resize = { + Left = "resize shrink width 10 px"; + Right = "resize grow width 10 px"; + Up = "resize shrink height 10 px"; + Down = "resize grow height 10 px"; + Escape = "mode default"; + Return = "mode default"; + }; + }; + + bars = [ ]; + }; + + extraConfig = '' + # window borders + default_border pixel 0 + default_floating_border pixel 0 + + # mouse bindings + floating_modifier ${config.wayland.windowManager.sway.config.modifier} normal + + # cursor theme + seat seat0 xcursor_theme macOS 24 + ''; + }; + + # environment variables + home.sessionVariables = { + XCURSOR_THEME = "macOS"; + XCURSOR_SIZE = "24"; + }; +} diff --git a/nixos/hardware-configuration.nix b/nixos/hardware-configuration.nix index 168b86b..290fe4b 100644 --- a/nixos/hardware-configuration.nix +++ b/nixos/hardware-configuration.nix @@ -1,32 +1,47 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: +{ + config, + lib, + pkgs, + modulesPath, + ... +}: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; - boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" ]; + boot.initrd.availableKernelModules = [ + "xhci_pci" + "ahci" + "nvme" + "usb_storage" + "sd_mod" + ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/90ae88e4-a293-4e43-94ff-311f194d84d6"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/90ae88e4-a293-4e43-94ff-311f194d84d6"; + fsType = "ext4"; + }; - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/AF0B-79BE"; - fsType = "vfat"; - options = [ "fmask=0077" "dmask=0077" ]; - }; - - swapDevices = - [ { device = "/dev/disk/by-uuid/9553ce42-c192-47b4-8d3d-c4d3e9dc0f74"; } + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/4E27-4F9D"; + fsType = "vfat"; + options = [ + "fmask=0077" + "dmask=0077" ]; + }; + + swapDevices = [ + { device = "/dev/disk/by-uuid/9553ce42-c192-47b4-8d3d-c4d3e9dc0f74"; } + ]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's diff --git a/nixos/modules/fonts.nix b/nixos/modules/fonts.nix index 9c8da58..edc37fb 100644 --- a/nixos/modules/fonts.nix +++ b/nixos/modules/fonts.nix @@ -9,10 +9,11 @@ nerd-fonts.jetbrains-mono maple-mono.NF ]; + fontconfig.defaultFonts = { - serif = [ "Noto Nerd Font" ]; - sansSerif = [ "Noto Nerd Font" ]; - monospace = [ "Noto Nerd Font" ]; + serif = [ "Maple Mono NF" ]; + sansSerif = [ "Maple Mono NF" ]; + monospace = [ "Maple Mono NF" ]; }; }; } diff --git a/nixos/modules/networking.nix b/nixos/modules/networking.nix index 8b25da9..845d215 100644 --- a/nixos/modules/networking.nix +++ b/nixos/modules/networking.nix @@ -1,29 +1,6 @@ { networking.hostName = "nixos"; networking.networkmanager.enable = true; - - services.blueman.enable = true; - hardware.bluetooth = { - enable = true; - powerOnBoot = true; - settings = { - General = { - # Shows battery charge of connected devices on supported - # Bluetooth adapters. Defaults to 'false'. - Experimental = true; - # When enabled other devices can connect faster to us, however - # the tradeoff is increased power consumption. Defaults to - # 'false'. - FastConnectable = true; - }; - Policy = { - # Enable all controllers when they are found. This includes - # adapters present on start as well as adapters that are plugged - # in later on. Defaults to 'true'. - AutoEnable = true; - }; - }; - }; # Configure network proxy if necessary # networking.proxy.default = "http://user:password@proxy:port/"; # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; diff --git a/nixos/modules/programs.nix b/nixos/modules/programs.nix index 4a23ada..02d9647 100644 --- a/nixos/modules/programs.nix +++ b/nixos/modules/programs.nix @@ -4,17 +4,18 @@ let spicePkgs = inputs.spicetify-nix.legacyPackages.${pkgs.system}; in { - programs.hyprland = { - enable = true; - withUWSM = true; - xwayland.enable = true; - }; - environment.sessionVariables = { WLR_NO_HARDWARE_CURSORS = "1"; NIXOS_OZONE_WL = "1"; }; + security.polkit.enable = true; + + programs.sway = { + enable = true; + wrapperFeatures.gtk = true; + }; + environment.systemPackages = with pkgs; [ # essential curl diff --git a/nixos/modules/xserver.nix b/nixos/modules/xserver.nix index 8459bd3..ab7205d 100644 --- a/nixos/modules/xserver.nix +++ b/nixos/modules/xserver.nix @@ -1,4 +1,4 @@ -{ config, ... }: +{ config, pkgs, ... }: { services.xserver.enable = true; services.xserver.videoDrivers = [ "nvidia" ]; @@ -20,23 +20,28 @@ }; services.xserver.xkb = { - layout = "es"; + layout = "es,ru"; variant = ""; }; + services.greetd = { + enable = true; + settings = rec { + initial_session = { + command = "${pkgs.sway}/bin/sway --unsupported-gpu"; + user = "elisiei"; + }; + default_session = initial_session; + }; + }; + console.keyMap = "es"; - services.displayManager.sddm.enable = true; - services.displayManager.defaultSession = "hyprland-uwsm"; - services.displayManager.autoLogin.enable = true; - services.displayManager.autoLogin.user = "elisiei"; - services.displayManager.sddm.wayland.enable = true; - - environment.etc."xdg/sessions/hyprland.desktop".text = '' - [Desktop Entry] - Name=Hyprland - Comment=Hyprland Wayland Compositor - Exec=Hyprland - Type=Application - ''; + #environment.etc."xdg/sessions/hyprland.desktop".text = '' + # [Desktop Entry] + # Name=Hyprland + # Comment=Hyprland Wayland Compositor + # Exec=Hyprland + # Type=Application + #''; }