From 850454a6c6d91f18f80560f467fa015009a41b02 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Wed, 17 Apr 2024 13:00:14 +0200 Subject: [PATCH] chore: work on modularization of config --- nix/base/base_packages.nix | 13 ++-- nix/base/xkb_layout.nix | 24 +++---- nix/flake.nix | 59 ++++++++++++---- nix/hardware/overheating/base_config.nix | 13 ++++ nix/hardware/overheating/configuration.nix | 79 +++++++++++++++++++++- nix/hardware/overheating/default.nix | 4 +- nix/hardware/overheating/overheating.nix | 58 +++++++++++++++- nix/hardware/spaceship/base_config.nix | 34 ++++++++++ nix/hardware/spaceship/configuration.nix | 6 +- nix/hardware/spaceship/spaceship.nix | 2 +- nix/modules/ironbar_config.nix | 12 ++++ nix/programs/common.nix | 8 +++ nix/programs/hyprland/config.nix | 37 ++-------- nix/programs/hyprland/hyprpaper.nix | 35 +++++----- nix/programs/hyprland/ironbar.nix | 8 ++- nix/programs/xdg.nix | 2 + 16 files changed, 300 insertions(+), 94 deletions(-) create mode 100644 nix/hardware/overheating/base_config.nix create mode 100644 nix/hardware/spaceship/base_config.nix create mode 100644 nix/modules/ironbar_config.nix diff --git a/nix/base/base_packages.nix b/nix/base/base_packages.nix index 0426ff8..95fd07f 100644 --- a/nix/base/base_packages.nix +++ b/nix/base/base_packages.nix @@ -43,12 +43,13 @@ nssmdns4 = true; openFirewall = true; }; - services.xserver.desktopManager.gnome.extraGSettingsOverrides = '' - [org.gnome.desktop.interface] - gtk-theme='adw-gtk3' - cursor-theme='Bibata-Modern-Classsic' - cursor-size=24 - ''; + # services.xserver.desktopManager.gnome.extraGSettingsOverrides = '' + # [org.gnome.desktop.interface] + # gtk-theme='adw-gtk3' + # cursor-theme='Bibata-Modern-Classsic' + # cursor-size=24 + # ''; + programs.direnv = { package = pkgs.direnv; silent = false; diff --git a/nix/base/xkb_layout.nix b/nix/base/xkb_layout.nix index 9422663..0370e17 100644 --- a/nix/base/xkb_layout.nix +++ b/nix/base/xkb_layout.nix @@ -1,27 +1,23 @@ -{ pkgs -, ... -}: +{ pkgs, ... }: let - customKeyboardLayout = pkgs.writeText "us_int" '' - xkb_symbols "us_int" + dashie = pkgs.writeText "dashie" '' + xkb_symbols "dashie" { include "us(basic)" - key {[ apostrophe, dead_diaeresis, apostrophe, quotedouble ] }; - key {[ grave, asciitilde ] }; + include "level3(ralt_switch)" + key { [ a, A, adiaeresis, Adiaeresis ] }; + key { [ o, O, odiaeresis, Odiaeresis ] }; + key { [ u, U, udiaeresis, Udiaeresis ] }; }; ''; - compiledLayout = pkgs.runCommand "keyboard-layout" { } '' - ${pkgs.xorg.xkbcomp}/bin/xkbcomp ${customKeyboardLayout} $out - ''; in { environment.systemPackages = [ pkgs.xorg.xkbcomp ]; - services.xserver.xkb.extraLayouts.us_int = { + services.xserver.xkb.extraLayouts.dashie = { description = "US layout with 'umlaut'"; languages = [ "eng" ]; - #symbolsFile = ${customKeyboardLayout}; - symbolsFile = /home/dashie/.config/symbols/us_int; + symbolsFile = "${dashie}"; }; - #services.xserver.displayManager.sessionCommands = "${pkgs.xorg.xkbcomp}/bin/xkbcomp ${compiledLayout} $DISPLAY"; } + diff --git a/nix/flake.nix b/nix/flake.nix index ee8ffe4..e36c497 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -34,7 +34,20 @@ allowUnfree = true; }; }; - default_modules = [ + + hypr_config = { monitor = [ "" ]; workspace = [ "" ]; }; + in + { + # TODO put actual configuration of profiles somewhere else + # TODO: deduplicate + homeConfigurations."marmo" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [ ./hardware/marmo/default.nix ]; + }; + nixosConfigurations."overheating" = nixpkgs.lib.nixosSystem { + inherit pkgs; + modules = [ + ./hardware/overheating/default.nix ./base/default.nix hyprland.nixosModules.default home-manager.nixosModules.home-manager @@ -56,31 +69,49 @@ hyprland.homeManagerModules.default anyrun.homeManagerModules.default ironbar.homeManagerModules.default + ./hardware/overheating/base_config.nix ./programs/hyprland/default.nix nix-flatpak.homeManagerModules.nix-flatpak ./programs/flatpak.nix ]; - home-manager.users.dashie.home.stateVersion = "24.05"; } - ]; - in - { - # TODO put actual configuration of profiles somewhere else - homeConfigurations."marmo" = home-manager.lib.homeManagerConfiguration { - inherit pkgs default_modules; - modules = [ ./hardware/marmo/default.nix ]; - }; - homeConfigurations."overheating" = home-manager.lib.homeManagerConfiguration { - inherit pkgs default_modules; - modules = [ ./hardware/overheating/default.nix ]; + ]; }; nixosConfigurations."spaceship" = nixpkgs.lib.nixosSystem { - inherit pkgs default_modules; + inherit pkgs; modules = [ ./hardware/spaceship/default.nix ./hardware/streamdeck.nix ./programs/gaming/default.nix + ./base/default.nix + hyprland.nixosModules.default + home-manager.nixosModules.home-manager + { + xdg.portal.config.common.default = "*"; + xdg.portal = { + enable = true; + extraPortals = [ + pkgs.xdg-desktop-portal-hyprland + pkgs.xdg-desktop-portal-gtk + ]; + }; + home-manager.useGlobalPkgs = true; + home-manager.users.dashie.imports = [ + { + _module = { args = { inherit self inputs; }; }; + } + ./programs/default.nix + hyprland.homeManagerModules.default + anyrun.homeManagerModules.default + ironbar.homeManagerModules.default + ./hardware/spaceship/base_config.nix + ./programs/hyprland/default.nix + nix-flatpak.homeManagerModules.nix-flatpak + ./programs/flatpak.nix + ]; + home-manager.users.dashie.home.stateVersion = "24.05"; + } ]; }; }; diff --git a/nix/hardware/overheating/base_config.nix b/nix/hardware/overheating/base_config.nix new file mode 100644 index 0000000..0f04c65 --- /dev/null +++ b/nix/hardware/overheating/base_config.nix @@ -0,0 +1,13 @@ +{ lib, config, ... }: { + imports = [ + ../../modules/ironbar_config.nix + ]; + wayland.windowManager.hyprland.settings.monitor = [ + # default + "eDP-1,2944x1840@90,0x0,2" + + # all others + ",highrr,auto,1" + ]; + programs.ironbar.monitor = "eDP-1"; +} diff --git a/nix/hardware/overheating/configuration.nix b/nix/hardware/overheating/configuration.nix index 0967ef4..84e0019 100644 --- a/nix/hardware/overheating/configuration.nix +++ b/nix/hardware/overheating/configuration.nix @@ -1 +1,78 @@ -{} +{ pkgs, ... }: +{ + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.kernelPackages = pkgs.linuxPackages_latest; + + # WARNING: Simply change this for each config + networking.hostName = "overheating"; + + # Enable networking + networking.networkmanager.enable = true; + services.flatpak.enable = true; + + # Set your time zone. + time.timeZone = "Europe/Zurich"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Configure keymap in X11 + services.xserver = { + xkb.layout = "us"; + xkb.variant = ""; + }; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # Enable sound with pipewire. + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + + environment.variables = { + XDG_CACHE_HOME = "$HOME/.cache"; + DIRENV_LOG_FORMAT = ""; + }; + + # allows user change later on + users.mutableUsers = true; + users.users.dashie = { + isNormalUser = true; + description = "dashie"; + extraGroups = [ "networkmanager" "wheel" "gamemode" ]; + packages = with pkgs; [ + home-manager + xdg-desktop-portal-gtk + xdg-desktop-portal-hyprland + ]; + # this password will only last for the first login + # e.g. login, then change to whatever else, this also ensures no public hash is available + password = "firstlogin"; + }; + + nix.settings = { + builders-use-substitutes = true; + # substituters to use + substituters = [ + "https://anyrun.cachix.org" + ]; + + trusted-public-keys = [ + "anyrun.cachix.org-1:pqBobmOjI7nKlsUMV25u9QHa9btJK65/C8vnO3p346s=" + ]; + }; + + system.stateVersion = "unstable"; +} diff --git a/nix/hardware/overheating/default.nix b/nix/hardware/overheating/default.nix index 407b224..3091cdc 100644 --- a/nix/hardware/overheating/default.nix +++ b/nix/hardware/overheating/default.nix @@ -1,6 +1,6 @@ { imports = [ - ./overheating.nix - ./configuration.nix + ./overheating.nix + ./configuration.nix ]; } diff --git a/nix/hardware/overheating/overheating.nix b/nix/hardware/overheating/overheating.nix index f3bcc32..6371d50 100644 --- a/nix/hardware/overheating/overheating.nix +++ b/nix/hardware/overheating/overheating.nix @@ -1 +1,57 @@ -{ config, lib, pkgs, modulesPath, ... }: { } +{ config, lib, modulesPath, ... }: +{ + imports = + [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { + device = "/dev/disk/by-label/ROOT"; + fsType = "btrfs"; + options = [ + "noatime" + "nodiratime" + "discard" + ]; + }; + + fileSystems."/boot" = + { + device = "/dev/disk/by-label/BOOT"; + fsType = "vfat"; + options = [ "rw" "fmask=0022" "dmask=0022" "noatime" ]; + }; + + fileSystems."/home" = + { + device = "/dev/disk/by-label/HOME"; + fsType = "btrfs"; + options = [ + "noatime" + "nodiratime" + "discard" + ]; + }; + + swapDevices = + [{ device = "/dev/disk/by-label/SWAP"; }]; + + # 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 + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp15s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp16s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + services.fstrim.enable = lib.mkDefault true; + nix.settings.auto-optimise-store = true; +} diff --git a/nix/hardware/spaceship/base_config.nix b/nix/hardware/spaceship/base_config.nix new file mode 100644 index 0000000..c970730 --- /dev/null +++ b/nix/hardware/spaceship/base_config.nix @@ -0,0 +1,34 @@ +{config, ...}:{ + imports = [ + ../../modules/ironbar_config.nix + ]; + wayland.windowManager.hyprland.settings.monitor = [ + # default + "DP-2,2560x1440@165,0x0,1" + "DP-1,3440x1440@180,2560x0,1" + "HDMI-A-1,1920x1200@60,6000x0,1" + "HDMI-A-1,transform,1" + + # all others + ",highrr,auto,1" + ]; + wayland.windowManager.hyprland.settings.workspace = [ + # workspaces + # monitor middle + "2,monitor:DP-1, default:true" + "4,monitor:DP-1" + "6,monitor:DP-1" + "8,monitor:DP-1" + "9,monitor:DP-1" + "10,monitor:DP-1" + + # monitor left + "1,monitor:DP-2, default:true" + "5,monitor:DP-2" + "7,monitor:DP-2" + + # monitor right + "3,monitor:HDMI-A-1, default:true" + ]; + programs.monitor = "DP-1"; +} diff --git a/nix/hardware/spaceship/configuration.nix b/nix/hardware/spaceship/configuration.nix index 9f5fdea..422235f 100644 --- a/nix/hardware/spaceship/configuration.nix +++ b/nix/hardware/spaceship/configuration.nix @@ -45,13 +45,13 @@ pulse.enable = true; }; - environment.variables = rec { + environment.variables = { XDG_CACHE_HOME = "$HOME/.cache"; DIRENV_LOG_FORMAT = ""; }; # allows user change later on - users.mutableUsers=true; + users.mutableUsers = true; users.users.dashie = { isNormalUser = true; description = "dashie"; @@ -63,7 +63,7 @@ ]; # this password will only last for the first login # e.g. login, then change to whatever else, this also ensures no public hash is available - hashedPassword="firstlogin"; + hashedPassword = "firstlogin"; }; nix.settings = { diff --git a/nix/hardware/spaceship/spaceship.nix b/nix/hardware/spaceship/spaceship.nix index 6c12638..a38ae70 100644 --- a/nix/hardware/spaceship/spaceship.nix +++ b/nix/hardware/spaceship/spaceship.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, modulesPath, ... }: +{ config, lib, modulesPath, ... }: { imports = [ diff --git a/nix/modules/ironbar_config.nix b/nix/modules/ironbar_config.nix new file mode 100644 index 0000000..2b3cacb --- /dev/null +++ b/nix/modules/ironbar_config.nix @@ -0,0 +1,12 @@ +{ lib, ... }: { + options.programs.ironbar = { + monitor = lib.mkOption { + default = ""; + example = "eDP-1"; + type = lib.types.str; + description = '' + Extra settings for foo. + ''; + }; + }; +} diff --git a/nix/programs/common.nix b/nix/programs/common.nix index b345195..85c073a 100644 --- a/nix/programs/common.nix +++ b/nix/programs/common.nix @@ -55,6 +55,14 @@ filesystems=xdg-config/gtk-3.0;xdg-config/gtk-4.0 ''; + dconf.settings = { + "org/gnome/desktop/interface" = { + gtk-theme = "adw-gtk3"; + cursor-theme = "Bibata-Modern-Classic"; + cursor-size = 24; + }; + }; + programs.nix-index = { enable = true; diff --git a/nix/programs/hyprland/config.nix b/nix/programs/hyprland/config.nix index 8a737a8..4361535 100644 --- a/nix/programs/hyprland/config.nix +++ b/nix/programs/hyprland/config.nix @@ -148,7 +148,7 @@ }; input = { - kb_layout = "us_int"; + kb_layout = "dashie"; repeat_delay = 200; force_no_accel = true; touchpad = { @@ -169,6 +169,10 @@ enable_hyprcursor = false; }; + gestures = { + workspace_swipe = true; + }; + env = [ "GTK_CSD,0" "TERM,\"kitty /bin/fish\"" @@ -190,37 +194,6 @@ "GTK_USE_PORTAL, 1" ]; - monitor = [ - # default - "DP-2,2560x1440@165,0x0,1" - "DP-1,3440x1440@180,2560x0,1" - "HDMI-A-1,1920x1200@60,6000x0,1" - "HDMI-A-1,transform,1" - - # all others - ",highrr,auto,1" - ]; - - workspace = [ - # workspaces - # monitor middle - "2,monitor:DP-1, default:true" - "4,monitor:DP-1" - "6,monitor:DP-1" - "8,monitor:DP-1" - "9,monitor:DP-1" - "10,monitor:DP-1" - - # monitor left - "1,monitor:DP-2, default:true" - "5,monitor:DP-2" - "7,monitor:DP-2" - - # monitor right - "3,monitor:HDMI-A-1, default:true" - ]; - - layerrule = [ # layer rules # mainly to disable animations within slurp and grim diff --git a/nix/programs/hyprland/hyprpaper.nix b/nix/programs/hyprland/hyprpaper.nix index 4d9d162..652abf9 100644 --- a/nix/programs/hyprland/hyprpaper.nix +++ b/nix/programs/hyprland/hyprpaper.nix @@ -1,17 +1,18 @@ -{ - xdg.configFile."hypr/hyprpaper.conf" = { - text = - '' - #load - preload = /home/dashie/Pictures/backgrounds/shinobu_2k.jpg - preload = /home/dashie/Pictures/backgrounds/shino_wide.png - preload = /home/dashie/Pictures/backgrounds/shinobu_1200.jpg - - #set - wallpaper = DP-2,/home/dashie/Pictures/backgrounds/shinobu_2k.jpg - wallpaper = DP-1,/home/dashie/Pictures/backgrounds/shino_wide.png - wallpaper = HDMI-A-1,/home/dashie/Pictures/backgrounds/shinobu_1200.jpg - splash = true - ''; - }; -} +#{ +# xdg.configFile."hypr/hyprpaper.conf" = { +# text = +# '' +# #load +# preload = /home/dashie/Pictures/backgrounds/shinobu_2k.jpg +# preload = /home/dashie/Pictures/backgrounds/shino_wide.png +# preload = /home/dashie/Pictures/backgrounds/shinobu_1200.jpg +# +# #set +# wallpaper = DP-2,/home/dashie/Pictures/backgrounds/shinobu_2k.jpg +# wallpaper = DP-1,/home/dashie/Pictures/backgrounds/shino_wide.png +# wallpaper = HDMI-A-1,/home/dashie/Pictures/backgrounds/shinobu_1200.jpg +# splash = true +# ''; +# }; +#} +{} diff --git a/nix/programs/hyprland/ironbar.nix b/nix/programs/hyprland/ironbar.nix index 93ff49a..d582b4a 100644 --- a/nix/programs/hyprland/ironbar.nix +++ b/nix/programs/hyprland/ironbar.nix @@ -1,5 +1,7 @@ -{ - programs.ironbar = { +{config, ...}:{ + + programs.ironbar = + { enable = true; style = '' @import url("/home/dashie/.config/gtk-3.0/gtk.css"); @@ -139,7 +141,7 @@ #"another_feature" ]; config = { - monitors.DP-1 = { + monitors."${config.programs.ironbar.monitor}" = { end = [ { type = "sys_info"; diff --git a/nix/programs/xdg.nix b/nix/programs/xdg.nix index b604a04..a0d0b97 100644 --- a/nix/programs/xdg.nix +++ b/nix/programs/xdg.nix @@ -1,3 +1,5 @@ +{config, ...}: + let browser = [ "firefox.desktop" ];