From fc21bf9436aa4899c0a57ce4c84cd52a18359747 Mon Sep 17 00:00:00 2001 From: Gerg-L Date: Sat, 23 Sep 2023 21:55:56 -0400 Subject: [PATCH] treewide reformat --- flake.nix | 52 ++--- hosts/game-laptop/disko.nix | 61 +++--- hosts/game-laptop/main.nix | 40 ++-- hosts/game-laptop/prime.nix | 6 +- hosts/gerg-desktop/disko.nix | 92 ++++---- hosts/gerg-desktop/git.nix | 8 +- hosts/gerg-desktop/main.nix | 83 ++++---- hosts/gerg-desktop/services/gitea.nix | 10 +- hosts/gerg-desktop/services/minecraft.nix | 34 +-- hosts/gerg-desktop/services/miniflux.nix | 46 ++-- hosts/gerg-desktop/services/nextcloud.nix | 10 +- hosts/gerg-desktop/services/nginx.nix | 38 ++-- hosts/gerg-desktop/services/parrot.nix | 14 +- hosts/gerg-desktop/services/postgresql.nix | 18 +- hosts/gerg-desktop/services/searxng.nix | 15 +- hosts/gerg-desktop/spicetify.nix | 18 +- hosts/gerg-desktop/vfio.nix | 168 ++++++++------- hosts/gerg-desktop/zfs.nix | 38 ++-- hosts/iso/main.nix | 8 +- hosts/moms-laptop/disko.nix | 61 +++--- hosts/moms-laptop/main.nix | 44 ++-- hosts/moms-laptop/printing.nix | 26 ++- lib/default.nix | 114 +++++----- modules/DE/dwm.nix | 58 +++--- modules/DE/gnome.nix | 18 +- modules/DE/xfce.nix | 8 +- modules/DM/autoLogin.nix | 8 +- modules/DM/lightDM.nix | 6 +- modules/X11.nix | 34 +-- modules/boot.nix | 12 +- modules/builders.nix | 152 +++++++------- modules/hardware.nix | 33 ++- modules/keys.nix | 6 +- modules/misc.nix | 36 ++-- modules/nix.nix | 22 +- modules/shell.nix | 43 ++-- modules/sops.nix | 18 +- modules/systemd-boot/default.nix | 232 +++++++++++++-------- modules/theming.nix | 139 ++++++------ packages/fzf-tab.nix | 2 +- packages/images.nix | 33 +-- packages/papermc.nix | 24 ++- 42 files changed, 1012 insertions(+), 876 deletions(-) diff --git a/flake.nix b/flake.nix index bffe60a..784f1a0 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,7 @@ nix = { url = "github:NixOS/nix?ref=2.17-maintenance"; inputs.nixpkgs.follows = "unstable"; - }; + }; nixos-generators = { url = "github:nix-community/nixos-generators"; @@ -45,37 +45,29 @@ }; }; - outputs = inputs: let - lib = import ./lib inputs; - in - lib.gerg-utils { - allowUnfree = true; - } ( + outputs = + inputs: + let + lib = import ./lib inputs; + in + lib.gerg-utils { allowUnfree = true; } ( + { pkgs, system, ... }: { - pkgs, - system, - ... - }: { inherit lib; - nixosConfigurations = - lib.mkHosts - "x86_64-linux" - [ - "gerg-desktop" - "game-laptop" - "moms-laptop" - "iso" - ]; + nixosConfigurations = lib.mkHosts "x86_64-linux" [ + "gerg-desktop" + "game-laptop" + "moms-laptop" + "iso" + ]; nixosModules = lib.mkModules ./modules; - diskoConfigurations = - lib.mkDisko - [ - "gerg-desktop" - "game-laptop" - "moms-laptop" - ]; + diskoConfigurations = lib.mkDisko [ + "gerg-desktop" + "game-laptop" + "moms-laptop" + ]; formatter.${system} = pkgs.writeShellApplication { name = "lint"; runtimeInputs = [ @@ -94,11 +86,7 @@ ''; }; - devShells.${system}.default = pkgs.mkShell { - packages = [ - pkgs.sops - ]; - }; + devShells.${system}.default = pkgs.mkShell { packages = [ pkgs.sops ]; }; packages.${system} = lib.mkPackages ./packages pkgs; } diff --git a/hosts/game-laptop/disko.nix b/hosts/game-laptop/disko.nix index c73fe60..8b996a2 100644 --- a/hosts/game-laptop/disko.nix +++ b/hosts/game-laptop/disko.nix @@ -1,36 +1,39 @@ -{disko, ...}: { - imports = [disko.nixosModules.disko]; - disko.devices.disk.nvme0n1 = let - baseDevice = "/dev/disk/by-id/nvme-WDC_PC_SN530_SDBPNPZ-512G-1006_21311N802456"; - in { - device = baseDevice; - type = "disk"; - content = { - type = "gpt"; - partitions = { - ESP = { - device = "${baseDevice}-part1"; - start = "1MiB"; - end = "1GiB"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; +{ disko, ... }: +{ + imports = [ disko.nixosModules.disko ]; + disko.devices.disk.nvme0n1 = + let + baseDevice = "/dev/disk/by-id/nvme-WDC_PC_SN530_SDBPNPZ-512G-1006_21311N802456"; + in + { + device = baseDevice; + type = "disk"; + content = { + type = "gpt"; + partitions = { + ESP = { + device = "${baseDevice}-part1"; + start = "1MiB"; + end = "1GiB"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; }; - }; - root = { - device = "${baseDevice}-part2"; - start = "1GiB"; - end = "100%"; - type = "EF00"; - content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/"; + root = { + device = "${baseDevice}-part2"; + start = "1GiB"; + end = "100%"; + type = "EF00"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + }; }; }; }; }; - }; _file = ./disko.nix; } diff --git a/hosts/game-laptop/main.nix b/hosts/game-laptop/main.nix index 3b1a68f..14fe706 100644 --- a/hosts/game-laptop/main.nix +++ b/hosts/game-laptop/main.nix @@ -1,9 +1,11 @@ -_: { +_: +{ pkgs, config, lib, ... -}: { +}: +{ local = { remoteBuild.enable = true; DE.gnome.enable = true; @@ -25,23 +27,19 @@ _: { }; environment = { systemPackages = builtins.attrValues { - inherit - (pkgs) + inherit (pkgs) neovim heroic legendary-gl prismlauncher - pcmanfm #file manager - librewolf #best browser + pcmanfm # file manager + librewolf # best browser obs-studio vlc webcord blender - ; - inherit - (pkgs.libsForQt5) - kdenlive - ; + ; + inherit (pkgs.libsForQt5) kdenlive; }; etc = { "jdks/17".source = "${pkgs.openjdk17}/bin"; @@ -61,7 +59,7 @@ _: { useDefaultShell = true; uid = 1000; isNormalUser = true; - extraGroups = ["audio"]; + extraGroups = [ "audio" ]; initialHashedPassword = ""; }; "root" = { @@ -79,16 +77,18 @@ _: { hardware.bluetooth.enable = true; services.blueman.enable = true; boot = { - initrd.availableKernelModules = ["nvme" "xhci_pci" "ahci"]; - kernelModules = ["kvm-amd"]; + initrd.availableKernelModules = [ + "nvme" + "xhci_pci" + "ahci" + ]; + kernelModules = [ "kvm-amd" ]; kernelPackages = pkgs.linuxPackages_latest; }; - swapDevices = [ - { - device = "/swapfile"; - size = 16 * 1024; - } - ]; + swapDevices = [ { + device = "/swapfile"; + size = 16 * 1024; + } ]; system.stateVersion = "23.05"; _file = ./main.nix; diff --git a/hosts/game-laptop/prime.nix b/hosts/game-laptop/prime.nix index 5620329..8368a73 100644 --- a/hosts/game-laptop/prime.nix +++ b/hosts/game-laptop/prime.nix @@ -1,4 +1,6 @@ -_: {config, ...}: { +_: +{ config, ... }: +{ hardware.nvidia = { package = config.boot.kernelPackages.nvidiaPackages.latest; prime = { @@ -11,7 +13,7 @@ _: {config, ...}: { modesetting.enable = true; }; services.xserver = { - videoDrivers = ["nvidia"]; + videoDrivers = [ "nvidia" ]; #disable DPMS monitorSection = '' Option "DPMS" "false" diff --git a/hosts/gerg-desktop/disko.nix b/hosts/gerg-desktop/disko.nix index 33d4307..23bbb15 100644 --- a/hosts/gerg-desktop/disko.nix +++ b/hosts/gerg-desktop/disko.nix @@ -1,46 +1,58 @@ -{disko, ...}: {lib, ...}: { - imports = [disko.nixosModules.disko]; +{ disko, ... }: +{ lib, ... }: +{ + imports = [ disko.nixosModules.disko ]; - disko.devices.disk = lib.genAttrs ["0E" "22"] (name: let - fullName = "/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N${name}"; - in { - type = "disk"; - device = fullName; - content = { - type = "gpt"; - partitions = { - BOOT = { - device = "${fullName}-part1"; - type = "EF00"; - start = "0"; - end = "4G"; + disko.devices.disk = + lib.genAttrs + [ + "0E" + "22" + ] + ( + name: + let + fullName = "/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N${name}"; + in + { + type = "disk"; + device = fullName; content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/efi${name}"; + type = "gpt"; + partitions = { + BOOT = { + device = "${fullName}-part1"; + type = "EF00"; + start = "0"; + end = "4G"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/efi${name}"; + }; + }; + swap = { + device = "${fullName}-part2"; + start = "5G"; + end = "21G"; + content = { + type = "swap"; + randomEncryption = true; + }; + }; + zfsroot = { + device = "${fullName}-part3"; + start = "21G"; + end = "100%"; + content = { + type = "zfs"; + pool = "rpool"; + }; + }; + }; }; - }; - swap = { - device = "${fullName}-part2"; - start = "5G"; - end = "21G"; - content = { - type = "swap"; - randomEncryption = true; - }; - }; - zfsroot = { - device = "${fullName}-part3"; - start = "21G"; - end = "100%"; - content = { - type = "zfs"; - pool = "rpool"; - }; - }; - }; - }; - }); + } + ); disko.devices.zpool = { rpool = { diff --git a/hosts/gerg-desktop/git.nix b/hosts/gerg-desktop/git.nix index 0797270..a10ce38 100644 --- a/hosts/gerg-desktop/git.nix +++ b/hosts/gerg-desktop/git.nix @@ -1,8 +1,6 @@ -_: { - pkgs, - config, - ... -}: { +_: +{ pkgs, config, ... }: +{ programs.git = { enable = true; package = pkgs.gitMinimal; diff --git a/hosts/gerg-desktop/main.nix b/hosts/gerg-desktop/main.nix index 65db071..5a609fe 100644 --- a/hosts/gerg-desktop/main.nix +++ b/hosts/gerg-desktop/main.nix @@ -1,8 +1,6 @@ -{nvim-flake, nixfmt, ...}: { - pkgs, - config, - ... -}: { +{ nvim-flake, nixfmt, ... }: +{ pkgs, config, ... }: +{ local = { remoteBuild.isBuilder = true; X11Programs = { @@ -18,11 +16,9 @@ enable = true; kmscon.enable = true; }; - allowedUnfree = [ - "nvidia-x11" - ]; + allowedUnfree = [ "nvidia-x11" ]; }; - boot.binfmt.emulatedSystems = ["aarch64-linux"]; + boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; hardware.nvidia = { package = config.boot.kernelPackages.nvidiaPackages.beta; nvidiaPersistenced = false; @@ -31,7 +27,10 @@ open = false; }; services.xserver = { - videoDrivers = ["nvidia" "amdgpu"]; + videoDrivers = [ + "nvidia" + "amdgpu" + ]; }; programs.direnv = { @@ -40,19 +39,24 @@ silent = true; }; - nix.settings.system-features = ["kvm" "big-parallel" "nixos-test" "benchmark"]; + nix.settings.system-features = [ + "kvm" + "big-parallel" + "nixos-test" + "benchmark" + ]; environment = { - systemPackages = let - fmt = pkgs.nixfmt.overrideAttrs { - version = "0.6.0-${nixfmt.shortRev}"; + systemPackages = + let + fmt = pkgs.nixfmt.overrideAttrs { + version = "0.6.0-${nixfmt.shortRev}"; - src = nixfmt; - }; - in + src = nixfmt; + }; + in builtins.attrValues { - inherit - (pkgs) + inherit (pkgs) bitwarden # store stuff qbittorrent # steal stuff pavucontrol # gui volume control @@ -69,13 +73,13 @@ nix-index element-desktop webcord - ; + ; inherit (nvim-flake.packages.${pkgs.system}) neovim; inherit fmt; lint = pkgs.writeShellApplication { name = "lint"; runtimeInputs = [ - fmt + fmt pkgs.deadnix pkgs.statix pkgs.fd @@ -99,9 +103,7 @@ }; }; - services.udev.packages = [ - pkgs.android-udev-rules - ]; + services.udev.packages = [ pkgs.android-udev-rules ]; programs.adb.enable = true; networking = { @@ -122,22 +124,16 @@ networks = { "enp11s0" = { name = "enp11s0"; - bridge = ["br0"]; + bridge = [ "br0" ]; linkConfig.RequiredForOnline = "enslaved"; }; "br0" = { name = "br0"; - address = [ - "192.168.1.4/24" - ]; - gateway = [ - "192.168.1.1" - ]; - dns = [ - "192.168.1.1" - ]; + address = [ "192.168.1.4/24" ]; + gateway = [ "192.168.1.1" ]; + dns = [ "192.168.1.1" ]; DHCP = "no"; - bridgeConfig = {}; + bridgeConfig = { }; linkConfig = { MACAddress = "D8:5E:D3:E5:47:90"; RequiredForOnline = "routable"; @@ -157,7 +153,12 @@ useDefaultShell = true; uid = 1000; isNormalUser = true; - extraGroups = ["wheel" "audio" "adbusers" "plugdev"]; + extraGroups = [ + "wheel" + "audio" + "adbusers" + "plugdev" + ]; openssh.authorizedKeys.keys = [ config.local.keys.gerg_gerg-phone config.local.keys.gerg_gerg-windows @@ -172,9 +173,15 @@ }; }; boot = { - kernelModules = ["amdgpu"]; + kernelModules = [ "amdgpu" ]; initrd = { - availableKernelModules = ["nvme" "xhci_pci" "ahci" "usbhid" "sd_mod"]; + availableKernelModules = [ + "nvme" + "xhci_pci" + "ahci" + "usbhid" + "sd_mod" + ]; includeDefaultModules = false; }; }; diff --git a/hosts/gerg-desktop/services/gitea.nix b/hosts/gerg-desktop/services/gitea.nix index 6fd11d5..06caa0e 100644 --- a/hosts/gerg-desktop/services/gitea.nix +++ b/hosts/gerg-desktop/services/gitea.nix @@ -1,10 +1,12 @@ -_: {config, ...}: { +_: +{ config, ... }: +{ users.users = { ${config.services.gitea.user} = { - openssh.authorizedKeys.keys = [config.local.keys.gerg_gerg-desktop]; - extraGroups = ["postgres"]; + openssh.authorizedKeys.keys = [ config.local.keys.gerg_gerg-desktop ]; + extraGroups = [ "postgres" ]; }; - ${config.services.nginx.user}.extraGroups = [config.services.gitea.group]; + ${config.services.nginx.user}.extraGroups = [ config.services.gitea.group ]; }; services.gitea = { enable = true; diff --git a/hosts/gerg-desktop/services/minecraft.nix b/hosts/gerg-desktop/services/minecraft.nix index aae653f..cd86ab3 100644 --- a/hosts/gerg-desktop/services/minecraft.nix +++ b/hosts/gerg-desktop/services/minecraft.nix @@ -1,11 +1,9 @@ -{self, ...}: { - pkgs, - lib, - ... -}: { +{ self, ... }: +{ pkgs, lib, ... }: +{ # I manually switch this sometimes config = lib.mkIf false { - networking.firewall.allowedTCPPorts = [25565]; + networking.firewall.allowedTCPPorts = [ 25565 ]; users.users.minecraft = { description = "Minecraft server service user"; @@ -14,10 +12,10 @@ isSystemUser = true; group = "minecraft"; }; - users.groups.minecraft = {}; + users.groups.minecraft = { }; systemd.sockets.minecraft-server = { - bindsTo = ["minecraft-server.service"]; + bindsTo = [ "minecraft-server.service" ]; socketConfig = { ListenFIFO = "/run/minecraft-server.stdin"; SocketMode = "0660"; @@ -31,10 +29,13 @@ systemd.services.minecraft-server = { enable = true; description = "Minecraft Server Service"; - wantedBy = ["multi-user.target"]; - requires = ["minecraft-server.socket"]; - after = ["network.target" "minecraft-server.socket"]; - path = [self.packages.${pkgs.system}.papermc]; + wantedBy = [ "multi-user.target" ]; + requires = [ "minecraft-server.socket" ]; + after = [ + "network.target" + "minecraft-server.socket" + ]; + path = [ self.packages.${pkgs.system}.papermc ]; script = '' minecraft-server \ -Xms8G \ @@ -70,8 +71,8 @@ StandardError = "journal"; # Hardening - CapabilityBoundingSet = [""]; - DeviceAllow = [""]; + CapabilityBoundingSet = [ "" ]; + DeviceAllow = [ "" ]; LockPersonality = true; PrivateDevices = true; PrivateTmp = true; @@ -84,7 +85,10 @@ ProtectKernelModules = true; ProtectKernelTunables = true; ProtectProc = "invisible"; - RestrictAddressFamilies = ["AF_INET" "AF_INET6"]; + RestrictAddressFamilies = [ + "AF_INET" + "AF_INET6" + ]; RestrictNamespaces = true; RestrictRealtime = true; RestrictSUIDSGID = true; diff --git a/hosts/gerg-desktop/services/miniflux.nix b/hosts/gerg-desktop/services/miniflux.nix index c7a1853..f8eb5bc 100644 --- a/hosts/gerg-desktop/services/miniflux.nix +++ b/hosts/gerg-desktop/services/miniflux.nix @@ -1,17 +1,23 @@ -_: { +_: +{ config, lib, pkgs, ... -}: { +}: +{ sops.secrets.minifluxenv.owner = "miniflux"; systemd.services = { miniflux = { description = "Miniflux service"; - wantedBy = ["multi-user.target"]; - requires = ["miniflux-dbsetup.service"]; - after = ["network.target" "postgresql.service" "miniflux-dbsetup.service"]; + wantedBy = [ "multi-user.target" ]; + requires = [ "miniflux-dbsetup.service" ]; + after = [ + "network.target" + "postgresql.service" + "miniflux-dbsetup.service" + ]; script = lib.getExe' pkgs.miniflux "miniflux"; serviceConfig = { @@ -20,8 +26,8 @@ _: { RuntimeDirectoryMode = "0770"; EnvironmentFile = config.sops.secrets.minifluxenv.path; # Hardening - CapabilityBoundingSet = [""]; - DeviceAllow = [""]; + CapabilityBoundingSet = [ "" ]; + DeviceAllow = [ "" ]; LockPersonality = true; MemoryDenyWriteExecute = true; PrivateDevices = true; @@ -35,12 +41,19 @@ _: { ProtectKernelModules = true; ProtectKernelTunables = true; ProtectProc = "invisible"; - RestrictAddressFamilies = ["AF_INET" "AF_INET6" "AF_UNIX"]; + RestrictAddressFamilies = [ + "AF_INET" + "AF_INET6" + "AF_UNIX" + ]; RestrictNamespaces = true; RestrictRealtime = true; RestrictSUIDSGID = true; SystemCallArchitectures = "native"; - SystemCallFilter = ["@system-service" "~@privileged"]; + SystemCallFilter = [ + "@system-service" + "~@privileged" + ]; UMask = "0077"; }; @@ -54,10 +67,15 @@ _: { }; miniflux-dbsetup = { description = "Miniflux database setup"; - requires = ["postgresql.service"]; - after = ["network.target" "postgresql.service"]; + requires = [ "postgresql.service" ]; + after = [ + "network.target" + "postgresql.service" + ]; script = '' - ${lib.getExe' config.services.postgresql.package "psql"} "miniflux" -c "CREATE EXTENSION IF NOT EXISTS hstore" + ${ + lib.getExe' config.services.postgresql.package "psql" + } "miniflux" -c "CREATE EXTENSION IF NOT EXISTS hstore" ''; serviceConfig = { Type = "oneshot"; @@ -72,11 +90,11 @@ _: { users = { miniflux = { group = "miniflux"; - extraGroups = ["postgres"]; + extraGroups = [ "postgres" ]; isSystemUser = true; uid = 377; }; - ${config.services.nginx.user}.extraGroups = ["miniflux"]; + ${config.services.nginx.user}.extraGroups = [ "miniflux" ]; }; }; } diff --git a/hosts/gerg-desktop/services/nextcloud.nix b/hosts/gerg-desktop/services/nextcloud.nix index 15d7a77..84a8d1f 100644 --- a/hosts/gerg-desktop/services/nextcloud.nix +++ b/hosts/gerg-desktop/services/nextcloud.nix @@ -1,11 +1,9 @@ -_: { - pkgs, - config, - ... -}: { +_: +{ pkgs, config, ... }: +{ sops.secrets.nextcloud.owner = "nextcloud"; - users.users.nextcloud.extraGroups = ["postgres"]; + users.users.nextcloud.extraGroups = [ "postgres" ]; services.nextcloud = { enable = true; diff --git a/hosts/gerg-desktop/services/nginx.nix b/hosts/gerg-desktop/services/nginx.nix index fdfecc1..76d1853 100644 --- a/hosts/gerg-desktop/services/nginx.nix +++ b/hosts/gerg-desktop/services/nginx.nix @@ -1,19 +1,20 @@ -_: { - config, - lib, - ... -}: { +_: +{ config, lib, ... }: +{ sops.secrets = - lib.genAttrs [ - "nixfu_ssl_cert" - "nixfu_ssl_key" - "gerg_ssl_key" - "gerg_ssl_cert" - ] - (_: { - owner = config.services.nginx.user; - inherit (config.services.nginx) group; - }); + lib.genAttrs + [ + "nixfu_ssl_cert" + "nixfu_ssl_key" + "gerg_ssl_key" + "gerg_ssl_cert" + ] + ( + _: { + owner = config.services.nginx.user; + inherit (config.services.nginx) group; + } + ); services.nginx = { enable = true; @@ -33,7 +34,7 @@ _: { forceSSL = true; sslCertificate = config.sops.secrets.nixfu_ssl_cert.path; sslCertificateKey = config.sops.secrets.nixfu_ssl_key.path; - serverAliases = ["www.nix-fu.com"]; + serverAliases = [ "www.nix-fu.com" ]; globalRedirect = "github.com/Gerg-L"; }; "search.gerg-l.com" = { @@ -62,6 +63,9 @@ _: { }; }; }; - networking.firewall.allowedTCPPorts = [80 443]; + networking.firewall.allowedTCPPorts = [ + 80 + 443 + ]; _file = ./nginx.nix; } diff --git a/hosts/gerg-desktop/services/parrot.nix b/hosts/gerg-desktop/services/parrot.nix index 7743ec9..735589c 100644 --- a/hosts/gerg-desktop/services/parrot.nix +++ b/hosts/gerg-desktop/services/parrot.nix @@ -1,15 +1,17 @@ -_: { +_: +{ pkgs, config, lib, ... -}: { - sops.secrets.discordenv = {}; +}: +{ + sops.secrets.discordenv = { }; systemd.services.parrot = { enable = true; - wantedBy = ["multi-user.target"]; - wants = ["network-online.target"]; - after = ["network-online.target"]; + wantedBy = [ "multi-user.target" ]; + wants = [ "network-online.target" ]; + after = [ "network-online.target" ]; script = lib.getExe pkgs.parrot; serviceConfig = { EnvironmentFile = config.sops.secrets.discordenv.path; diff --git a/hosts/gerg-desktop/services/postgresql.nix b/hosts/gerg-desktop/services/postgresql.nix index c667da8..164396d 100644 --- a/hosts/gerg-desktop/services/postgresql.nix +++ b/hosts/gerg-desktop/services/postgresql.nix @@ -1,8 +1,6 @@ -_: { - config, - pkgs, - ... -}: { +_: +{ config, pkgs, ... }: +{ services.postgresql = { enable = true; package = pkgs.postgresql_13; @@ -12,12 +10,10 @@ _: { "miniflux" config.services.gitea.database.user ]; - ensureUsers = [ - { - name = "miniflux"; - ensurePermissions."DATABASE miniflux" = "ALL PRIVILEGES"; - } - ]; + ensureUsers = [ { + name = "miniflux"; + ensurePermissions."DATABASE miniflux" = "ALL PRIVILEGES"; + } ]; settings.unix_socket_permissions = "0770"; }; diff --git a/hosts/gerg-desktop/services/searxng.nix b/hosts/gerg-desktop/services/searxng.nix index d6eaba6..3fb8de6 100644 --- a/hosts/gerg-desktop/services/searxng.nix +++ b/hosts/gerg-desktop/services/searxng.nix @@ -1,20 +1,17 @@ -_: { - config, - pkgs, - ... -}: { +_: +{ config, pkgs, ... }: +{ sops.secrets.searxngenv = { owner = "searx"; group = "searx"; }; - users.users.${config.services.nginx.user}.extraGroups = ["searx"]; + users.users.${config.services.nginx.user}.extraGroups = [ "searx" ]; services.searx = { enable = true; package = pkgs.searxng; #Later - /* - redisCreateLocally = true; - limiterSettings = {}; + /* redisCreateLocally = true; + limiterSettings = {}; */ runInUwsgi = true; uwsgiConfig = { diff --git a/hosts/gerg-desktop/spicetify.nix b/hosts/gerg-desktop/spicetify.nix index 8ea648e..407167a 100644 --- a/hosts/gerg-desktop/spicetify.nix +++ b/hosts/gerg-desktop/spicetify.nix @@ -1,17 +1,15 @@ -{spicetify-nix, ...}: {pkgs, ...}: let +{ spicetify-nix, ... }: +{ pkgs, ... }: +let spicePkgs = spicetify-nix.legacyPackages.${pkgs.system}; -in { - imports = [spicetify-nix.nixosModules.default]; - local.allowedUnfree = ["spotify"]; +in +{ + imports = [ spicetify-nix.nixosModules.default ]; + local.allowedUnfree = [ "spotify" ]; programs.spicetify = { enable = true; enabledExtensions = builtins.attrValues { - inherit - (spicePkgs.extensions) - adblock - hidePodcasts - shuffle - ; + inherit (spicePkgs.extensions) adblock hidePodcasts shuffle; }; theme = spicePkgs.themes.Comfy; colorScheme = "custom"; diff --git a/hosts/gerg-desktop/vfio.nix b/hosts/gerg-desktop/vfio.nix index a9666ac..2a25115 100644 --- a/hosts/gerg-desktop/vfio.nix +++ b/hosts/gerg-desktop/vfio.nix @@ -1,4 +1,5 @@ -_: { +_: +{ pkgs, lib, config, @@ -7,55 +8,61 @@ _: { ###TAKEN FROM HERE:https://github.com/NixOS/nixpkgs/blob/4787ebf7ae2ab071389be7ff86cf38edeee7e9f8/nixos/modules/services/x11/xserver.nix#L106-L136 let xcfg = config.services.xserver; - xserverbase = let - fontsForXServer = - config.fonts.packages - ++ [ + xserverbase = + let + fontsForXServer = config.fonts.packages ++ [ pkgs.xorg.fontadobe100dpi pkgs.xorg.fontadobe75dpi ]; - fontpath = - lib.optionalString (xcfg.fontPath != null) - ''FontPath "${xcfg.fontPath}"''; - in '' - echo 'Section "Files"' >> $out - echo ${fontpath} >> $out - for i in ${toString fontsForXServer}; do - if test "''${i:0:''${#NIX_STORE}}" == "$NIX_STORE"; then - for j in $(find $i -name fonts.dir); do - echo " FontPath \"$(dirname $j)\"" >> $out - done - fi - done - for i in $(find ${toString xcfg.modules} -type d); do - if test $(echo $i/*.so* | wc -w) -ne 0; then - echo " ModulePath \"$i\"" >> $out - fi - done - echo '${xcfg.filesSection}' >> $out - echo 'EndSection' >> $out - echo >> $out - ''; + fontpath = + lib.optionalString (xcfg.fontPath != null) + ''FontPath "${xcfg.fontPath}"''; + in + '' + echo 'Section "Files"' >> $out + echo ${fontpath} >> $out + for i in ${toString fontsForXServer}; do + if test "''${i:0:''${#NIX_STORE}}" == "$NIX_STORE"; then + for j in $(find $i -name fonts.dir); do + echo " FontPath \"$(dirname $j)\"" >> $out + done + fi + done + for i in $(find ${toString xcfg.modules} -type d); do + if test $(echo $i/*.so* | wc -w) -ne 0; then + echo " ModulePath \"$i\"" >> $out + fi + done + echo '${xcfg.filesSection}' >> $out + echo 'EndSection' >> $out + echo >> $out + ''; ###END OF TAKEN PART cfg_monitors = pkgs.writeShellApplication { name = "cfg_monitors"; - runtimeInputs = [pkgs.xorg.xrandr pkgs.xorg.xset pkgs.gawk pkgs.gnugrep]; + runtimeInputs = [ + pkgs.xorg.xrandr + pkgs.xorg.xset + pkgs.gawk + pkgs.gnugrep + ]; text = '' xrandr --output DP-0 --auto --mode 3440x1440 --rate 120 --primary --pos 0x0 xrandr --output "$(xrandr | grep -e 'HDMI.* connected.*'| awk '{ print$1 }')" --auto --mode 1920x1080 --rate 144 --set TearFree on --pos 3440x360 xset -dpms ''; }; -in { +in +{ environment.etc = { - "Xorg/1_mon.conf".source = pkgs.runCommand "1_mon.conf" {} ( + "Xorg/1_mon.conf".source = pkgs.runCommand "1_mon.conf" { } ( xserverbase + '' cat ${./1_mon.conf} >> $out '' ); - "Xorg/2_mon.conf".source = pkgs.runCommand "2_mon.conf" {} ( + "Xorg/2_mon.conf".source = pkgs.runCommand "2_mon.conf" { } ( xserverbase + '' cat ${./2_mon.conf} >> $out @@ -74,10 +81,9 @@ in { enable = true; qemu = { #don't hook evdev at vm start - package = pkgs.qemu_kvm.overrideAttrs (old: { - patches = - old.patches - ++ [ + package = pkgs.qemu_kvm.overrideAttrs ( + old: { + patches = old.patches ++ [ (pkgs.writeText "qemu.diff" '' diff --git a/ui/input-linux.c b/ui/input-linux.c index e572a2e..a9d76ba 100644 @@ -98,7 +104,8 @@ in { return; '') ]; - }); + } + ); runAsRoot = true; ovmf.enable = true; verbatimConfig = '' @@ -123,9 +130,14 @@ in { programs.dconf.enable = true; - users.users.gerg.extraGroups = ["kvm" "libvirtd"]; + users.users.gerg.extraGroups = [ + "kvm" + "libvirtd" + ]; - services.xserver.displayManager.xserverArgs = lib.mkAfter ["-config /etc/Xorg/active.conf"]; + services.xserver.displayManager.xserverArgs = lib.mkAfter [ + "-config /etc/Xorg/active.conf" + ]; services.xserver.displayManager.sessionCommands = lib.mkBefore '' if ! [ -e "/etc/Xorg/ONE_MONITOR" ] ; then ${lib.getExe cfg_monitors} @@ -133,47 +145,53 @@ in { ''; - systemd.tmpfiles.rules = let - qemuHook = pkgs.writeShellApplication { - name = "qemu-hook"; + systemd.tmpfiles.rules = + let + qemuHook = pkgs.writeShellApplication { + name = "qemu-hook"; - runtimeInputs = [pkgs.libvirt pkgs.systemd pkgs.kmod]; - text = '' - GUEST_NAME="$1" - OPERATION="$2" + runtimeInputs = [ + pkgs.libvirt + pkgs.systemd + pkgs.kmod + ]; + text = '' + GUEST_NAME="$1" + OPERATION="$2" - if [ "$GUEST_NAME" == "Windows" ]; then - if [ "$OPERATION" == "prepare" ]; then + if [ "$GUEST_NAME" == "Windows" ]; then + if [ "$OPERATION" == "prepare" ]; then + systemctl stop display-manager.service + modprobe -r -a nvidia_uvm nvidia_drm nvidia nvidia_modeset + virsh nodedev-detach pci_0000_01_00_0 + virsh nodedev-detach pci_0000_01_00_1 + systemctl set-property --runtime -- user.slice AllowedCPUs=8-15,24-31 + systemctl set-property --runtime -- system.slice AllowedCPUs=8-15,24-31 + systemctl set-property --runtime -- init.scope AllowedCPUs=8-15,24-31 + ln -fs /etc/Xorg/1_mon.conf /etc/Xorg/active.conf + touch /etc/Xorg/ONE_MONITOR + systemctl start display-manager.service + fi + if [ "$OPERATION" == "release" ]; then systemctl stop display-manager.service - modprobe -r -a nvidia_uvm nvidia_drm nvidia nvidia_modeset - virsh nodedev-detach pci_0000_01_00_0 - virsh nodedev-detach pci_0000_01_00_1 - systemctl set-property --runtime -- user.slice AllowedCPUs=8-15,24-31 - systemctl set-property --runtime -- system.slice AllowedCPUs=8-15,24-31 - systemctl set-property --runtime -- init.scope AllowedCPUs=8-15,24-31 - ln -fs /etc/Xorg/1_mon.conf /etc/Xorg/active.conf - touch /etc/Xorg/ONE_MONITOR + systemctl set-property --runtime -- user.slice AllowedCPUs=0-31 + systemctl set-property --runtime -- system.slice AllowedCPUs=0-31 + systemctl set-property --runtime -- init.scope AllowedCPUs=0-31 + virsh nodedev-reattach pci_0000_01_00_0 + virsh nodedev-reattach pci_0000_01_00_1 + modprobe -a nvidia_uvm nvidia_drm nvidia nvidia_modeset + ln -fs /etc/Xorg/2_mon.conf /etc/Xorg/active.conf + rm /etc/Xorg/ONE_MONITOR systemctl start display-manager.service + fi fi - if [ "$OPERATION" == "release" ]; then - systemctl stop display-manager.service - systemctl set-property --runtime -- user.slice AllowedCPUs=0-31 - systemctl set-property --runtime -- system.slice AllowedCPUs=0-31 - systemctl set-property --runtime -- init.scope AllowedCPUs=0-31 - virsh nodedev-reattach pci_0000_01_00_0 - virsh nodedev-reattach pci_0000_01_00_1 - modprobe -a nvidia_uvm nvidia_drm nvidia nvidia_modeset - ln -fs /etc/Xorg/2_mon.conf /etc/Xorg/active.conf - rm /etc/Xorg/ONE_MONITOR - systemctl start display-manager.service - fi - fi - ''; - }; - in [ - "L /etc/Xorg/active.conf - - - - /etc/Xorg/2_mon.conf" - "C /var/lib/libvirt/hooks/qemu - - - - ${lib.getExe qemuHook}" - "C /var/lib/libvirt/qemu/Windows.xml - - - - ${./Windows.xml}" - ]; + ''; + }; + in + [ + "L /etc/Xorg/active.conf - - - - /etc/Xorg/2_mon.conf" + "C /var/lib/libvirt/hooks/qemu - - - - ${lib.getExe qemuHook}" + "C /var/lib/libvirt/qemu/Windows.xml - - - - ${./Windows.xml}" + ]; _file = ./vfio.nix; } diff --git a/hosts/gerg-desktop/zfs.nix b/hosts/gerg-desktop/zfs.nix index 067f7b6..d988e4b 100644 --- a/hosts/gerg-desktop/zfs.nix +++ b/hosts/gerg-desktop/zfs.nix @@ -1,9 +1,11 @@ -_: { +_: +{ config, lib, pkgs, ... -}: { +}: +{ #link some stuff systemd.tmpfiles.rules = [ "L+ /etc/ssh/ssh_host_ed25519_key - - - - /persist/ssh/ssh_host_ed25519_key" @@ -16,11 +18,11 @@ _: { mode = "0644"; }; #make sure the sopskey is found - sops.age.sshKeyPaths = lib.mkForce ["/persist/ssh/ssh_host_ed25519_key"]; + sops.age.sshKeyPaths = lib.mkForce [ "/persist/ssh/ssh_host_ed25519_key" ]; fileSystems = { "/persist".neededForBoot = true; - "/efi22".options = ["nofail"]; - "/efi0E".options = ["nofail"]; + "/efi22".options = [ "nofail" ]; + "/efi0E".options = [ "nofail" ]; }; boot = { @@ -30,23 +32,29 @@ _: { }; kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; #disable hibernate and set cache max - kernelParams = ["nohibernate" "zfs.zfs_arc_max=17179869184"]; + kernelParams = [ + "nohibernate" + "zfs.zfs_arc_max=17179869184" + ]; initrd = { - supportedFilesystems = ["zfs" "vfat"]; + supportedFilesystems = [ + "zfs" + "vfat" + ]; #module for multiple swap devices - kernelModules = ["dm_mod"]; + kernelModules = [ "dm_mod" ]; #keyboard module for zfs password - availableKernelModules = ["hid_generic"]; + availableKernelModules = [ "hid_generic" ]; systemd.services.rollback = { - path = [pkgs.zfs]; + path = [ pkgs.zfs ]; serviceConfig = { Type = "oneshot"; RemainAfterExit = true; }; unitConfig.DefaultDependencies = "no"; - wantedBy = ["initrd.target"]; - after = ["zfs-import.target"]; - before = ["sysroot.mount"]; + wantedBy = [ "initrd.target" ]; + after = [ "zfs-import.target" ]; + before = [ "sysroot.mount" ]; script = '' zfs rollback -r rpool/root@empty zfs rollback -r rpool/var@empty @@ -73,11 +81,11 @@ _: { mirroredBoots = [ { path = "/efi22"; - devices = ["nodev"]; + devices = [ "nodev" ]; } { path = "/efi0E"; - devices = ["nodev"]; + devices = [ "nodev" ]; } ]; splashImage = null; diff --git a/hosts/iso/main.nix b/hosts/iso/main.nix index e83dc97..8d45a21 100644 --- a/hosts/iso/main.nix +++ b/hosts/iso/main.nix @@ -1,13 +1,11 @@ +{ disko, nixos-generators, ... }: { - disko, - nixos-generators, - ... -}: { lib, modulesPath, pkgs, ... -}: { +}: +{ ##Build wtih nix build .#nixosConfigurations.iso.config.formats.iso local = { hardware = { diff --git a/hosts/moms-laptop/disko.nix b/hosts/moms-laptop/disko.nix index 2038d7d..4456a33 100644 --- a/hosts/moms-laptop/disko.nix +++ b/hosts/moms-laptop/disko.nix @@ -1,36 +1,39 @@ -{disko, ...}: { - imports = [disko.nixosModules.disko]; - disko.devices.disk.sda = let - baseDevice = "/dev/disk/by-id/ata-WDC_WDS240G2G0A-00JH30_180936803144"; - in { - device = baseDevice; - type = "disk"; - content = { - type = "gpt"; - partitions = { - ESP = { - device = "${baseDevice}-part1"; - start = "1MiB"; - end = "1GiB"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; +{ disko, ... }: +{ + imports = [ disko.nixosModules.disko ]; + disko.devices.disk.sda = + let + baseDevice = "/dev/disk/by-id/ata-WDC_WDS240G2G0A-00JH30_180936803144"; + in + { + device = baseDevice; + type = "disk"; + content = { + type = "gpt"; + partitions = { + ESP = { + device = "${baseDevice}-part1"; + start = "1MiB"; + end = "1GiB"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; }; - }; - root = { - device = "${baseDevice}-part2"; - start = "1GiB"; - end = "100%"; - type = "EF00"; - content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/"; + root = { + device = "${baseDevice}-part2"; + start = "1GiB"; + end = "100%"; + type = "EF00"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + }; }; }; }; }; - }; _file = ./disko.nix; } diff --git a/hosts/moms-laptop/main.nix b/hosts/moms-laptop/main.nix index 15533cb..28b8549 100644 --- a/hosts/moms-laptop/main.nix +++ b/hosts/moms-laptop/main.nix @@ -1,9 +1,11 @@ -_: { +_: +{ lib, pkgs, config, ... -}: { +}: +{ local = { remoteBuild.enable = true; DM = { @@ -19,18 +21,17 @@ _: { }; environment.systemPackages = builtins.attrValues { - inherit - (pkgs) + inherit (pkgs) neovim vlc nomacs rsync - pavucontrol #gui volume control - librewolf #best browser + pavucontrol # gui volume control + librewolf # best browser chromium - ; + ; }; - services.xserver.videoDrivers = ["intel"]; + services.xserver.videoDrivers = [ "intel" ]; networking.networkmanager.enable = true; @@ -45,7 +46,10 @@ _: { useDefaultShell = true; uid = 1000; isNormalUser = true; - extraGroups = ["networkmanager" "audio"]; + extraGroups = [ + "networkmanager" + "audio" + ]; initialHashedPassword = ""; }; "root" = { @@ -62,8 +66,16 @@ _: { }; services.openssh.settings.PermitRootLogin = lib.mkForce "prohibit-password"; boot = { - initrd.availableKernelModules = ["xhci-pci" "ehci-pci" "ahci" "usbhid" "sd_mod" "sr_mod" "rtsx_usb_sdmmc"]; - kernelModules = ["kvm-intel"]; + initrd.availableKernelModules = [ + "xhci-pci" + "ehci-pci" + "ahci" + "usbhid" + "sd_mod" + "sr_mod" + "rtsx_usb_sdmmc" + ]; + kernelModules = [ "kvm-intel" ]; }; systemd.user.tmpfiles.users.jo.rules = [ "L+ %h/Desktop/gimp.desktop - - - - ${pkgs.gimp}/share/applications/gimp.desktop" @@ -79,11 +91,9 @@ _: { system.stateVersion = "23.05"; - swapDevices = [ - { - device = "/swapfile"; - size = 8 * 1024; - } - ]; + swapDevices = [ { + device = "/swapfile"; + size = 8 * 1024; + } ]; _file = ./main.nix; } diff --git a/hosts/moms-laptop/printing.nix b/hosts/moms-laptop/printing.nix index 90a63cf..856615e 100644 --- a/hosts/moms-laptop/printing.nix +++ b/hosts/moms-laptop/printing.nix @@ -1,23 +1,31 @@ -_: {pkgs, ...}: let - xsane = - pkgs.xsane.override {gimpSupport = true;}; -in { - local.allowedUnfree = ["hplip"]; +_: +{ pkgs, ... }: +let + xsane = pkgs.xsane.override { gimpSupport = true; }; +in +{ + local.allowedUnfree = [ "hplip" ]; environment.systemPackages = [ xsane pkgs.gimp pkgs.libreoffice ]; - users.users.jo.extraGroups = ["scanner" "lp" "cups"]; + users.users.jo.extraGroups = [ + "scanner" + "lp" + "cups" + ]; hardware.sane = { enable = true; - extraBackends = [pkgs.hplipWithPlugin]; + extraBackends = [ pkgs.hplipWithPlugin ]; }; - systemd.user.tmpfiles.users.jo.rules = ["L %h/.config/GIMP/2.10/plug-ins/xsane - - - - ${xsane}"]; + systemd.user.tmpfiles.users.jo.rules = [ + "L %h/.config/GIMP/2.10/plug-ins/xsane - - - - ${xsane}" + ]; services = { printing = { enable = true; - drivers = [pkgs.hplipWithPlugin]; + drivers = [ pkgs.hplipWithPlugin ]; }; }; _file = ./printing.nix; diff --git a/lib/default.nix b/lib/default.nix index e19d85b..1026527 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,82 +1,84 @@ -inputs @ { - unstable, - self, - ... -}: let +inputs@{ unstable, self, ... }: +let inherit (unstable) lib; - listNixFilesRecursive = path: - builtins.filter (lib.hasSuffix "nix") - (lib.filesystem.listFilesRecursive path); + listNixFilesRecursive = + path: + builtins.filter (lib.hasSuffix "nix") (lib.filesystem.listFilesRecursive path); - importAll = path: - map - (module: (import module inputs)) - (listNixFilesRecursive path); + importAll = + path: map (module: (import module inputs)) (listNixFilesRecursive path); - mkModules = path: + mkModules = + path: lib.listToAttrs ( - map ( - name: { + map + (name: { name = lib.pipe name [ toString (lib.removeSuffix ".nix") (lib.removePrefix "${toString path}/") ]; value = import name inputs; - } - ) - (listNixFilesRecursive path) + }) + (listNixFilesRecursive path) ); -in { +in +{ inherit importAll mkModules listNixFilesRecursive; - gerg-utils = config: f: - lib.foldr lib.recursiveUpdate {} - (map (system: - f { - inherit system; - pkgs = - if config == {} - then unstable.legacyPackages.${system} - else - import unstable { - inherit system config; - }; - }) ["x86_64-linux"]); + gerg-utils = + config: f: + lib.foldr lib.recursiveUpdate { } ( + map + ( + system: + f { + inherit system; + pkgs = + if config == { } then + unstable.legacyPackages.${system} + else + import unstable { inherit system config; } + ; + } + ) + [ "x86_64-linux" ] + ); #"x86_64-darwin" "aarch64-linux" "aarch64-darwin" - mkHosts = system: names: + mkHosts = + system: names: lib.genAttrs names ( name: # Whats lib.nixosSystem? never heard of her - lib.evalModules { - specialArgs.modulesPath = "${unstable}/nixos/modules"; + lib.evalModules { + specialArgs.modulesPath = "${unstable}/nixos/modules"; - modules = - builtins.attrValues self.nixosModules - ++ importAll "${self}/hosts/${name}" - ++ [ - { - networking.hostName = name; - nixpkgs.hostPlatform = system; - } - ] - ++ (import "${unstable}/nixos/modules/module-list.nix"); - } - ); - mkDisko = names: - lib.genAttrs names ( - name: (import "${self}/hosts/${name}/disko.nix" inputs) + modules = + builtins.attrValues self.nixosModules + ++ importAll "${self}/hosts/${name}" + ++ [ { + networking.hostName = name; + nixpkgs.hostPlatform = system; + } ] + ++ (import "${unstable}/nixos/modules/module-list.nix") + ; + } ); + mkDisko = + names: + lib.genAttrs names (name: (import "${self}/hosts/${name}/disko.nix" inputs)); - mkPackages = path: pkgs: + mkPackages = + path: pkgs: builtins.listToAttrs ( - map (module: { - name = lib.removeSuffix ".nix" (builtins.baseNameOf module); - value = pkgs.callPackage module {}; - }) - (listNixFilesRecursive path) + map + (module: { + name = lib.removeSuffix ".nix" (builtins.baseNameOf module); + value = pkgs.callPackage module { }; + }) + (listNixFilesRecursive path) ); _file = ./default.nix; } diff --git a/modules/DE/dwm.nix b/modules/DE/dwm.nix index ee33b1c..61fc712 100644 --- a/modules/DE/dwm.nix +++ b/modules/DE/dwm.nix @@ -1,13 +1,11 @@ +{ suckless, self, ... }: { - suckless, - self, - ... -}: { pkgs, config, lib, ... -}: { +}: +{ options.local.DE.dwm.enable = lib.mkEnableOption ""; config = lib.mkIf config.local.DE.dwm.enable { @@ -16,43 +14,37 @@ enable = true; displayManager = { sessionCommands = '' - ${lib.getExe pkgs.feh} --bg-center "${self.packages.${pkgs.system}.images}/recursion.png" + ${lib.getExe pkgs.feh} --bg-center "${ + self.packages.${pkgs.system}.images + }/recursion.png" ${lib.getExe pkgs.numlockx} ${lib.getExe pkgs.picom} & ''; defaultSession = "none+dwm"; }; - windowManager.session = - [ - { - name = "dwm"; - start = '' - update_time () { - while : - do - sleep 1 - xsetroot -name "$(date +"%I:%M %p")" - done - } + windowManager.session = [ { + name = "dwm"; + start = '' + update_time () { + while : + do + sleep 1 + xsetroot -name "$(date +"%I:%M %p")" + done + } - dont_stop() { - while type dwm >/dev/null ; do dwm && continue || break ; done - } + dont_stop() { + while type dwm >/dev/null ; do dwm && continue || break ; done + } - update_time & - dont_stop & - waitPID=$! - ''; - } - ]; + update_time & + dont_stop & + waitPID=$! + ''; + } ]; }; environment.systemPackages = builtins.attrValues { - inherit - (suckless.packages.${pkgs.system}) - dmenu - dwm - st - ; + inherit (suckless.packages.${pkgs.system}) dmenu dwm st; }; }; _file = ./dwm.nix; diff --git a/modules/DE/gnome.nix b/modules/DE/gnome.nix index f785833..8180076 100644 --- a/modules/DE/gnome.nix +++ b/modules/DE/gnome.nix @@ -1,24 +1,24 @@ -_: { +_: +{ config, lib, pkgs, ... -}: { +}: +{ options.local.DE.gnome.enable = lib.mkEnableOption ""; config = lib.mkIf config.local.DE.gnome.enable { environment = { - systemPackages = [pkgs.gnome.gnome-calculator]; + systemPackages = [ pkgs.gnome.gnome-calculator ]; gnome.excludePackages = builtins.attrValues { - inherit - (pkgs) + inherit (pkgs) gnome-photos gnome-tour gnome-text-editor gnome-online-accounts - ; - inherit - (pkgs.gnome) + ; + inherit (pkgs.gnome) gnome-weather gnome-shell gnome-disk-utility @@ -38,7 +38,7 @@ _: { iagno # go game hitori # sudoku game atomix # puzzle game - ; + ; }; }; diff --git a/modules/DE/xfce.nix b/modules/DE/xfce.nix index ccaafe8..469b3e4 100644 --- a/modules/DE/xfce.nix +++ b/modules/DE/xfce.nix @@ -1,13 +1,15 @@ -_: { +_: +{ config, lib, pkgs, ... -}: { +}: +{ options.local.DE.xfce.enable = lib.mkEnableOption ""; config = lib.mkIf config.local.DE.xfce.enable { - environment.systemPackages = [pkgs.xfce.xfce4-whiskermenu-plugin]; + environment.systemPackages = [ pkgs.xfce.xfce4-whiskermenu-plugin ]; services.xserver = { enable = true; desktopManager.xfce = { diff --git a/modules/DM/autoLogin.nix b/modules/DM/autoLogin.nix index 4180f7b..a8e0ba0 100644 --- a/modules/DM/autoLogin.nix +++ b/modules/DM/autoLogin.nix @@ -1,8 +1,6 @@ -_: { - config, - lib, - ... -}: { +_: +{ config, lib, ... }: +{ options.local.DM = { autoLogin = lib.mkEnableOption ""; loginUser = lib.mkOption { diff --git a/modules/DM/lightDM.nix b/modules/DM/lightDM.nix index da814c4..4bf9271 100644 --- a/modules/DM/lightDM.nix +++ b/modules/DM/lightDM.nix @@ -1,9 +1,11 @@ -{self, ...}: { +{ self, ... }: +{ config, lib, pkgs, ... -}: { +}: +{ options.local.DM.lightdm.enable = lib.mkEnableOption ""; config = lib.mkIf config.local.DM.lightdm.enable { diff --git a/modules/X11.nix b/modules/X11.nix index c4ba7c6..5058794 100644 --- a/modules/X11.nix +++ b/modules/X11.nix @@ -1,11 +1,14 @@ -_: { +_: +{ config, pkgs, lib, ... -}: let +}: +let cfg = config.local.X11Programs; -in { +in +{ options.local.X11Programs = { sxhkd.enable = lib.mkEnableOption ""; }; @@ -17,7 +20,7 @@ in { layout = "us"; libinput.enable = true; xautolock.enable = false; - excludePackages = [pkgs.xterm]; + excludePackages = [ pkgs.xterm ]; desktopManager.xterm.enable = false; }; } @@ -54,18 +57,17 @@ in { maim -s | xclip -selection clipboard -t image/png ''; in - lib.mkIf cfg.sxhkd.enable - { - environment.systemPackages = [ - pkgs.maim #screenshooter - pkgs.brightnessctl #brightness control for laptop - pkgs.playerctl #music control - pkgs.xclip - ]; - services.xserver.displayManager.sessionCommands = '' - ${lib.getExe' pkgs.sxhkd "sxhkd"} -c ${configFile} & - ''; - } + lib.mkIf cfg.sxhkd.enable { + environment.systemPackages = [ + pkgs.maim # screenshooter + pkgs.brightnessctl # brightness control for laptop + pkgs.playerctl # music control + pkgs.xclip + ]; + services.xserver.displayManager.sessionCommands = '' + ${lib.getExe' pkgs.sxhkd "sxhkd"} -c ${configFile} & + ''; + } ) ]; _file = ./X11.nix; diff --git a/modules/boot.nix b/modules/boot.nix index 936950d..38098ea 100644 --- a/modules/boot.nix +++ b/modules/boot.nix @@ -1,9 +1,11 @@ -{self, ...}: { +{ self, ... }: +{ lib, pkgs, config, ... -}: { +}: +{ options.local.bootConfig.disable = lib.mkEnableOption ""; config = lib.mkIf (!config.local.bootConfig.disable) { environment.etc = { @@ -13,7 +15,7 @@ }; }; boot = { - blacklistedKernelModules = ["pcspkr"]; + blacklistedKernelModules = [ "pcspkr" ]; kernelParams = lib.mkAfter [ "acpi_call" "pti=auto" @@ -76,8 +78,8 @@ Type = "oneshot"; RemainAfterExit = true; }; - path = [pkgs.efibootmgr]; - wantedBy = ["default.target"]; + path = [ pkgs.efibootmgr ]; + wantedBy = [ "default.target" ]; script = '' efibootmgr -t 0 ''; diff --git a/modules/builders.nix b/modules/builders.nix index 95d7afc..cffa86e 100644 --- a/modules/builders.nix +++ b/modules/builders.nix @@ -1,50 +1,50 @@ -_: { - config, - lib, - ... -}: { +_: +{ config, lib, ... }: +{ options.local.remoteBuild = { enable = lib.mkEnableOption ""; isBuilder = lib.mkEnableOption ""; }; config = lib.mkMerge [ - ( - lib.mkIf config.local.remoteBuild.enable { - nix = { - settings = { - keep-outputs = false; - keep-derivations = false; - builders-use-substitutes = true; - max-jobs = 0; - substituters = [ - "ssh-ng://nix-ssh@gerg-desktop" - ]; - trusted-public-keys = [ - "gerg-desktop:6p1+h6jQnb1MOt3ra3PlQpfgEEF4zRrQWiEuAqcjBj8=" - ]; - }; - distributedBuilds = true; - buildMachines = [ - { - hostName = "gerg-desktop"; - protocol = "ssh-ng"; - maxJobs = 32; - systems = ["x86_64-linux" "i686-linux"]; - supportedFeatures = ["big-parallel" "nixos-test" "kvm" "benchmark"]; - sshUser = "builder"; - sshKey = "/etc/ssh/ssh_host_ed25519_key"; - publicHostKey = config.local.keys.gerg-desktop_fingerprint; - } + (lib.mkIf config.local.remoteBuild.enable { + nix = { + settings = { + keep-outputs = false; + keep-derivations = false; + builders-use-substitutes = true; + max-jobs = 0; + substituters = [ "ssh-ng://nix-ssh@gerg-desktop" ]; + trusted-public-keys = [ + "gerg-desktop:6p1+h6jQnb1MOt3ra3PlQpfgEEF4zRrQWiEuAqcjBj8=" ]; }; - programs.ssh.knownHosts = { - gerg-desktop = { - extraHostNames = ["gerg-desktop.lan"]; - publicKey = config.local.keys.root_gerg-desktop; - }; + distributedBuilds = true; + buildMachines = [ { + hostName = "gerg-desktop"; + protocol = "ssh-ng"; + maxJobs = 32; + systems = [ + "x86_64-linux" + "i686-linux" + ]; + supportedFeatures = [ + "big-parallel" + "nixos-test" + "kvm" + "benchmark" + ]; + sshUser = "builder"; + sshKey = "/etc/ssh/ssh_host_ed25519_key"; + publicHostKey = config.local.keys.gerg-desktop_fingerprint; + } ]; + }; + programs.ssh.knownHosts = { + gerg-desktop = { + extraHostNames = [ "gerg-desktop.lan" ]; + publicKey = config.local.keys.root_gerg-desktop; }; - } - ) + }; + }) ( let @@ -53,44 +53,48 @@ _: { config.local.keys.root_game-laptop ]; in - lib.mkIf config.local.remoteBuild.isBuilder - { - sops.secrets.store_key = {}; - users = { - groups.builder = {}; - users.builder = { - createHome = false; - isSystemUser = true; - openssh.authorizedKeys = {inherit keys;}; - useDefaultShell = true; - group = "builder"; - }; - }; - services.openssh.extraConfig = '' - Match User builder - AllowAgentForwarding no - AllowTcpForwarding no - PermitTTY no - PermitTunnel no - X11Forwarding no - Match All - ''; - - nix = { - settings = { - trusted-users = ["builder" "nix-ssh"]; - keep-outputs = true; - keep-derivations = true; - secret-key-files = config.sops.secrets.store_key.path; - }; - sshServe = { - enable = true; - write = true; + lib.mkIf config.local.remoteBuild.isBuilder { + sops.secrets.store_key = { }; + users = { + groups.builder = { }; + users.builder = { + createHome = false; + isSystemUser = true; + openssh.authorizedKeys = { inherit keys; - protocol = "ssh-ng"; }; + useDefaultShell = true; + group = "builder"; }; - } + }; + services.openssh.extraConfig = '' + Match User builder + AllowAgentForwarding no + AllowTcpForwarding no + PermitTTY no + PermitTunnel no + X11Forwarding no + Match All + ''; + + nix = { + settings = { + trusted-users = [ + "builder" + "nix-ssh" + ]; + keep-outputs = true; + keep-derivations = true; + secret-key-files = config.sops.secrets.store_key.path; + }; + sshServe = { + enable = true; + write = true; + inherit keys; + protocol = "ssh-ng"; + }; + }; + } ) ]; _file = ./builders.nix; diff --git a/modules/hardware.nix b/modules/hardware.nix index 9fb1dd1..ae09666 100644 --- a/modules/hardware.nix +++ b/modules/hardware.nix @@ -1,28 +1,25 @@ -_: { - config, - lib, - ... -}: let +_: +{ config, lib, ... }: +let cfg = config.local.hardware; -in { +in +{ options.local.hardware = { gpuAcceleration.disable = lib.mkEnableOption ""; sound.disable = lib.mkEnableOption ""; }; config = lib.mkMerge [ - ( - lib.mkIf (! cfg.gpuAcceleration.disable) { - hardware.opengl = { - enable = true; - driSupport = true; - driSupport32Bit = true; - }; - } - ) - (lib.mkIf (! cfg.sound.disable) { + (lib.mkIf (!cfg.gpuAcceleration.disable) { + hardware.opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + }) + (lib.mkIf (!cfg.sound.disable) { security.rtkit.enable = true; - sound.enable = lib.mkForce false; #disable alsa - hardware.pulseaudio.enable = lib.mkForce false; #disable pulseAudio + sound.enable = lib.mkForce false; # disable alsa + hardware.pulseaudio.enable = lib.mkForce false; # disable pulseAudio services.pipewire = { enable = true; alsa = { diff --git a/modules/keys.nix b/modules/keys.nix index 4b2ce5f..1bbd733 100644 --- a/modules/keys.nix +++ b/modules/keys.nix @@ -1,5 +1,7 @@ -_: {lib, ...}: { - options.local.keys = lib.mkOption {}; +_: +{ lib, ... }: +{ + options.local.keys = lib.mkOption { }; config.local.keys = { gerg_gerg-phone = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDU6BnoHIgMLgZVGuvi03J9l5Z1yP1P5Q8QPyjRHyi77"; diff --git a/modules/misc.nix b/modules/misc.nix index 3811a4f..7eb2d92 100644 --- a/modules/misc.nix +++ b/modules/misc.nix @@ -1,42 +1,46 @@ -_: { +_: +{ lib, config, pkgs, ... -}: { +}: +{ options.local.allowedUnfree = lib.mkOption { type = lib.types.listOf lib.types.str; - default = []; + default = [ ]; }; config = { nixpkgs = { #TODO better way of doing this - overlays = [(self: _: {inherit (self.stdenv.hostPlatform) system;})]; + overlays = [ (self: _: { inherit (self.stdenv.hostPlatform) system; }) ]; config = { allowAliases = false; - allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) config.local.allowedUnfree; + allowUnfreePredicate = + pkg: builtins.elem (lib.getName pkg) config.local.allowedUnfree; }; }; programs.git.enable = true; - environment.defaultPackages = lib.mkForce (builtins.attrValues { - inherit - (pkgs) - bottom #view tasks - efibootmgr #efi editor - nix-output-monitor #nom nom nom nom; - nix-tree #view packages - pciutils #lspci + environment.defaultPackages = lib.mkForce ( + builtins.attrValues { + inherit (pkgs) + bottom # view tasks + efibootmgr # efi editor + nix-output-monitor # nom nom nom nom; + nix-tree # view packages + pciutils # lspci ; - }); + } + ); #enable ssh - programs.mtr.enable = true; #ping and traceroute + programs.mtr.enable = true; # ping and traceroute services.openssh = { enable = true; - hostKeys = lib.mkForce []; + hostKeys = lib.mkForce [ ]; settings = { PermitRootLogin = lib.mkDefault "no"; PasswordAuthentication = false; diff --git a/modules/nix.nix b/modules/nix.nix index 593ab26..7bec8af 100644 --- a/modules/nix.nix +++ b/modules/nix.nix @@ -1,17 +1,17 @@ -inputs: { - pkgs, - lib, - ... -}: +inputs: +{ pkgs, lib, ... }: # # Flake registry and $NIX_PATH pinning # let - alias = inputs // {nixpkgs = inputs.unstable;}; + alias = inputs // { + nixpkgs = inputs.unstable; + }; flakes = lib.filterAttrs (_: lib.isType "flake") alias; -in { +in +{ nix.nixPath = lib.mapAttrsToList (x: _: "${x}=flake:${x}") flakes; - nix.registry = lib.mapAttrs (_: flake: {inherit flake;}) flakes; + nix.registry = lib.mapAttrs (_: flake: { inherit flake; }) flakes; # # Ignore global registry # @@ -50,15 +50,13 @@ in { "root" "@wheel" ]; - allowed-users = []; + allowed-users = [ ]; use-xdg-base-directories = true; auto-allocate-uids = true; }; # # Fix for use-xdg-base-directories https://github.com/NixOS/nixpkgs/pull/241518 # - environment.profiles = [ - "\${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile" - ]; + environment.profiles = [ "\${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile" ]; _file = ./nix.nix; } diff --git a/modules/shell.nix b/modules/shell.nix index c51b7d2..7f245c2 100644 --- a/modules/shell.nix +++ b/modules/shell.nix @@ -1,30 +1,18 @@ +{ fetch-rs, self, ... }: { - fetch-rs, - self, - ... -}: { pkgs, config, lib, ... -}: { - systemd.tmpfiles.rules = [ - "d /tmp/neovim-page 0777 root root - -" - ]; +}: +{ + systemd.tmpfiles.rules = [ "d /tmp/neovim-page 0777 root root - -" ]; environment = { systemPackages = builtins.attrValues { - inherit - (pkgs) - page - eza - fzf - ; - inherit - (fetch-rs.packages.${pkgs.system}) - fetch-rs - ; + inherit (pkgs) page eza fzf; + inherit (fetch-rs.packages.${pkgs.system}) fetch-rs; }; - binsh = lib.getExe pkgs.dash; #use dash for speed + binsh = lib.getExe pkgs.dash; # use dash for speed variables = { EDITOR = "nvim"; VISUAL = "nvim"; @@ -39,7 +27,8 @@ pastebin = "curl -F 'clbin=<-' https://clbin.com"; termbin = "nc termbin.com 9999"; #nix stuff - gc-check = "nix-store --gc --print-roots | egrep -v \"^(/nix/var|/run/\w+-system|\{memory|/proc)\""; + gc-check = '' + nix-store --gc --print-roots | egrep -v "^(/nix/var|/run/w+-system|{memory|/proc)"''; #vim stuff vi = "nvim"; vim = "nvim"; @@ -61,14 +50,16 @@ enable = true; execWheelOnly = true; extraConfig = '' - Defaults env_keep += "${builtins.concatStringsSep " " (builtins.attrNames config.environment.variables)}" + Defaults env_keep += "${ + builtins.concatStringsSep " " (builtins.attrNames config.environment.variables) + }" Defaults lecture = never ''; }; #zsh stuff users.defaultUserShell = pkgs.zsh; - environment.shells = [pkgs.zsh]; + environment.shells = [ pkgs.zsh ]; programs = { zsh = { enable = true; @@ -122,7 +113,9 @@ enable = true; settings = { add_newline = false; - format = "$cmd_duration$git_metrics$git_state$git_branch\n$status$directory$character"; + format = '' + $cmd_duration$git_metrics$git_state$git_branch + $status$directory$character''; right_format = "$sudo$nix_shell\${custom.direnv} $time"; continuation_prompt = "▶▶ "; character = { @@ -161,7 +154,9 @@ when = "printenv DIRENV_FILE"; }; time = { - format = "[$time]($style)\n"; + format = '' + [$time]($style) + ''; time_format = "%I:%M %p"; disabled = false; }; diff --git a/modules/sops.nix b/modules/sops.nix index dfdb169..58564df 100644 --- a/modules/sops.nix +++ b/modules/sops.nix @@ -1,24 +1,18 @@ +{ sops-nix, self, ... }: { - sops-nix, - self, - ... -}: { pkgs, config, lib, ... -}: { - imports = [ - sops-nix.nixosModules.sops - ]; +}: +{ + imports = [ sops-nix.nixosModules.sops ]; options.local.sops.disable = lib.mkEnableOption ""; config = lib.mkIf (!config.local.sops.disable) { - environment.systemPackages = [ - pkgs.sops - ]; + environment.systemPackages = [ pkgs.sops ]; sops = { defaultSopsFile = "${self}/hosts/${config.networking.hostName}/secrets.yaml"; - age.sshKeyPaths = ["/etc/ssh/ssh_host_ed25519_key"]; + age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; }; }; _file = ./sops.nix; diff --git a/modules/systemd-boot/default.nix b/modules/systemd-boot/default.nix index 104c91b..0573053 100644 --- a/modules/systemd-boot/default.nix +++ b/modules/systemd-boot/default.nix @@ -1,18 +1,21 @@ -_: { +_: +{ config, lib, pkgs, modulesPath, ... }: -with lib; let +with lib; +let cfg = config.boot.loader.systemd-boot; inherit (config.boot.loader) efi; - python3 = pkgs.python3.withPackages (ps: [ps.packaging]); + python3 = pkgs.python3.withPackages (ps: [ ps.packaging ]); - systemdBootBuilder = mountPoint: + systemdBootBuilder = + mountPoint: pkgs.substituteAll { src = ./systemd-boot-builder.py; @@ -24,17 +27,14 @@ with lib; let nix = config.nix.package.out; - timeout = optionalString (config.boot.loader.timeout != null) config.boot.loader.timeout; + timeout = + optionalString (config.boot.loader.timeout != null) + config.boot.loader.timeout; - editor = - if cfg.editor - then "True" - else "False"; + editor = if cfg.editor then "True" else "False"; configurationLimit = - if cfg.configurationLimit == null - then 0 - else cfg.configurationLimit; + if cfg.configurationLimit == null then 0 else cfg.configurationLimit; inherit (cfg) consoleMode graceful; @@ -51,46 +51,89 @@ with lib; let copyExtraFiles = pkgs.writeShellScript "copy-extra-files" '' empty_file=$(${pkgs.coreutils}/bin/mktemp) - ${concatStrings (mapAttrsToList (n: v: '' - ${pkgs.coreutils}/bin/install -Dp "${v}" "${mountPoint}/"${escapeShellArg n} - ${pkgs.coreutils}/bin/install -D $empty_file "${mountPoint}/efi/nixos/.extra-files/"${escapeShellArg n} - '') - cfg.extraFiles)} + ${concatStrings ( + mapAttrsToList + (n: v: '' + ${pkgs.coreutils}/bin/install -Dp "${v}" "${mountPoint}/"${escapeShellArg n} + ${pkgs.coreutils}/bin/install -D $empty_file "${mountPoint}/efi/nixos/.extra-files/"${ + escapeShellArg n + } + '') + cfg.extraFiles + )} - ${concatStrings (mapAttrsToList (n: v: '' - ${pkgs.coreutils}/bin/install -Dp "${pkgs.writeText n v}" "${mountPoint}/loader/entries/"${escapeShellArg n} - ${pkgs.coreutils}/bin/install -D $empty_file "${mountPoint}/efi/nixos/.extra-files/loader/entries/"${escapeShellArg n} - '') - cfg.extraEntries)} + ${concatStrings ( + mapAttrsToList + (n: v: '' + ${pkgs.coreutils}/bin/install -Dp "${ + pkgs.writeText n v + }" "${mountPoint}/loader/entries/"${escapeShellArg n} + ${pkgs.coreutils}/bin/install -D $empty_file "${mountPoint}/efi/nixos/.extra-files/loader/entries/"${ + escapeShellArg n + } + '') + cfg.extraEntries + )} ''; }; - checkedSystemdBootBuilder = mountPoint: - pkgs.runCommand "systemd-boot" { - nativeBuildInputs = [pkgs.mypy python3]; - } '' - install -m755 ${systemdBootBuilder mountPoint} $out - mypy \ - --no-implicit-optional \ - --disallow-untyped-calls \ - --disallow-untyped-defs \ - $out - ''; + checkedSystemdBootBuilder = + mountPoint: + pkgs.runCommand "systemd-boot" + { + nativeBuildInputs = [ + pkgs.mypy + python3 + ]; + } + '' + install -m755 ${systemdBootBuilder mountPoint} $out + mypy \ + --no-implicit-optional \ + --disallow-untyped-calls \ + --disallow-untyped-defs \ + $out + ''; - finalSystemdBootBuilder = let - installDirs = - if cfg.mirroredBoots != [] - then cfg.mirroredBoots - else [efi.efiSysMountPoint]; - in - pkgs.writeShellScript "install-systemd-boot.sh" - (lib.concatMapStrings (x: "${checkedSystemdBootBuilder x} \"$@\"\n") installDirs) - + cfg.extraInstallCommands; -in { - disabledModules = ["${modulesPath}/system/boot/loader/systemd-boot/systemd-boot.nix"]; + finalSystemdBootBuilder = + let + installDirs = + if cfg.mirroredBoots != [ ] then + cfg.mirroredBoots + else + [ efi.efiSysMountPoint ] + ; + in + pkgs.writeShellScript "install-systemd-boot.sh" ( + lib.concatMapStrings + (x: '' + ${checkedSystemdBootBuilder x} "$@" + '') + installDirs + ) + + cfg.extraInstallCommands + ; +in +{ + disabledModules = [ + "${modulesPath}/system/boot/loader/systemd-boot/systemd-boot.nix" + ]; imports = [ - (mkRenamedOptionModule ["boot" "loader" "gummiboot" "enable"] ["boot" "loader" "systemd-boot" "enable"]) + (mkRenamedOptionModule + [ + "boot" + "loader" + "gummiboot" + "enable" + ] + [ + "boot" + "loader" + "systemd-boot" + "enable" + ] + ) ]; options.boot.loader.systemd-boot = { @@ -99,7 +142,9 @@ in { type = types.bool; - description = lib.mdDoc "Whether to enable the systemd-boot (formerly gummiboot) EFI boot manager"; + description = + lib.mdDoc + "Whether to enable the systemd-boot (formerly gummiboot) EFI boot manager"; }; editor = mkOption { @@ -148,7 +193,14 @@ in { consoleMode = mkOption { default = "keep"; - type = types.enum ["0" "1" "2" "auto" "max" "keep"]; + type = types.enum [ + "0" + "1" + "2" + "auto" + "max" + "keep" + ]; description = lib.mdDoc '' The resolution of the console. The following values are valid: @@ -210,7 +262,7 @@ in { extraEntries = mkOption { type = types.attrsOf types.lines; - default = {}; + default = { }; example = literalExpression '' { "memtest86.conf" = ''' title MemTest86 @@ -231,7 +283,7 @@ in { extraFiles = mkOption { type = types.attrsOf types.path; - default = {}; + default = { }; example = literalExpression '' { "efi/memtest86/memtest86.efi" = "''${pkgs.memtest86-efi}/BOOTX64.efi"; } ''; @@ -260,7 +312,7 @@ in { mirroredBoots = lib.mkOption { type = lib.types.listOf lib.types.str; - default = []; + default = [ ]; example = '' [ "/boot1" "/boot2" ] ''; @@ -272,36 +324,52 @@ in { config = mkIf cfg.enable { assertions = - [ - { - assertion = (config.boot.kernelPackages.kernel.features or {efiBootStub = true;}) ? efiBootStub; - message = "This kernel does not support the EFI boot stub"; - } - ] - ++ concatMap (filename: [ - { - assertion = !(hasInfix "/" filename); - message = "boot.loader.systemd-boot.extraEntries.${lib.strings.escapeNixIdentifier filename} is invalid: entries within folders are not supported"; - } - { - assertion = hasSuffix ".conf" filename; - message = "boot.loader.systemd-boot.extraEntries.${lib.strings.escapeNixIdentifier filename} is invalid: entries must have a .conf file extension"; - } - ]) (builtins.attrNames cfg.extraEntries) - ++ concatMap (filename: [ - { - assertion = !(hasPrefix "/" filename); - message = "boot.loader.systemd-boot.extraFiles.${lib.strings.escapeNixIdentifier filename} is invalid: paths must not begin with a slash"; - } - { - assertion = !(hasInfix ".." filename); - message = "boot.loader.systemd-boot.extraFiles.${lib.strings.escapeNixIdentifier filename} is invalid: paths must not reference the parent directory"; - } - { - assertion = !(hasInfix "nixos/.extra-files" (toLower filename)); - message = "boot.loader.systemd-boot.extraFiles.${lib.strings.escapeNixIdentifier filename} is invalid: files cannot be placed in the nixos/.extra-files directory"; - } - ]) (builtins.attrNames cfg.extraFiles); + [ { + assertion = + (config.boot.kernelPackages.kernel.features or { efiBootStub = true; }) + ? efiBootStub; + message = "This kernel does not support the EFI boot stub"; + } ] + ++ concatMap + (filename: [ + { + assertion = !(hasInfix "/" filename); + message = "boot.loader.systemd-boot.extraEntries.${ + lib.strings.escapeNixIdentifier filename + } is invalid: entries within folders are not supported"; + } + { + assertion = hasSuffix ".conf" filename; + message = "boot.loader.systemd-boot.extraEntries.${ + lib.strings.escapeNixIdentifier filename + } is invalid: entries must have a .conf file extension"; + } + ]) + (builtins.attrNames cfg.extraEntries) + ++ + concatMap + (filename: [ + { + assertion = !(hasPrefix "/" filename); + message = "boot.loader.systemd-boot.extraFiles.${ + lib.strings.escapeNixIdentifier filename + } is invalid: paths must not begin with a slash"; + } + { + assertion = !(hasInfix ".." filename); + message = "boot.loader.systemd-boot.extraFiles.${ + lib.strings.escapeNixIdentifier filename + } is invalid: paths must not reference the parent directory"; + } + { + assertion = !(hasInfix "nixos/.extra-files" (toLower filename)); + message = "boot.loader.systemd-boot.extraFiles.${ + lib.strings.escapeNixIdentifier filename + } is invalid: files cannot be placed in the nixos/.extra-files directory"; + } + ]) + (builtins.attrNames cfg.extraFiles) + ; boot.loader.grub.enable = mkDefault false; @@ -339,9 +407,7 @@ in { boot.loader.id = "systemd-boot"; - requiredKernelConfig = with config.lib.kernelConfig; [ - (isYes "EFI_STUB") - ]; + requiredKernelConfig = with config.lib.kernelConfig; [ (isYes "EFI_STUB") ]; }; }; } diff --git a/modules/theming.nix b/modules/theming.nix index 5cf45f5..591224a 100644 --- a/modules/theming.nix +++ b/modules/theming.nix @@ -1,79 +1,80 @@ -_: { +_: +{ pkgs, config, lib, ... -}: let +}: +let cfg = config.local.theming; -in { +in +{ options.local.theming = { enable = lib.mkEnableOption ""; kmscon.enable = lib.mkEnableOption ""; }; config = lib.mkMerge [ - ( - lib.mkIf cfg.enable { - environment = { - systemPackages = [ - pkgs.flat-remix-gtk - pkgs.flat-remix-icon-theme - pkgs.quintom-cursor-theme - ]; - etc = { - "xdg/gtk-4.0/settings.ini".text = '' - [Settings] - gtk-cursor-theme-name=Quintom_Ink - gtk-cursor-theme-size=16 - gtk-font-name = "Overpass 10" - gtk-icon-theme-name=Flat-Remix-Blue-Dark - gtk-theme-name=Flat-Remix-GTK-Blue-Darkest - ''; - "xdg/gtk-3.0/settings.ini".text = '' - [Settings] - gtk-cursor-theme-name=Quintom_Ink - gtk-cursor-theme-size=16 - gtk-font-name = "Overpass 10" - gtk-icon-theme-name=Flat-Remix-Blue-Dark - gtk-theme-name=Flat-Remix-GTK-Blue-Darkest - ''; - "xdg/gtk-2.0/gtkrc".text = '' - gtk-cursor-theme-name = "Quintom_Ink" - gtk-cursor-theme-size = 16 - gtk-font-name = "Overpass 10" - gtk-icon-theme-name = "Flat-Remix-Blue-Dark" - gtk-theme-name = "Flat-Remix-GTK-Blue-Darkest" - ''; - "xdg/Xresources".text = '' - Xcursor.size: 16 - Xcursor.theme: Quintom_Ink - ''; - }; + (lib.mkIf cfg.enable { + environment = { + systemPackages = [ + pkgs.flat-remix-gtk + pkgs.flat-remix-icon-theme + pkgs.quintom-cursor-theme + ]; + etc = { + "xdg/gtk-4.0/settings.ini".text = '' + [Settings] + gtk-cursor-theme-name=Quintom_Ink + gtk-cursor-theme-size=16 + gtk-font-name = "Overpass 10" + gtk-icon-theme-name=Flat-Remix-Blue-Dark + gtk-theme-name=Flat-Remix-GTK-Blue-Darkest + ''; + "xdg/gtk-3.0/settings.ini".text = '' + [Settings] + gtk-cursor-theme-name=Quintom_Ink + gtk-cursor-theme-size=16 + gtk-font-name = "Overpass 10" + gtk-icon-theme-name=Flat-Remix-Blue-Dark + gtk-theme-name=Flat-Remix-GTK-Blue-Darkest + ''; + "xdg/gtk-2.0/gtkrc".text = '' + gtk-cursor-theme-name = "Quintom_Ink" + gtk-cursor-theme-size = 16 + gtk-font-name = "Overpass 10" + gtk-icon-theme-name = "Flat-Remix-Blue-Dark" + gtk-theme-name = "Flat-Remix-GTK-Blue-Darkest" + ''; + "xdg/Xresources".text = '' + Xcursor.size: 16 + Xcursor.theme: Quintom_Ink + ''; }; - qt = { + }; + qt = { + enable = true; + style = "gtk2"; + platformTheme = "gtk2"; + }; + services.xserver.displayManager.sessionCommands = '' + ${lib.getExe' pkgs.xorg.xrdb "xrdb"} -load /etc/xdg/Xresources + ''; + fonts = { + packages = [ pkgs.overpass ]; + enableDefaultPackages = false; + fontDir.enable = true; + fontconfig = { enable = true; - style = "gtk2"; - platformTheme = "gtk2"; - }; - services.xserver.displayManager.sessionCommands = '' - ${lib.getExe' pkgs.xorg.xrdb "xrdb"} -load /etc/xdg/Xresources - ''; - fonts = { - packages = [pkgs.overpass]; - enableDefaultPackages = false; - fontDir.enable = true; - fontconfig = { - enable = true; - defaultFonts = { - serif = ["Overpass"]; - sansSerif = ["Overpass"]; - monospace = ["Overpass Mono"]; - }; - hinting.enable = true; - antialias = true; + defaultFonts = { + serif = [ "Overpass" ]; + sansSerif = [ "Overpass" ]; + monospace = [ "Overpass Mono" ]; }; + hinting.enable = true; + antialias = true; }; - } - ) + }; + }) (lib.mkIf cfg.kmscon.enable { services.kmscon = { enable = true; @@ -81,16 +82,10 @@ in { extraConfig = '' font-size=10 ''; - fonts = [ - { - name = "OverpassMono"; - package = - pkgs.nerdfonts.override - { - fonts = ["Overpass"]; - }; - } - ]; + fonts = [ { + name = "OverpassMono"; + package = pkgs.nerdfonts.override { fonts = [ "Overpass" ]; }; + } ]; }; systemd.services = { "autovt@tty1".enable = false; diff --git a/packages/fzf-tab.nix b/packages/fzf-tab.nix index b0c72dd..7e127e5 100644 --- a/packages/fzf-tab.nix +++ b/packages/fzf-tab.nix @@ -1,4 +1,4 @@ -{fetchFromGitHub}: +{ fetchFromGitHub }: fetchFromGitHub { owner = "Aloxaf"; repo = "fzf-tab"; diff --git a/packages/images.nix b/packages/images.nix index 2e98302..75b2377 100644 --- a/packages/images.nix +++ b/packages/images.nix @@ -3,19 +3,20 @@ runCommand, imagemagick, }: -runCommand "images" { - recursion = fetchurl { - url = "https://github.com/NixOS/nixos-artwork/raw/bcdd2770f5f4839fddc9b503e68db2bc3a87ca4d/wallpapers/nix-wallpaper-recursive.png"; - sha256 = "sha256-YvFrlysNGMwJ7eMFOoz0KI8AjoPN3ao+AVOgnVZzkFE="; - }; - logo = fetchurl { - url = "https://raw.githubusercontent.com/NixOS/nixos-artwork/376ed4ba8dc2e611b7e8a62fdc680967ead5bd87/logo/nix-snowflake.svg"; - sha256 = "sha256-SCuQlSPB14GFTq4XvExJ0QEuK2VIbrd5YYKHLRG/q5I="; - }; - buildInputs = [imagemagick]; -} -'' - mkdir -p $out - cp $recursion $out/recursion.png - convert -background none -size 512x512 $logo $out/logo.png -'' +runCommand "images" + { + recursion = fetchurl { + url = "https://github.com/NixOS/nixos-artwork/raw/bcdd2770f5f4839fddc9b503e68db2bc3a87ca4d/wallpapers/nix-wallpaper-recursive.png"; + sha256 = "sha256-YvFrlysNGMwJ7eMFOoz0KI8AjoPN3ao+AVOgnVZzkFE="; + }; + logo = fetchurl { + url = "https://raw.githubusercontent.com/NixOS/nixos-artwork/376ed4ba8dc2e611b7e8a62fdc680967ead5bd87/logo/nix-snowflake.svg"; + sha256 = "sha256-SCuQlSPB14GFTq4XvExJ0QEuK2VIbrd5YYKHLRG/q5I="; + }; + buildInputs = [ imagemagick ]; + } + '' + mkdir -p $out + cp $recursion $out/recursion.png + convert -background none -size 512x512 $logo $out/logo.png + '' diff --git a/packages/papermc.nix b/packages/papermc.nix index d05cd0a..3254dab 100644 --- a/packages/papermc.nix +++ b/packages/papermc.nix @@ -4,31 +4,37 @@ makeBinaryWrapper, fetchurl, jre, -}: let +}: +let pname = "papermc"; version = "1.20.1.83"; in - runCommandNoCC "papermc" { +runCommandNoCC "papermc" + { inherit pname version; - src = let - mcVersion = lib.versions.pad 3 version; - buildNum = builtins.elemAt (lib.versions.splitVersion version) 3; - in + src = + let + mcVersion = lib.versions.pad 3 version; + buildNum = builtins.elemAt (lib.versions.splitVersion version) 3; + in fetchurl { url = "https://papermc.io/api/v2/projects/paper/versions/${mcVersion}/builds/${buildNum}/downloads/paper-${mcVersion}-${buildNum}.jar"; hash = "sha256-HQpc3MOXa1wkXqgm9ciQj04FUIyuupnYiu+2RZ/sXE4="; }; - nativeBuildInputs = [makeBinaryWrapper]; + nativeBuildInputs = [ makeBinaryWrapper ]; meta = { description = "High-performance Minecraft Server"; homepage = "https://papermc.io/"; - sourceProvenance = with lib.sourceTypes; [binaryBytecode]; + sourceProvenance = with lib.sourceTypes; [ binaryBytecode ]; license = lib.licenses.gpl3Only; platforms = lib.platforms.unix; - maintainers = with lib.maintainers; [aaronjanse neonfuz]; + maintainers = with lib.maintainers; [ + aaronjanse + neonfuz + ]; mainProgram = "minecraft-server"; }; }