From a5c9298cda617ae5b173a6e43a616dab103d6bcc Mon Sep 17 00:00:00 2001 From: zuma Date: Thu, 6 Feb 2025 15:18:02 +0100 Subject: [PATCH] Add Hyprland as a WM --- commons/home-manager/hyprland.nix | 121 +++++ flake.lock | 428 +++++++++++++++++- flake.nix | 17 +- .../t0urn3s0l/configuration.nix | 42 +- .../t0urn3s0l/hardware-configuration.nix | 0 home.nix => hosts/t0urn3s0l/home.nix | 6 +- 6 files changed, 595 insertions(+), 19 deletions(-) create mode 100644 commons/home-manager/hyprland.nix rename configuration.nix => hosts/t0urn3s0l/configuration.nix (77%) rename hardware-configuration.nix => hosts/t0urn3s0l/hardware-configuration.nix (100%) rename home.nix => hosts/t0urn3s0l/home.nix (96%) diff --git a/commons/home-manager/hyprland.nix b/commons/home-manager/hyprland.nix new file mode 100644 index 0000000..1f11564 --- /dev/null +++ b/commons/home-manager/hyprland.nix @@ -0,0 +1,121 @@ +{ ... }: { + wayland.windowManager.hyprland = { + enable = true; + + + settings = { + "$mod" = "SUPER"; # Windows key on classic keyboards + + monitor = [ + "eDP-1, 1920x1080, 1440x0,1" + "HDMI-A-1,1440x900, 0x0, 1" + ]; + + bind = [ + # Programs + "$mod, B, exec, firefox" + "$mod, code:36, exec, kitty" + "$mod, Q, killactive," + "$mod, E, exec, thunar" + "$mod, F, fullscreen, 1" + "$mod SHIFT, F, fullscreen" + + # Move to workspace + "$mod, code:10, workspace, 1" + "$mod, code:11, workspace, 2" + "$mod, code:12, workspace, 3" + "$mod, code:13, workspace, 4" + "$mod, code:14, workspace, 5" + "$mod, code:15, workspace, 6" + "$mod, code:16, workspace, 7" + "$mod, code:17, workspace, 8" + "$mod, code:18, workspace, 9" + + # Move active window to workspace + "$mod SHIFT, code:10, movetoworkspace, 1" + "$mod SHIFT, code:11, movetoworkspace, 2" + "$mod SHIFT, code:12, movetoworkspace, 3" + "$mod SHIFT, code:13, movetoworkspace, 4" + "$mod SHIFT, code:14, movetoworkspace, 5" + "$mod SHIFT, code:15, movetoworkspace, 6" + "$mod SHIFT, code:16, movetoworkspace, 7" + "$mod SHIFT, code:17, movetoworkspace, 8" + "$mod SHIFT, code:18, movetoworkspace, 9" + ]; + + bindm = [ + "$mod, mouse:272, moveWindow" + "$mod, mouse:273, moveWindow" + ]; + + cursor = { + no_hardware_cursors = true; + }; + + input = { + kb_layout = "fr, us"; + kb_variant = ",altgr-intl"; # Specify international variant for qwerty so I can type french accents + kb_options = "grp:lctrl_lwin_toggle"; # Toggle keyboard variants with LCTRL + LWIN + follow_mouse = 1; + + touchpad = { + natural_scroll = "yes"; + }; + }; + + general = { + # Default Hyprland UI + gaps_in = 5; + gaps_out = 10; + border_size = 1; + "col.active_border" = "rgba(33ccffee) rgba(00ff99ee) 45deg"; + "col.inactive_border" = "rgba(595959aa)"; + + layout = "dwindle"; + + resize_on_border = true; + }; + + decoration = { + rounding = 10; + + blur = { + enabled = true; + size = 3; + passes = 1; + }; + + shadow = { + enabled = true; + color = "rgba(1a1a1aee)"; + }; + }; + + animations = { + enabled = "yes"; + bezier = "myBezier, 0.05, 0.9, 0.1, 1.05"; + animation = [ + "windows, 1, 7, myBezier" + "windowsOut, 1, 7, default, popin 80%" + "border, 1, 10, default" + "borderangle, 1, 8, default" + "fade, 1, 7, default" + "workspaces, 1, 6, default" + ]; + }; + + dwindle = { + pseudotile = "yes"; + preserve_split = "yes"; + }; + + master = { + new_status = "master"; + }; + + gestures = { + workspace_swipe = "on"; + }; + }; + }; +} diff --git a/flake.lock b/flake.lock index edf1651..8a6b8a5 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,76 @@ { "nodes": { + "aquamarine": { + "inputs": { + "hyprutils": [ + "hyprland", + "hyprutils" + ], + "hyprwayland-scanner": [ + "hyprland", + "hyprwayland-scanner" + ], + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1738456976, + "narHash": "sha256-cufyHbOMnSt9V4w4OVSzNcpJ+8DwzRZRJaca2Q89KVI=", + "owner": "hyprwm", + "repo": "aquamarine", + "rev": "257b2050790ab3b1eb389e0f8bdc400eb9510139", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "aquamarine", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "hyprland", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -20,7 +91,282 @@ "type": "github" } }, + "hyprcursor": { + "inputs": { + "hyprlang": [ + "hyprland", + "hyprlang" + ], + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1738178255, + "narHash": "sha256-+D6Nu2ewXbMTFzx/Q4jDOo+LAOUPr0cxQJg5k33daIE=", + "owner": "hyprwm", + "repo": "hyprcursor", + "rev": "dcadd3398abe146d60c67e0d9ee6e27b301cae82", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprcursor", + "type": "github" + } + }, + "hyprgraphics": { + "inputs": { + "hyprutils": [ + "hyprland", + "hyprutils" + ], + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1738437059, + "narHash": "sha256-J+8ecqaP3zD9GHeN8Y4hUapoELSoggp0IZI8laTFt/0=", + "owner": "hyprwm", + "repo": "hyprgraphics", + "rev": "5ac80e3686a4dfa55d2bd15c81a266b89594a295", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprgraphics", + "type": "github" + } + }, + "hyprland": { + "inputs": { + "aquamarine": "aquamarine", + "hyprcursor": "hyprcursor", + "hyprgraphics": "hyprgraphics", + "hyprland-protocols": "hyprland-protocols", + "hyprland-qtutils": "hyprland-qtutils", + "hyprlang": "hyprlang", + "hyprutils": "hyprutils", + "hyprwayland-scanner": "hyprwayland-scanner", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks", + "systems": "systems", + "xdph": "xdph" + }, + "locked": { + "lastModified": 1738840864, + "narHash": "sha256-tMPkXvAPIbJp8UhuAQ9ONSDFj3yYbP5gZWK2Sv7JWCI=", + "owner": "hyprwm", + "repo": "Hyprland", + "rev": "ff9e059de6dd30c813270ff5a74053339cc94765", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "Hyprland", + "type": "github" + } + }, + "hyprland-protocols": { + "inputs": { + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1738422629, + "narHash": "sha256-5v+bv75wJWvahyM2xcMTSNNxmV8a7hb01Eey5zYnBJw=", + "owner": "hyprwm", + "repo": "hyprland-protocols", + "rev": "755aef8dab49d0fc4663c715fa4ad221b2aedaed", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprland-protocols", + "type": "github" + } + }, + "hyprland-qt-support": { + "inputs": { + "hyprlang": [ + "hyprland", + "hyprland-qtutils", + "hyprlang" + ], + "nixpkgs": [ + "hyprland", + "hyprland-qtutils", + "nixpkgs" + ], + "systems": [ + "hyprland", + "hyprland-qtutils", + "systems" + ] + }, + "locked": { + "lastModified": 1737634706, + "narHash": "sha256-nGCibkfsXz7ARx5R+SnisRtMq21IQIhazp6viBU8I/A=", + "owner": "hyprwm", + "repo": "hyprland-qt-support", + "rev": "8810df502cdee755993cb803eba7b23f189db795", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprland-qt-support", + "type": "github" + } + }, + "hyprland-qtutils": { + "inputs": { + "hyprland-qt-support": "hyprland-qt-support", + "hyprlang": [ + "hyprland", + "hyprlang" + ], + "hyprutils": [ + "hyprland", + "hyprland-qtutils", + "hyprlang", + "hyprutils" + ], + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1737981711, + "narHash": "sha256-lh6cL5D8nPplB3WovCQjLUZ7k7MViiBrMlpkfm4R7/c=", + "owner": "hyprwm", + "repo": "hyprland-qtutils", + "rev": "96bf0677fa9cd13508294e3d4559dfbbc8beff73", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprland-qtutils", + "type": "github" + } + }, + "hyprlang": { + "inputs": { + "hyprutils": [ + "hyprland", + "hyprutils" + ], + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1737634606, + "narHash": "sha256-W7W87Cv6wqZ9PHegI6rH1+ve3zJPiyevMFf0/HwdbCQ=", + "owner": "hyprwm", + "repo": "hyprlang", + "rev": "f41271d35cc0f370d300413d756c2677f386af9d", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprlang", + "type": "github" + } + }, + "hyprutils": { + "inputs": { + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1737978343, + "narHash": "sha256-TfFS0HCEJh63Kahrkp1h9hVDMdLU8a37Zz+IFucxyfA=", + "owner": "hyprwm", + "repo": "hyprutils", + "rev": "6a8bc9d2a4451df12f5179dc0b1d2d46518a90ab", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprutils", + "type": "github" + } + }, + "hyprwayland-scanner": { + "inputs": { + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1735493474, + "narHash": "sha256-fktzv4NaqKm94VAkAoVqO/nqQlw+X0/tJJNAeCSfzK4=", + "owner": "hyprwm", + "repo": "hyprwayland-scanner", + "rev": "de913476b59ee88685fdc018e77b8f6637a2ae0b", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprwayland-scanner", + "type": "github" + } + }, "nixpkgs": { + "locked": { + "lastModified": 1738410390, + "narHash": "sha256-xvTo0Aw0+veek7hvEVLzErmJyQkEcRk6PSR4zsRQFEc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3a228057f5b619feb3186e986dbe76278d707b6e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1738680400, "narHash": "sha256-ooLh+XW8jfa+91F1nhf9OF7qhuA/y1ChLx6lXDNeY5U=", @@ -36,10 +382,90 @@ "type": "github" } }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "hyprland", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1737465171, + "narHash": "sha256-R10v2hoJRLq8jcL4syVFag7nIGE7m13qO48wRIukWNg=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "9364dc02281ce2d37a1f55b6e51f7c0f65a75f17", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { "home-manager": "home-manager", - "nixpkgs": "nixpkgs" + "hyprland": "hyprland", + "nixpkgs": "nixpkgs_2" + } + }, + "systems": { + "locked": { + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "owner": "nix-systems", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-linux", + "type": "github" + } + }, + "xdph": { + "inputs": { + "hyprland-protocols": [ + "hyprland", + "hyprland-protocols" + ], + "hyprlang": [ + "hyprland", + "hyprlang" + ], + "hyprutils": [ + "hyprland", + "hyprutils" + ], + "hyprwayland-scanner": [ + "hyprland", + "hyprwayland-scanner" + ], + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1737634991, + "narHash": "sha256-dBAnb7Kbnier30cA7AgxVSxxARmxKZ1vHZT33THSIr8=", + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", + "rev": "e09dfe2726c8008f983e45a0aa1a3b7416aaeb8a", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 56b9377..0b94889 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,8 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + hyprland.url = "github:hyprwm/Hyprland"; + home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; @@ -11,12 +13,15 @@ }; outputs = { self, nixpkgs, ... }@inputs: { - nixosConfigurations.default = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs;}; - modules = [ - ./configuration.nix - inputs.home-manager.nixosModules.default - ]; + nixosConfigurations = { + # This should correspond to the hostname of the machine + t0urn3s0l = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs;}; + modules = [ + ./hosts/t0urn3s0l/configuration.nix + inputs.home-manager.nixosModules.default + ]; + }; }; }; } diff --git a/configuration.nix b/hosts/t0urn3s0l/configuration.nix similarity index 77% rename from configuration.nix rename to hosts/t0urn3s0l/configuration.nix index 1ad7e1d..35fa0e6 100644 --- a/configuration.nix +++ b/hosts/t0urn3s0l/configuration.nix @@ -15,7 +15,7 @@ boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; - networking.hostName = "nixos"; # Define your hostname. + networking.hostName = "t0urn3s0l"; # Define your hostname. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. # Configure network proxy if necessary @@ -24,6 +24,12 @@ # Enable Nix Flakes nix.settings.experimental-features = ["nix-command" "flakes"]; + + # Enable Hyprland cache so we don't have to compile it ourselves + nix.settings = { + substituters = ["https://hyprland.cachix.org"]; + trusted-public-keys = ["hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="]; + }; # Enable networking networking.networkmanager.enable = true; @@ -48,11 +54,11 @@ # Enable the X11 windowing system. # You can disable this if you're only using the Wayland session. - services.xserver.enable = true; + services.xserver.enable = false; # Enable the KDE Plasma Desktop Environment. - services.displayManager.sddm.enable = true; - services.desktopManager.plasma6.enable = true; + services.displayManager.sddm.enable = false; + services.desktopManager.plasma6.enable = false; # Configure keymap in X11 services.xserver.xkb = { @@ -60,6 +66,14 @@ variant = ""; }; + programs.hyprland = { + enable = true; + # set the flake package + package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland; + # make sure to also set the portal package, so that they are in sync + portalPackage = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland; + }; + # Configure console keymap console.keyMap = "fr"; @@ -107,24 +121,30 @@ services.xserver.displayManager.autoLogin.enable = true; services.xserver.displayManager.autoLogin.user = "zuma"; + environment.sessionVariables = rec { + XCURSOR_SIZE = 24; + }; + # Install firefox. programs.firefox.enable = true; - # Install KDE Partition Manager - programs.partition-manager.enable = true; - # Allow unfree packages nixpkgs.config.allowUnfree = true; # List packages installed in system profile. To search, run: # $ nix search wget environment.systemPackages = with pkgs; [ - # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - # wget - neovim - git + neovim # <3 + git # <3 bis + kitty # Hyprland default terminal + + xfce.thunar # GUI Filebrowser ]; + programs.xfconf.enable = true; # Enable xfconf because we don't use XFCE + services.gvfs.enable = true; # Enable Trash so that if I delete my nix files without having saved them I can backup ......... + services.tumbler.enable = true; # Thumbnail support + # Some programs need SUID wrappers, can be configured further or are # started in user sessions. # programs.mtr.enable = true; diff --git a/hardware-configuration.nix b/hosts/t0urn3s0l/hardware-configuration.nix similarity index 100% rename from hardware-configuration.nix rename to hosts/t0urn3s0l/hardware-configuration.nix diff --git a/home.nix b/hosts/t0urn3s0l/home.nix similarity index 96% rename from home.nix rename to hosts/t0urn3s0l/home.nix index 0b5dc34..7be1e0c 100644 --- a/home.nix +++ b/hosts/t0urn3s0l/home.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, inputs, ... }: { # Home Manager needs a bit of information about you and the paths it should @@ -51,6 +51,10 @@ # ''; }; + imports = [ + ../../commons/home-manager/hyprland.nix + ]; + # Home Manager can also manage your environment variables through # 'home.sessionVariables'. These will be explicitly sourced when using a # shell provided by Home Manager. If you don't want to manage your shell