diff --git a/flake.nix b/flake.nix index 2c907de..5c8e996 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,7 @@ { - outputs = { nixpkgs, home-manager, ... }@inputs: { + description = "azikx snowflake palace"; + + outputs = { nixpkgs, home-manager, flake-parts, ... }@inputs: { nixosConfigurations.karbur = nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs; }; modules = [ ./host ]; @@ -27,6 +29,10 @@ yazi.url = "github:sxyazi/yazi"; # TWO LINE SOFTWARE + flake-parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; @@ -43,6 +49,8 @@ url = "github:pyt0xic/hyprfocus"; inputs.hyprland.follows = "hyprland"; }; + + # WALLPAPERS walls = { url = "git+https://git.pub.solar/azikx/wallpapers?ref=main"; flake = false; diff --git a/home/programs/cli/git/default.nix b/home/programs/cli/git/default.nix index f736411..382477c 100644 --- a/home/programs/cli/git/default.nix +++ b/home/programs/cli/git/default.nix @@ -6,7 +6,7 @@ extraConfig = { color.ui = true; init.defaultBranch = "main"; - safe.directory = "/home/dragora/.flake"; + safe.directory = "*"; }; }; } diff --git a/home/window-managers/hyprland/rules.nix b/home/window-managers/hyprland/rules.nix index 0faf01b..4bfd939 100644 --- a/home/window-managers/hyprland/rules.nix +++ b/home/window-managers/hyprland/rules.nix @@ -40,7 +40,7 @@ in { # MPV & ANIME "nodim, ${cl}(mpv)$" "float, ${cl}(anicliru)$" - "size 660 630, ${cl}(anicliru)$" + "size 810 630, ${cl}(anicliru)$" "bordercolor rgb(${base08}) rgb(${base09}) 45deg, ${cl}(anicliru)$" # KOMIKKU diff --git a/host/misc/default.nix b/host/misc/default.nix index be2bb8a..fda2b65 100644 --- a/host/misc/default.nix +++ b/host/misc/default.nix @@ -1,7 +1,5 @@ { imports = [ - ./torrserver - ./locale.nix ./nh.nix ./nix.nix diff --git a/host/misc/nh.nix b/host/misc/nh.nix index 50d39c3..de7b561 100644 --- a/host/misc/nh.nix +++ b/host/misc/nh.nix @@ -1,8 +1,9 @@ { ... }: { programs.nh = { # NIX HELPER enable = true; - clean.enable = true; - clean.extraArgs = "--keep-since 4d --keep 3"; - flake = "/home/dragora/.flake"; + clean = { + enable = true; + extraArgs = "--keep-since 4d --keep 3"; + }; }; } diff --git a/host/misc/nix.nix b/host/misc/nix.nix index 77e9c48..6809c83 100644 --- a/host/misc/nix.nix +++ b/host/misc/nix.nix @@ -16,7 +16,7 @@ "anyrun.cachix.org-1:pqBobmOjI7nKlsUMV25u9QHa9btJK65/C8vnO3p346s=" "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" ]; - trusted-users = [ "dragora" "@wheel" ]; + trusted-users = [ "@wheel" ]; }; }; diff --git a/host/misc/pkgs.nix b/host/misc/pkgs.nix index b071a26..dcc06af 100644 --- a/host/misc/pkgs.nix +++ b/host/misc/pkgs.nix @@ -1,32 +1,12 @@ -{ pkgs, inputs, lib, ... }: +{ pkgs, inputs, ... }: let hpkg = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}; in { # OS PACKAGES - nixpkgs = { hostPlatform = lib.mkDefault "x86_64-linux"; }; - environment.systemPackages = with pkgs; [ - git - helix - hyprland - home-manager - # (callPackage ./torrserver/package.nix { }) - ]; + environment.systemPackages = with pkgs; [ git helix home-manager ]; # PROGRAMS ENABLE programs = { fish.enable = true; - gamescope.enable = true; - steam = { - enable = true; - package = pkgs.steam.override { - extraEnv = { - MANGOHUD = true; - OBS_VKCAPTURE = true; - RADV_TEX_ANISO = 16; - }; - }; - extraCompatPackages = with pkgs; [ proton-ge-bin ]; - protontricks.enable = true; - }; hyprland = { enable = true; package = hpkg.hyprland; diff --git a/host/misc/security.nix b/host/misc/security.nix index 67a5c73..16a93a5 100644 --- a/host/misc/security.nix +++ b/host/misc/security.nix @@ -1,30 +1,32 @@ -{ ... }: { +{ comp, ... }: { security = { + sudo.enable = true; doas = { # VERY TOP enable = true; wheelNeedsPassword = true; extraRules = [{ - users = [ "dragora" ]; + users = [ comp.user ]; keepEnv = true; persist = true; }]; extraConfig = '' - permit nopass dragora as root cmd light - permit nopass dragora as root cmd tee + permit nopass ${comp.user} as root cmd light + permit nopass ${comp.user} as root cmd tee ''; }; - sudo-rs = { - enable = true; + sudo-rs = { # FAST SUDO + enable = false; wheelNeedsPassword = true; - extraRules = [{ - groups = [ "sudo" ]; - commands = [ "ALL" ]; - } - # { - # users = [ "megamozg" ]; - # commands = [ "light" "tee" ]; - # } - ]; + extraRules = [ + { + groups = [ "sudo" ]; + commands = [ "ALL" ]; + } + { + groups = [ "wheel" ]; + commands = [ "light" "tee" ]; + } + ]; }; polkit = { enable = true; }; }; diff --git a/host/misc/user.nix b/host/misc/user.nix index 3b76b5a..8734625 100644 --- a/host/misc/user.nix +++ b/host/misc/user.nix @@ -1,8 +1,8 @@ -{ pkgs, ... }: { +{ pkgs, comp, ... }: { system.stateVersion = "24.05"; users = { users = { # USERS - dragora = { + "${comp.user}" = { shell = pkgs.fish; isNormalUser = true; extraGroups = [ "networkmanager" "wheel" "video" ]; diff --git a/host/specific/comp/default.nix b/host/specific/comp/default.nix new file mode 100644 index 0000000..40d5a68 --- /dev/null +++ b/host/specific/comp/default.nix @@ -0,0 +1,8 @@ +{ + imports = [ + ./modules + + ./torrserver + ../../default.nix + ]; +} diff --git a/host/specific/comp/modules/default.nix b/host/specific/comp/modules/default.nix new file mode 100644 index 0000000..22de9e4 --- /dev/null +++ b/host/specific/comp/modules/default.nix @@ -0,0 +1 @@ +{ imports = [ ./disks.nix ./hardware.nix ./user-like.nix ]; } diff --git a/host/system/disks.nix b/host/specific/comp/modules/disks.nix similarity index 100% rename from host/system/disks.nix rename to host/specific/comp/modules/disks.nix diff --git a/host/specific/comp/modules/hardware.nix b/host/specific/comp/modules/hardware.nix new file mode 100644 index 0000000..b903d0a --- /dev/null +++ b/host/specific/comp/modules/hardware.nix @@ -0,0 +1,19 @@ +{ config, lib, ... }: { + hardware = { + # AND VIDEOCARD DRIVE (maybe) + amdgpu = { + amdvlk = { + enable = true; + supportExperimental.enable = true; + support32Bit.enable = true; + }; + }; + # PROCCESOR + cpu.amd = { + updateMicrocode = + lib.mkDefault config.hardware.enableRedistributableFirmware; + ryzen-smu.enable = true; + }; + xone.enable = true; + }; +} diff --git a/host/specific/comp/modules/user-like.nix b/host/specific/comp/modules/user-like.nix new file mode 100644 index 0000000..b8dc880 --- /dev/null +++ b/host/specific/comp/modules/user-like.nix @@ -0,0 +1,20 @@ +{ pkgs, comp, ... }: { + networking.hostName = comp.host; + services.getty.autologinUser = comp.user; + programs = { + nh.flake = "/home/${comp.user}/.flake"; # NIX-HELPER + gamescope.enable = true; + steam = { # GAMING + enable = true; + package = pkgs.steam.override { + extraEnv = { + MANGOHUD = true; + OBS_VKCAPTURE = true; + RADV_TEX_ANISO = 16; + }; + }; + extraCompatPackages = with pkgs; [ proton-ge-bin ]; + protontricks.enable = true; + }; + }; +} diff --git a/host/misc/torrserver/default.nix b/host/specific/comp/torrserver/default.nix similarity index 100% rename from host/misc/torrserver/default.nix rename to host/specific/comp/torrserver/default.nix diff --git a/host/misc/torrserver/package.nix b/host/specific/comp/torrserver/package.nix similarity index 100% rename from host/misc/torrserver/package.nix rename to host/specific/comp/torrserver/package.nix diff --git a/host/system/default.nix b/host/system/default.nix index 3cdc108..8caaca3 100644 --- a/host/system/default.nix +++ b/host/system/default.nix @@ -1,10 +1,10 @@ { imports = [ ./boot.nix - ./disks.nix ./hardware.nix - ./services.nix ./network.nix + ./services.nix ./sound.nix + ./minimal.nix ]; } diff --git a/host/system/hardware.nix b/host/system/hardware.nix index e63c1a1..aa95774 100644 --- a/host/system/hardware.nix +++ b/host/system/hardware.nix @@ -1,30 +1,20 @@ -{ config, lib, ... }: { +{ pkgs, ... }: { hardware = { - # AND VIDEOCARD DRIVE (maybe) - amdgpu = { - # opencl.enable = true; - amdvlk = { - enable = true; - supportExperimental.enable = true; - support32Bit.enable = true; - }; - }; # OPENGL - graphics = { + graphics = { # GPU enable = true; enable32Bit = true; - }; - # PROCCESOR - cpu.amd = { - updateMicrocode = - lib.mkDefault config.hardware.enableRedistributableFirmware; - ryzen-smu.enable = true; + extraPackages = with pkgs; [ amdvlk ]; + extraPackages32 = with pkgs; [ driversi686Linux.amdvlk ]; }; # BLUETOOTH bluetooth = { enable = true; powerOnBoot = true; }; + xone.enable = true; + system76.enableAll = true; + firmware = [ pkgs.linux-firmware ]; }; } diff --git a/host/system/minimal.nix b/host/system/minimal.nix new file mode 100644 index 0000000..17d99bb --- /dev/null +++ b/host/system/minimal.nix @@ -0,0 +1,9 @@ +{ + documentation = { + enable = false; + doc.enable = false; + info.enable = false; + man.enable = false; + nixos.enable = false; + }; +} diff --git a/host/system/network.nix b/host/system/network.nix index 642ee64..1c33bcc 100644 --- a/host/system/network.nix +++ b/host/system/network.nix @@ -1,6 +1,5 @@ { lib, ... }: { networking = { # NETWORK - hostName = "karbur"; networkmanager = { # NETWORK MANAGER enable = true; insertNameservers = [ "1.1.1.1" "1.0.0.1" ]; @@ -9,6 +8,5 @@ }; useDHCP = lib.mkDefault true; nftables.enable = true; - # resolvconf.dnsSingleRequest = true; }; } diff --git a/host/system/services.nix b/host/system/services.nix index 194ff3b..1f65960 100644 --- a/host/system/services.nix +++ b/host/system/services.nix @@ -1,6 +1,5 @@ { ... }: { services = { # SERVICES - getty.autologinUser = "dragora"; xserver = { # XORG? xkb = { layout = "us"; diff --git a/modules/host/default.nix b/modules/host/default.nix new file mode 100644 index 0000000..309359b --- /dev/null +++ b/modules/host/default.nix @@ -0,0 +1,8 @@ +{ systemModules, lib, ... }: + +{ + # Read all directories from systemModules + imports = builtins.filter (module: lib.pathIsDirectory module) + (map (module: "${systemModules}/${module}") + (builtins.attrNames (builtins.readDir systemModules))); +} diff --git a/modules/host/hardware/bluetooth/default.nix b/modules/host/hardware/bluetooth/default.nix new file mode 100644 index 0000000..89728e6 --- /dev/null +++ b/modules/host/hardware/bluetooth/default.nix @@ -0,0 +1,20 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.hardware.bluetooth; +in { + options = { module.hardware.bluetooth.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + hardware.bluetooth = { # BLUETOOTH LOL + enable = true; + powerOnBoot = true; + }; + environment.systemPackages = with pkgs; [ # TUI FOR BLUETOOTH + bluetuith + bluetooth_battery + ]; + }; +} + diff --git a/modules/host/hardware/boot/default.nix b/modules/host/hardware/boot/default.nix new file mode 100644 index 0000000..397e5d8 --- /dev/null +++ b/modules/host/hardware/boot/default.nix @@ -0,0 +1,65 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.hardware.boot; +in { + options = { module.hardware.boot.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + boot = { # ITSELF LOL + kernelPackages = pkgs.linuxPackages_zen; + kernelModules = [ "kvm-amd" ]; + consoleLogLevel = 0; + kernelParams = [ + "quiet" + "loglevel=3" + "nowatchdog" + "page_alloc.shuffle=1" + "threadirqs" + "split_lock_detect=off" + "pci=pcie_bus_perf" + "psmouse.synaptics_intertouch=0" + "rd.systemd.show_status=false" + ]; + + loader = { # SYSTEMD BOOT AS DEFAULT + systemd-boot = { + enable = true; + configurationLimit = 4; + }; + efi.canTouchEfiVariables = true; + timeout = 0; # TIMEOUT FOR LAUNCH + }; + + initrd = { # IDK + availableKernelModules = [ + "nvme" + "xhci_pci" + "ahci" + "ohci_pci" + "ehci_pci" + "pata_atiixp" + "ums_realtek" + "sd_mod" + "sr_mod" + "sdhci_pci" + "usb_storage" + ]; + systemd.enable = true; + compressor = "zstd"; + compressorArgs = [ "-9" ]; + verbose = false; + }; + + plymouth = { # PLYMOUTH WITH NIXOS LOGO + enable = true; + logo = + "${pkgs.nixos-icons}/share/icons/hicolor/48x48/apps/nix-snowflake-white.png"; + }; + + tmp.cleanOnBoot = true; + }; + }; +} + diff --git a/modules/host/hardware/cpu/default.nix b/modules/host/hardware/cpu/default.nix new file mode 100644 index 0000000..c9f3bee --- /dev/null +++ b/modules/host/hardware/cpu/default.nix @@ -0,0 +1,16 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.hardware.cpu; +in { + options = { module.hardware.cpu.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + hardware.cpu.amd = { # OPTIMIZATION FOR CPU + updateMicrocode = + lib.mkDefault config.hardware.enableRedistributableFirmware; + ryzen-smu.enable = true; + }; + }; +} diff --git a/modules/host/hardware/default.nix b/modules/host/hardware/default.nix new file mode 100644 index 0000000..dafc8ad --- /dev/null +++ b/modules/host/hardware/default.nix @@ -0,0 +1,9 @@ +{ systemModules, lib, ... }: + +let hostProgramModulesPath = "${systemModules}/hardware"; +in { + imports = builtins.filter (module: lib.pathIsDirectory module) + (map (module: "${hostProgramModulesPath}/${module}") + (builtins.attrNames (builtins.readDir hostProgramModulesPath))); +} + diff --git a/modules/host/hardware/gpu/default.nix b/modules/host/hardware/gpu/default.nix new file mode 100644 index 0000000..8777ded --- /dev/null +++ b/modules/host/hardware/gpu/default.nix @@ -0,0 +1,25 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.hardware.graphics; +in { + options = { module.hardware.graphics.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + hardware = { + graphics = { # GPU + enable = true; + enable32Bit = true; + extraPackages32 = with pkgs; [ driversi686Linux.amdvlk ]; + }; + amdgpu = { + amdvlk = { + enable = true; + support32Bit.enable = true; + supportExperimental.enable = true; + }; + }; + }; + }; +} diff --git a/modules/host/hardware/network/default.nix b/modules/host/hardware/network/default.nix new file mode 100644 index 0000000..1be38d5 --- /dev/null +++ b/modules/host/hardware/network/default.nix @@ -0,0 +1,37 @@ +{ lib, config, hostname, ... }: + +with lib; + +let cfg = config.module.hardware.network; +in { + options = { module.hardware.network.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + services.resolved.enable = true; + systemd.services = { # IDK + NetworkManager-wait-online.enable = false; + systemd-networkd-wait-online.enable = mkForce false; + }; + + networking = { # FOR NETWORK + hostName = hostname; + networkmanager = { + enable = true; + insertNameservers = [ "1.1.1.1" "1.0.0.1" ]; + dns = "systemd-resolved"; + wifi = { + powersave = true; + macAddress = "random"; + backend = "iwd"; + }; + }; + wireless.iwd = { + enable = true; + settings = { Settings = { AutoConnect = true; }; }; + }; + useDHCP = mkDefault true; + nftables.enable = true; + }; + }; +} + diff --git a/modules/host/hardware/security/default.nix b/modules/host/hardware/security/default.nix new file mode 100644 index 0000000..46ee988 --- /dev/null +++ b/modules/host/hardware/security/default.nix @@ -0,0 +1,34 @@ +{ lib, config, username, ... }: + +with lib; + +let cfg = config.module.hardware.security; +in { + options = { module.hardware.security.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + security = { + sudo.enable = false; + sudo-rs = { + enable = true; + execWheelOnly = true; + wheelNeedsPassword = true; + }; + doas = { # VERY TOP + enable = true; + wheelNeedsPassword = true; + extraRules = [{ + users = [ username ]; + keepEnv = true; + persist = true; + }]; + }; + pam.services = { + gtklock = { }; + swaylock = { }; + hyprlock = { }; + }; + }; + }; +} + diff --git a/modules/host/hardware/sound/default.nix b/modules/host/hardware/sound/default.nix new file mode 100644 index 0000000..a1f5018 --- /dev/null +++ b/modules/host/hardware/sound/default.nix @@ -0,0 +1,27 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.hardware.sound; +in { + options = { module.hardware.sound.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + security.rtkit.enable = true; + services.pipewire = { + enable = true; + pulse.enable = true; + wireplumber.enable = true; + alsa = { + enable = true; + support32Bit = true; + }; + lowLatency = { + enable = true; + quantum = 64; + rate = 48000; + }; + }; + }; +} + diff --git a/modules/host/misc/default.nix b/modules/host/misc/default.nix new file mode 100644 index 0000000..8de21cd --- /dev/null +++ b/modules/host/misc/default.nix @@ -0,0 +1,9 @@ +{ systemModules, lib, ... }: + +let hostProgramModulesPath = "${systemModules}/misc"; +in { + imports = builtins.filter (module: lib.pathIsDirectory module) + (map (module: "${hostProgramModulesPath}/${module}") + (builtins.attrNames (builtins.readDir hostProgramModulesPath))); +} + diff --git a/modules/host/misc/locales/default.nix b/modules/host/misc/locales/default.nix new file mode 100644 index 0000000..0462ddd --- /dev/null +++ b/modules/host/misc/locales/default.nix @@ -0,0 +1,18 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.misc.locales; +in { + options = { module.misc.locales.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + time.timeZone = "Asia/Chita"; # TIME + services.chrony.enable = true; # SYNC TIME + i18n = { # LOCALE LANG + defaultLocale = "en_US.UTF-8"; + supportedLocales = [ "all" ]; + }; + }; +} + diff --git a/modules/host/misc/minimal/default.nix b/modules/host/misc/minimal/default.nix new file mode 100644 index 0000000..a054e2b --- /dev/null +++ b/modules/host/misc/minimal/default.nix @@ -0,0 +1,21 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.misc.minimal; +in { + options = { module.misc.minimal.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + programs.command-not-found.enable = mkDefault false; + documentation = { # DISABLE MAN AND GUIDES + enable = mkDefault false; + doc.enable = mkDefault false; + info.enable = mkDefault false; + man.enable = mkDefault false; + nixos.enable = mkDefault false; + }; + + }; +} + diff --git a/modules/host/misc/power/default.nix b/modules/host/misc/power/default.nix new file mode 100644 index 0000000..48be126 --- /dev/null +++ b/modules/host/misc/power/default.nix @@ -0,0 +1,16 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.misc.power; +in { + options = { module.misc.power.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + powerManagement = { # POWER OPTIMIZATION + enable = true; + powertop.enable = true; + }; + }; +} + diff --git a/modules/host/misc/system76/default.nix b/modules/host/misc/system76/default.nix new file mode 100644 index 0000000..f4cdc4c --- /dev/null +++ b/modules/host/misc/system76/default.nix @@ -0,0 +1,25 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.misc.system76; +in { + options = { module.misc.system76.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + hardware.system76 = { # OPTIMIZATIONS + enableAll = true; + power-daemon.enable = true; + firmware-daemon.enable = true; + kernel-modules.enable = true; + }; + services.system76-scheduler = { # SCHEDULER + enable = true; + settings = { + cfsProfiles.enable = true; + processScheduler.pipewireBoost.enable = true; + }; + }; + }; +} + diff --git a/modules/host/misc/torrserver/default.nix b/modules/host/misc/torrserver/default.nix new file mode 100644 index 0000000..85ae4c0 --- /dev/null +++ b/modules/host/misc/torrserver/default.nix @@ -0,0 +1,27 @@ +{ lib, config, ... }: + +with lib; + +let + cfg = config.module.misc.torrserver; + torr = pkgs.callPackage ./package.nix { }; +in { + options = { module.misc.torrserver.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + systemd.services = { + torrserver = { # TORRSERVER + enable = true; + after = [ "multi-user.target" "network.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + ExecStart = "${torr}/bin/torrserver"; + Restart = "on-failure"; + Type = "simple"; + TimeoutSec = 30; + }; + }; + }; + }; +} + diff --git a/modules/host/misc/torrserver/package.nix b/modules/host/misc/torrserver/package.nix new file mode 100644 index 0000000..d1a29d0 --- /dev/null +++ b/modules/host/misc/torrserver/package.nix @@ -0,0 +1,27 @@ +{ lib, stdenv, fetchurl, autoPatchelfHook }: +let + version = "134"; + hash = "sha256-WDygG9aGnD20nGxtG0t+T2KEwbJ+fZ0uRaCndirrsXI="; +in stdenv.mkDerivation { + name = "torrserver"; + dontUnpack = true; + + src = fetchurl { + url = + "https://github.com/YouROK/TorrServer/releases/download/MatriX.${version}/TorrServer-linux-amd64"; + sha256 = "${hash}"; + }; + + nativeBuildInputs = [ autoPatchelfHook ]; + + installPhase = + " mkdir -p $out/bin\n cp $src $out/bin/torrserver\n chmod +x $out/bin/torrserver\n"; + + meta = with lib; { + description = "Torrserver"; + homepage = "https://github.com/YouROK/TorrServer"; + license = licenses.unlicense; + meta.platforms = platforms.all; + mainProgram = "torrserver"; + }; +} diff --git a/modules/host/misc/users/default.nix b/modules/host/misc/users/default.nix new file mode 100644 index 0000000..2821706 --- /dev/null +++ b/modules/host/misc/users/default.nix @@ -0,0 +1,30 @@ +{ pkgs, lib, config, username, ... }: + +with lib; + +let cfg = config.module.misc.users; +in { + options = { module.misc.users.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + users = { + mutableUsers = false; + defaultUserShell = pkgs.fish; + groups = { ${username} = { gid = 1000; }; }; + users = { + root.useDefaultShell = true; + ${username} = { + uid = 1000; + home = "/home/${username}"; + group = "${username}"; + useDefaultShell = true; + createHome = true; + isSystemUser = true; + extraGroups = + [ "video" "audio" "networkmanager" "wheel" "docker" "libvirtd" ]; + }; + }; + }; + }; +} + diff --git a/modules/host/misc/variables/default.nix b/modules/host/misc/variables/default.nix new file mode 100644 index 0000000..6ec5eba --- /dev/null +++ b/modules/host/misc/variables/default.nix @@ -0,0 +1,30 @@ +{ lib, config, username, ... }: + +with lib; + +let cfg = config.module.misc.variables; +in { + options = { module.misc.variables.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + environment.variables = { + QT_QPA_PLATFORM = "wayland"; + SDL_VIDEODRIVER = "wayland"; + CLUTTER_BACKEND = "wayland"; + GDK_BACKEND = "wayland"; + NIXPKGS_ALLOW_UNFREE = "1"; + NIXPKGS_ALLOW_INSECURE = "1"; + MOZ_ENABLE_WAYLAND = "1"; + XDG_SESSION_TYPE = "wayland"; + NIXOS_OZONE_WL = "1"; + }; + + environment.sessionVariables = { + MOZ_LEGACY_PROFILES = "1"; + FLAKE = "/home/${username}/.flake"; + QT_QPA_PLATFORMTHEME = "gtk3"; + TDESKTOP_I_KNOW_ABOUT_GTK_INCOMPATIBILITY = "1"; + }; + }; +} + diff --git a/modules/host/misc/zapret/default.nix b/modules/host/misc/zapret/default.nix new file mode 100644 index 0000000..23fd87e --- /dev/null +++ b/modules/host/misc/zapret/default.nix @@ -0,0 +1,57 @@ +{ lib, config, pkgs, ... }: + +with lib; + +let cfg = config.module.misc.zapret; +in { + options = { module.misc.zapret.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + systemd = { + services = { + zapret = { + wantedBy = [ "multi-user.target" ]; + requires = [ "network.target" ]; + path = with pkgs; [ iptables nftables zapret ipset curl gawk ]; + serviceConfig = { + Type = "forking"; + Restart = "no"; + TimeoutSec = "30sec"; + IgnoreSIGPIPE = "no"; + KillMode = "none"; + GuessMainPID = "no"; + ExecStart = "${pkgs.zapret}/bin/zapret start"; + ExecStop = "${pkgs.zapret}/bin/zapret stop"; + EnvironmentFile = pkgs.writeText "zapret-environment" '' + FWTYPE="iptables" + SET_MAXELEM=522288 + IPSET_OPT="hashsize 262144 maxelem $SET_MAXELEM" + AUTOHOSTLIST_RETRANS_THRESHOLD=3 + AUTOHOSTLIST_FAIL_THRESHOLD=3 + AUTOHOSTLIST_FAIL_TIME=60 + AUTOHOSTLIST_DEBUGLOG=0 + MDIG_THREADS=30 + GZIP_LISTS=1 + + MODE=nfqws + MODE_HTTP=1 + MODE_HTTP_KEEPALIVE=0 + MODE_HTTPS=1 + MODE_QUIC=0 + MODE_FILTER=none + + DESYNC_MARK=0x40000000 + DESYNC_MARK_POSTNAT=0x20000000 + NFQWS_OPT_DESYNC="--dpi-desync=fake,split2 --dpi-desync-ttl=3" + TPWS_OPT="--hostspell=HOST --split-http-req=method --split-pos=3 --oob" + FLOWOFFLOAD=donttouch + INIT_APPLY_FW=1 + DISABLE_IPV6=0 + ''; + }; + }; + }; + }; + }; +} + diff --git a/modules/host/programs/default.nix b/modules/host/programs/default.nix new file mode 100644 index 0000000..e8b165b --- /dev/null +++ b/modules/host/programs/default.nix @@ -0,0 +1,9 @@ +{ systemModules, lib, ... }: + +let hostProgramModulesPath = "${systemModules}/programs"; +in { + imports = builtins.filter (module: lib.pathIsDirectory module) + (map (module: "${hostProgramModulesPath}/${module}") + (builtins.attrNames (builtins.readDir hostProgramModulesPath))); +} + diff --git a/modules/host/programs/fish/default.nix b/modules/host/programs/fish/default.nix new file mode 100644 index 0000000..655be43 --- /dev/null +++ b/modules/host/programs/fish/default.nix @@ -0,0 +1,11 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.programs.fish; +in { + options = { module.programs.fish.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { programs.fish.enable = true; }; +} + diff --git a/modules/host/programs/git/default.nix b/modules/host/programs/git/default.nix new file mode 100644 index 0000000..c9582c5 --- /dev/null +++ b/modules/host/programs/git/default.nix @@ -0,0 +1,16 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.programs.git; +in { + options = { module.programs.git.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + programs.git = { + enable = true; + package = pkgs.gitMinimal; + }; + }; +} + diff --git a/modules/host/programs/hm/default.nix b/modules/host/programs/hm/default.nix new file mode 100644 index 0000000..05ff5cf --- /dev/null +++ b/modules/host/programs/hm/default.nix @@ -0,0 +1,17 @@ +{ inputs, lib, config, ... }: + +with lib; + +let cfg = config.module.programs.hm; +in { + options = { module.programs.hm.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + extraSpecialArgs = { inherit inputs; }; + }; + }; +} + diff --git a/modules/host/programs/hyprland/default.nix b/modules/host/programs/hyprland/default.nix new file mode 100644 index 0000000..468791f --- /dev/null +++ b/modules/host/programs/hyprland/default.nix @@ -0,0 +1,16 @@ +{ inputs, pkgs, lib, config, ... }: + +with lib; + +let cfg = config.module.programs.hyprland; +in { + options = { module.programs.hyprland.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + programs.hyprland = { + enable = true; + package = inputs.hyprland.packages.${pkgs.system}.hyprland; + }; + }; +} + diff --git a/modules/host/programs/light/default.nix b/modules/host/programs/light/default.nix new file mode 100644 index 0000000..410719c --- /dev/null +++ b/modules/host/programs/light/default.nix @@ -0,0 +1,11 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.programs.light; +in { + options = { module.programs.light.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { programs.light.enable = true; }; +} + diff --git a/modules/host/programs/nh/default.nix b/modules/host/programs/nh/default.nix new file mode 100644 index 0000000..430022d --- /dev/null +++ b/modules/host/programs/nh/default.nix @@ -0,0 +1,20 @@ +{ lib, config, username, ... }: + +with lib; + +let cfg = config.module.programs.nh; +in { + options = { module.programs.nh.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + programs.nh = { + enable = true; + flake = "/home/${username}/.flake"; + clean = { + enable = true; + extraArgs = "--keep-since 3d --keep 3"; + }; + }; + }; +} + diff --git a/modules/host/programs/packages/default.nix b/modules/host/programs/packages/default.nix new file mode 100644 index 0000000..92ffd77 --- /dev/null +++ b/modules/host/programs/packages/default.nix @@ -0,0 +1,13 @@ +{ pkgs, lib, config, ... }: + +with lib; + +let cfg = config.module.programs.packages; +in { + options = { module.programs.packages.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + environment.systemPackages = with pkgs; [ helix killall ]; + }; +} + diff --git a/modules/host/programs/steam/default.nix b/modules/host/programs/steam/default.nix new file mode 100644 index 0000000..1d6784a --- /dev/null +++ b/modules/host/programs/steam/default.nix @@ -0,0 +1,28 @@ +{ pkgs, lib, config, ... }: + +with lib; + +let cfg = config.module.programs.steam; +in { + options = { module.programs.steam.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + hardware.xone.enable = true; + programs = { + gamescope.enable = true; + steam = { # GAMING + enable = true; + package = pkgs.steam.override { + extraEnv = { + MANGOHUD = true; + OBS_VKCAPTURE = true; + RADV_TEX_ANISO = 16; + }; + }; + extraCompatPackages = with pkgs; [ proton-ge-bin ]; + protontricks.enable = true; + }; + }; + }; +} + diff --git a/modules/host/services/autocpu/default.nix b/modules/host/services/autocpu/default.nix new file mode 100644 index 0000000..35c1192 --- /dev/null +++ b/modules/host/services/autocpu/default.nix @@ -0,0 +1,28 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.services.autocpu; +in { + options = { module.services.autocpu.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + services.auto-cpufreq = { + enable = true; + settings = { + charger = { # AC MODE + governor = "performance"; + turbo = "auto"; + }; + battery = { # BAT MODE + governor = "powersave"; + turbo = "auto"; + energy_perf_bias = "balance_power"; + platform_profile = "low-power"; + enable_thresholds = true; + }; + }; + }; + }; +} + diff --git a/modules/host/services/dbus/default.nix b/modules/host/services/dbus/default.nix new file mode 100644 index 0000000..43e7ddb --- /dev/null +++ b/modules/host/services/dbus/default.nix @@ -0,0 +1,11 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.services.dbus; +in { + options = { module.services.dbus.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { services.dbus.implementation = "broker"; }; +} + diff --git a/modules/host/services/default.nix b/modules/host/services/default.nix new file mode 100644 index 0000000..750f152 --- /dev/null +++ b/modules/host/services/default.nix @@ -0,0 +1,9 @@ +{ systemModules, lib, ... }: + +let hostServicesModulesPath = "${systemModules}/services"; +in { + imports = builtins.filter (module: lib.pathIsDirectory module) + (map (module: "${hostServicesModulesPath}/${module}") + (builtins.attrNames (builtins.readDir hostServicesModulesPath))); +} + diff --git a/modules/host/services/getty/default.nix b/modules/host/services/getty/default.nix new file mode 100644 index 0000000..954ff61 --- /dev/null +++ b/modules/host/services/getty/default.nix @@ -0,0 +1,16 @@ +{ lib, config, username, ... }: + +with lib; + +let cfg = config.module.services.getty; +in { + options = { module.services.getty.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + services.getty = { + autologinUser = username; + greetingLine = "Good day my lord ahhhh"; + }; + }; +} + diff --git a/modules/host/services/gvfs/default.nix b/modules/host/services/gvfs/default.nix new file mode 100644 index 0000000..904cf0c --- /dev/null +++ b/modules/host/services/gvfs/default.nix @@ -0,0 +1,11 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.services.gvfs; +in { + options = { module.services.gvfs.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { services.gvfs.enable = true; }; +} + diff --git a/modules/host/services/laptop/default.nix b/modules/host/services/laptop/default.nix new file mode 100644 index 0000000..01adc3a --- /dev/null +++ b/modules/host/services/laptop/default.nix @@ -0,0 +1,63 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.services.tlp; +in { + options = { module.services.tlp.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + services = { + thermald.enable = true; + upower.enable = true; + fprintd = { # FINGER PRINT + enable = true; + package = pkgs.fprintd-tod; + tod = { + enable = true; + driver = pkgs.libfprint-2-tod1-vfs0090; + }; + }; + tlp = { + enable = true; + + settings = { + PLATFORM_PROFILE_ON_AC = "performance"; + PLATFORM_PROFILE_ON_BAT = "balanced"; + + # CPU + CPU_SCALING_GOVERNOR_ON_AC = "performance"; + CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; + + CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; + CPU_ENERGY_PERF_POLICY_ON_BAT = "balance_performance"; + + CPU_BOOST_ON_AC = 1; + CPU_BOOST_ON_BAT = 0; + + CPU_MIN_PERF_ON_AC = 0; + CPU_MAX_PERF_ON_AC = 100; + CPU_MIN_PERF_ON_BAT = 0; + CPU_MAX_PERF_ON_BAT = 40; + + # NETWORKING + WIFI_PWR_ON_AC = "off"; + WIFI_PWR_ON_BAT = "on"; + + # GRAPHICS + RADEON_DPM_STATE_ON_AC = "performance"; + RADEON_DPM_STATE_ON_BAT = "battery"; + RADEON_POWER_PROFILE_ON_AC = "default"; + RADEON_POWER_PROFILE_ON_BAT = "default"; + + # IDK + TLP_DEFAULT_MODE = "BAT"; + RUNTIME_PM_ON_AC = "auto"; + RUNTIME_PM_ON_BAT = "auto"; + USB_AUTOSUSPEND = 0; + }; + }; + }; + }; +} + diff --git a/modules/host/services/polkit/default.nix b/modules/host/services/polkit/default.nix new file mode 100644 index 0000000..1f94802 --- /dev/null +++ b/modules/host/services/polkit/default.nix @@ -0,0 +1,11 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.services.polkit; +in { + options = { module.services.polkit.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { security.polkit.enable = true; }; +} + diff --git a/modules/host/services/printing/default.nix b/modules/host/services/printing/default.nix new file mode 100644 index 0000000..25828ec --- /dev/null +++ b/modules/host/services/printing/default.nix @@ -0,0 +1,11 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.services.printing; +in { + options = { module.services.printing.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { services.printing.enable = true; }; +} + diff --git a/modules/host/services/syncthing/default.nix b/modules/host/services/syncthing/default.nix new file mode 100644 index 0000000..47e65b7 --- /dev/null +++ b/modules/host/services/syncthing/default.nix @@ -0,0 +1,18 @@ +{ lib, config, username, ... }: + +with lib; + +let cfg = config.module.services.syncthing; +in { + options = { module.services.syncthing.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + services.syncthing = { + enable = false; + user = username; + dataDir = "/home/${username}/.obsidian/obsidian"; + configDir = "/home/${username}/.config/syncthing"; + }; + }; +} + diff --git a/modules/host/services/tailscale/default.nix b/modules/host/services/tailscale/default.nix new file mode 100644 index 0000000..ab8e7da --- /dev/null +++ b/modules/host/services/tailscale/default.nix @@ -0,0 +1,18 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.services.tailscale; +in { + options = { module.services.tailscale.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + services = { + tailscale = { # OWN VPN NETWORK + enable = true; + useRoutingFeatures = "both"; + }; + }; + }; +} + diff --git a/modules/host/services/xserver/default.nix b/modules/host/services/xserver/default.nix new file mode 100644 index 0000000..013c494 --- /dev/null +++ b/modules/host/services/xserver/default.nix @@ -0,0 +1,23 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.services.xserver; +in { + options = { module.services.xserver.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + services = { + xserver = { + enable = true; + libinput.enable = true; + xkb = { + layout = "us"; + variant = "qwerty"; + options = "grp:caps_toggle"; + }; + }; + }; + }; +} + diff --git a/modules/host/services/zram/default.nix b/modules/host/services/zram/default.nix new file mode 100644 index 0000000..43b45de --- /dev/null +++ b/modules/host/services/zram/default.nix @@ -0,0 +1,19 @@ +{ lib, config, ... }: + +with lib; + +let cfg = config.module.services.zram; +in { + options = { module.services.zram.enable = mkEnableOption ""; }; + + config = mkIf cfg.enable { + zramSwap = { + enable = true; + priority = 1000; + algorithm = "zstd"; + swapDevices = 1; + memoryPercent = 100; + }; + }; +} +