diff --git a/nixos/audio.nix b/nixos/audio.nix index 76758ee..d54b0ef 100644 --- a/nixos/audio.nix +++ b/nixos/audio.nix @@ -12,7 +12,7 @@ enable = true; extraConfig = { "10-disable-camera" = { - "wireplumber.profiles" = { main."monitor.libcamera" = "disabled"; }; + "wireplumber.profiles" = {main."monitor.libcamera" = "disabled";}; }; }; }; diff --git a/nixos/bluetooth.nix b/nixos/bluetooth.nix index f5c7856..67dd8ed 100644 --- a/nixos/bluetooth.nix +++ b/nixos/bluetooth.nix @@ -1,5 +1,5 @@ -{ pkgs, ... }: { - environment.systemPackages = with pkgs; [ blueman ]; +{pkgs, ...}: { + environment.systemPackages = with pkgs; [blueman]; hardware.bluetooth = { enable = true; powerOnBoot = true; diff --git a/nixos/docker.nix b/nixos/docker.nix index 6fa3bc6..bea0536 100644 --- a/nixos/docker.nix +++ b/nixos/docker.nix @@ -1,4 +1,4 @@ -{ config, ... }: { +{config, ...}: { virtualisation.docker.enable = true; - users.users."${config.var.username}".extraGroups = [ "docker" ]; + users.users."${config.var.username}".extraGroups = ["docker"]; } diff --git a/nixos/fonts.nix b/nixos/fonts.nix index 1cd59c9..4e7e18c 100644 --- a/nixos/fonts.nix +++ b/nixos/fonts.nix @@ -1,5 +1,4 @@ -{ pkgs, ... }: { - +{pkgs, ...}: { fonts = { packages = with pkgs; [ roboto diff --git a/nixos/home-manager.nix b/nixos/home-manager.nix index 0875089..cb94fa2 100644 --- a/nixos/home-manager.nix +++ b/nixos/home-manager.nix @@ -1,8 +1,8 @@ -{ inputs, ... }: { +{inputs, ...}: { home-manager = { useGlobalPkgs = true; useUserPackages = true; backupFileExtension = "hm-backup"; - extraSpecialArgs = { inherit inputs; }; + extraSpecialArgs = {inherit inputs;}; }; } diff --git a/nixos/hyprland.nix b/nixos/hyprland.nix index f58bbde..718408e 100644 --- a/nixos/hyprland.nix +++ b/nixos/hyprland.nix @@ -1,4 +1,8 @@ -{ inputs, pkgs, ... }: { +{ + inputs, + pkgs, + ... +}: { programs.hyprland = { enable = true; withUWSM = true; diff --git a/nixos/nix.nix b/nixos/nix.nix index fabb277..3aa8930 100644 --- a/nixos/nix.nix +++ b/nixos/nix.nix @@ -1,26 +1,34 @@ -{ config, inputs, ... }: -let autoGarbageCollector = config.var.autoGarbageCollector; +{ + config, + inputs, + ... +}: let + autoGarbageCollector = config.var.autoGarbageCollector; in { - security.sudo.extraRules = [{ - users = [ config.var.username ]; - commands = [{ - command = "/run/current-system/sw/bin/nixos-rebuild"; - options = [ "NOPASSWD" ]; - }]; - }]; + security.sudo.extraRules = [ + { + users = [config.var.username]; + commands = [ + { + command = "/run/current-system/sw/bin/nixos-rebuild"; + options = ["NOPASSWD"]; + } + ]; + } + ]; nixpkgs.config = { allowUnfree = true; allowBroken = true; }; nix = { - nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; + nixPath = ["nixpkgs=${inputs.nixpkgs}"]; channel.enable = false; extraOptions = '' warn-dirty = false ''; settings = { auto-optimise-store = true; - experimental-features = [ "nix-command" "flakes" ]; + experimental-features = ["nix-command" "flakes"]; substituters = [ # high priority since it's almost always used "https://cache.nixos.org?priority=10" diff --git a/nixos/nvidia.nix b/nixos/nvidia.nix index 231d6f2..67b7901 100644 --- a/nixos/nvidia.nix +++ b/nixos/nvidia.nix @@ -1,12 +1,13 @@ -{ lib, pkgs, config, ... }: - -let +{ + pkgs, + config, + ... +}: let # Using beta driver for recent GPUs like RTX 4070 nvidiaDriverChannel = config.boot.kernelPackages.nvidiaPackages.beta; in { # Video drivers configuration for Xorg and Wayland - services.xserver.videoDrivers = - [ "nvidia" ]; # Simplified - other modules are loaded automatically + services.xserver.videoDrivers = ["nvidia"]; # Simplified - other modules are loaded automatically # Kernel parameters for better Wayland and Hyprland integration boot.kernelParams = [ @@ -16,7 +17,7 @@ in { ]; # Blacklist nouveau to avoid conflicts - boot.blacklistedKernelModules = [ "nouveau" ]; + boot.blacklistedKernelModules = ["nouveau"]; # Environment variables for better compatibility environment.variables = { @@ -88,7 +89,7 @@ in { # Nix cache for CUDA nix.settings = { - substituters = [ "https://cuda-maintainers.cachix.org" ]; + substituters = ["https://cuda-maintainers.cachix.org"]; trusted-public-keys = [ "cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=" ]; diff --git a/nixos/omen.nix b/nixos/omen.nix index 246b188..fb2c0b0 100644 --- a/nixos/omen.nix +++ b/nixos/omen.nix @@ -1,8 +1,15 @@ -{ config, pkgs, ... }: - -let - hp-omen-linux-module = pkgs.callPackage - ({ kernel ? config.boot.kernelPackages.kernel, stdenv, fetchFromGitHub }: +{ + config, + pkgs, + ... +}: let + hp-omen-linux-module = + pkgs.callPackage + ({ + kernel ? config.boot.kernelPackages.kernel, + stdenv, + fetchFromGitHub, + }: stdenv.mkDerivation (finalAttrs: { pname = "hp-omen-linux-module"; version = "rebase-6.14"; @@ -24,13 +31,13 @@ let install hp-wmi.ko -Dm444 -t $out/lib/modules/${kernel.modDirVersion}/kernel/drivers/platform/x86/hp/ runHook postInstall ''; - })) { kernel = config.boot.kernelPackages.kernel; }; + })) {kernel = config.boot.kernelPackages.kernel;}; in { - boot.extraModulePackages = [ hp-omen-linux-module ]; - boot.kernelModules = [ "hp-wmi" ]; + boot.extraModulePackages = [hp-omen-linux-module]; + boot.kernelModules = ["hp-wmi"]; - users.groups.omen-rgb = { }; - users.users.${config.var.username}.extraGroups = [ "omen-rgb" ]; + users.groups.omen-rgb = {}; + users.users.${config.var.username}.extraGroups = ["omen-rgb"]; systemd.tmpfiles.rules = [ "w /sys/devices/platform/hp-wmi/rgb_zones/zone00 0660 root omen-rgb -" @@ -51,22 +58,4 @@ in { RUN+="${pkgs.coreutils}/bin/chgrp omen-rgb /sys/devices/platform/hp-wmi/rgb_zones/zone03", \ RUN+="${pkgs.coreutils}/bin/chmod 0660 /sys/devices/platform/hp-wmi/rgb_zones/zone03" ''; - # systemd.services.fix-hp-omen-perms = { - # description = "Fix HP Omen keyboard RGB zone permissions"; - # after = [ "systemd-modules-load.service" ]; - # wantedBy = [ "multi-user.target" ]; - # serviceConfig = { - # Type = "oneshot"; - # ExecStart = '' - # ${pkgs.coreutils}/bin/chgrp omen-rgb /sys/devices/platform/hp-wmi/rgb_zones/zone00 - # ${pkgs.coreutils}/bin/chmod 0660 /sys/devices/platform/hp-wmi/rgb_zones/zone00 - # ${pkgs.coreutils}/bin/chgrp omen-rgb /sys/devices/platform/hp-wmi/rgb_zones/zone01 - # ${pkgs.coreutils}/bin/chmod 0660 /sys/devices/platform/hp-wmi/rgb_zones/zone01 - # ${pkgs.coreutils}/bin/chgrp omen-rgb /sys/devices/platform/hp-wmi/rgb_zones/zone02 - # ${pkgs.coreutils}/bin/chmod 0660 /sys/devices/platform/hp-wmi/rgb_zones/zone02 - # ${pkgs.coreutils}/bin/chgrp omen-rgb /sys/devices/platform/hp-wmi/rgb_zones/zone03 - # ${pkgs.coreutils}/bin/chmod 0660 /sys/devices/platform/hp-wmi/rgb_zones/zone03 - # ''; - # }; - # }; } diff --git a/nixos/sddm.nix b/nixos/sddm.nix index 842223b..4115086 100644 --- a/nixos/sddm.nix +++ b/nixos/sddm.nix @@ -1,34 +1,14 @@ # SDDM is a display manager for X11 and Wayland -{ pkgs, inputs, config, lib, ... }: -let +{ + pkgs, + inputs, + config, + ... +}: let foreground = config.theme.textColorOnWallpaper; sddm-astronaut = pkgs.sddm-astronaut.override { embeddedTheme = "pixel_sakura"; - # TODO: Cleaner version for static vs .gif, just a string.replace - themeConfig = if lib.hasSuffix "sakura_static.png" config.stylix.image then - { } - else if lib.hasSuffix "studio.png" config.stylix.image then { - Background = pkgs.fetchurl { - url = - "https://raw.githubusercontent.com/anotherhadi/nixy-wallpapers/refs/heads/main/wallpapers/studio.gif"; - sha256 = "sha256-qySDskjmFYt+ncslpbz0BfXiWm4hmFf5GPWF2NlTVB8="; - }; - HeaderTextColor = "#${foreground}"; - DateTextColor = "#${foreground}"; - TimeTextColor = "#${foreground}"; - LoginFieldTextColor = "#${foreground}"; - PasswordFieldTextColor = "#${foreground}"; - UserIconColor = "#${foreground}"; - PasswordIconColor = "#${foreground}"; - WarningColor = "#${foreground}"; - LoginButtonBackgroundColor = "#${foreground}"; - SystemButtonsIconsColor = "#${foreground}"; - SessionButtonTextColor = "#${foreground}"; - VirtualKeyboardButtonTextColor = "#${foreground}"; - DropdownBackgroundColor = "#${foreground}"; - HighlightBackgroundColor = "#${foreground}"; - } else { - Background = "${toString config.stylix.image}"; + themeConfig = { HeaderTextColor = "#${foreground}"; DateTextColor = "#${foreground}"; TimeTextColor = "#${foreground}"; @@ -43,26 +23,37 @@ let VirtualKeyboardButtonTextColor = "#${foreground}"; DropdownBackgroundColor = "#${foreground}"; HighlightBackgroundColor = "#${foreground}"; + Background = + if "sakura_pixelart_light_static.png" == config.stylix.image + then + pkgs.fetchurl { + url = "https://raw.githubusercontent.com/anotherhadi/awesome-wallpapers/refs/heads/main/app/static/wallpapers/sakura_pixelart_light_animated.gif"; + sha256 = "sha256-qySDskjmFYt+ncslpbz0BfXiWm4hmFf5GPWF2NlTVB8="; + } + else if "cat-watching-the-star_pixelart_purple_static.png" == config.stylix.image + then + pkgs.fetchurl { + url = "https://raw.githubusercontent.com/anotherhadi/awesome-wallpapers/refs/heads/main/app/static/wallpapers/cat-watching-the-star_pixelart_purple_animated.gif"; + sha256 = ""; + } + else "${toString config.stylix.image}"; }; }; in { services.displayManager = { sddm = { package = pkgs.kdePackages.sddm; - extraPackages = [ sddm-astronaut ]; + extraPackages = [sddm-astronaut]; enable = true; wayland.enable = true; theme = "sddm-astronaut-theme"; settings = { Wayland.SessionDir = "${ - inputs.hyprland.packages."${pkgs.system}".hyprland - }/share/wayland-sessions"; + inputs.hyprland.packages."${pkgs.system}".hyprland + }/share/wayland-sessions"; }; }; }; - environment.systemPackages = [ sddm-astronaut ]; - - # To prevent getting stuck at shutdown - systemd.extraConfig = "DefaultTimeoutStopSec=10s"; + environment.systemPackages = [sddm-astronaut]; } diff --git a/nixos/systemd-boot.nix b/nixos/systemd-boot.nix index 5f0003e..18a4d0f 100644 --- a/nixos/systemd-boot.nix +++ b/nixos/systemd-boot.nix @@ -1,8 +1,4 @@ -{ - pkgs, - lib, - ... -}: { +{pkgs, ...}: { boot = { bootspec.enable = true; loader = { @@ -29,14 +25,17 @@ consoleLogLevel = 0; initrd.verbose = false; - plymouth = { - enable = true; - theme = lib.mkForce "cuts_alt"; - themePackages = with pkgs; [ - (adi1090x-plymouth-themes.override { - selected_themes = ["cuts_alt"]; - }) - ]; - }; + # plymouth = { + # enable = true; + # theme = lib.mkForce "cuts_alt"; + # themePackages = with pkgs; [ + # (adi1090x-plymouth-themes.override { + # selected_themes = ["cuts_alt"]; + # }) + # ]; + # }; }; + + # To avoid systemd services hanging on shutdown + systemd.extraConfig = "DefaultTimeoutStopSec=10s"; } diff --git a/nixos/tailscale.nix b/nixos/tailscale.nix index 14bf7e8..f323bc9 100644 --- a/nixos/tailscale.nix +++ b/nixos/tailscale.nix @@ -1,25 +1,31 @@ # Tailscale is a VPN service that makes it easy to connect your devices between each other. -{ config, ... }: { - security.sudo.extraRules = [{ - users = [ config.var.username ]; - commands = [ - { - command = "/etc/profiles/per-user/${config.var.username}/bin/tailscale"; - options = [ "NOPASSWD" ]; - } - { - command = "/run/current-system/sw/bin/tailscale"; - options = [ "NOPASSWD" ]; - } - ]; - }]; +{config, ...}: let + username = config.var.username; +in { + security.sudo.extraRules = [ + { + users = [username]; + # Allow running Tailscale commands without a password + commands = [ + { + command = "/etc/profiles/per-user/${username}/bin/tailscale"; + options = ["NOPASSWD"]; + } + { + command = "/run/current-system/sw/bin/tailscale"; + options = ["NOPASSWD"]; + } + ]; + } + ]; + services.tailscale = { enable = true; openFirewall = true; }; networking.firewall = { - trustedInterfaces = [ "tailscale0" ]; + trustedInterfaces = ["tailscale0"]; # required to connect to Tailscale exit nodes checkReversePath = "loose"; }; diff --git a/nixos/tuigreet.nix b/nixos/tuigreet.nix index 775d802..2c3c9e3 100644 --- a/nixos/tuigreet.nix +++ b/nixos/tuigreet.nix @@ -1,18 +1,17 @@ # TUIGreet is a display manager. # Legacy, I'm now using SDDM -{ pkgs, ... }: { +{pkgs, ...}: { services.greetd = { enable = true; settings = { default_session = { - command = - "${pkgs.greetd.tuigreet}/bin/tuigreet --remember --asterisks --container-padding 2 --time --time-format '%I:%M %p | %a • %h | %F' --cmd Hyprland"; + command = "${pkgs.greetd.tuigreet}/bin/tuigreet --remember --asterisks --container-padding 2 --time --time-format '%I:%M %p | %a • %h | %F' --cmd Hyprland"; user = "greeter"; }; }; }; - environment.systemPackages = with pkgs; [ greetd.tuigreet ]; + environment.systemPackages = with pkgs; [greetd.tuigreet]; # this is a life saver. # literally no documentation about this anywhere. @@ -28,8 +27,4 @@ TTYVHangup = true; TTYVTDisallocate = true; }; - - # To prevent getting stuck at shutdown - systemd.extraConfig = "DefaultTimeoutStopSec=10s"; - } diff --git a/nixos/users.nix b/nixos/users.nix index a6e1813..7733b61 100644 --- a/nixos/users.nix +++ b/nixos/users.nix @@ -1,13 +1,18 @@ -{ config, pkgs, ... }: -let username = config.var.username; +{ + config, + pkgs, + ... +}: let + username = config.var.username; in { programs.zsh.enable = true; users = { defaultUserShell = pkgs.zsh; + users.${username} = { isNormalUser = true; description = "${username} account"; - extraGroups = [ "networkmanager" "wheel" ]; + extraGroups = ["networkmanager" "wheel"]; }; }; } diff --git a/nixos/utils.nix b/nixos/utils.nix index ff71699..ef2865b 100644 --- a/nixos/utils.nix +++ b/nixos/utils.nix @@ -1,5 +1,8 @@ -{ pkgs, config, inputs, ... }: -let +{ + pkgs, + config, + ... +}: let hostname = config.var.hostname; keyboardLayout = config.var.keyboardLayout; configDir = config.var.configDirectory; @@ -17,11 +20,11 @@ in { enable = autoUpgrade; dates = "04:00"; flake = "${configDir}"; - flags = [ "--update-input" "nixpkgs" "--commit-lock-file" ]; + flags = ["--update-input" "nixpkgs" "--commit-lock-file"]; allowReboot = false; }; - time = { timeZone = timeZone; }; + time = {timeZone = timeZone;}; i18n.defaultLocale = defaultLocale; i18n.extraLocaleSettings = { LC_ADDRESS = extraLocale; @@ -64,7 +67,7 @@ in { dbus = { enable = true; implementation = "broker"; - packages = with pkgs; [ gcr gnome-settings-daemon ]; + packages = with pkgs; [gcr gnome-settings-daemon]; }; gvfs.enable = true; upower.enable = true; @@ -73,7 +76,7 @@ in { }; # enable zsh autocompletion for system packages (systemd, etc) - environment.pathsToLink = [ "/share/zsh" ]; + environment.pathsToLink = ["/share/zsh"]; # Faster rebuilding documentation = { @@ -101,11 +104,11 @@ in { enable = true; xdgOpenUsePortal = true; config = { - common.default = [ "gtk" ]; - hyprland.default = [ "gtk" "hyprland" ]; + common.default = ["gtk"]; + hyprland.default = ["gtk" "hyprland"]; }; - extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; + extraPortals = [pkgs.xdg-desktop-portal-gtk]; }; security = { diff --git a/server-modules/adguardhome.nix b/server-modules/adguardhome.nix index 3552d20..af3c52a 100644 --- a/server-modules/adguardhome.nix +++ b/server-modules/adguardhome.nix @@ -1,5 +1,7 @@ -{ config, ... }: -let domain = "adguard.hadi.diy"; +# Adguard is a network-wide ad blocker +# When installed, open localhost:3000 to setup +{config, ...}: let + domain = "adguard.hadi.diy"; in { services = { adguardhome = { @@ -11,8 +13,7 @@ in { useACMEHost = "hadi.diy"; forceSSL = true; locations."/" = { - proxyPass = - "http://127.0.0.1:${toString config.services.adguardhome.port}"; + proxyPass = "http://127.0.0.1:${toString config.services.adguardhome.port}"; }; }; }; diff --git a/server-modules/bitwarden.nix b/server-modules/bitwarden.nix index 76e3a18..51af04d 100644 --- a/server-modules/bitwarden.nix +++ b/server-modules/bitwarden.nix @@ -1,5 +1,6 @@ -{ config, ... }: -let domain = "vault.hadi.diy"; +# Bitwarden (or vaultwarden) is a self-hosted password manager. +{config, ...}: let + domain = "vault.hadi.diy"; in { services = { vaultwarden = { @@ -18,8 +19,8 @@ in { forceSSL = true; locations."/" = { proxyPass = "http://127.0.0.1:${ - toString config.services.vaultwarden.config.ROCKET_PORT - }"; + toString config.services.vaultwarden.config.ROCKET_PORT + }"; }; }; }; diff --git a/server-modules/firewall.nix b/server-modules/firewall.nix index 6987110..0a45838 100644 --- a/server-modules/firewall.nix +++ b/server-modules/firewall.nix @@ -1,3 +1,4 @@ +# Firewall configuration for NixOS { networking.firewall = { enable = true;