From c0a1f059dc02d26587cb6295c7026d424c6dabba Mon Sep 17 00:00:00 2001 From: thiloho <123883702+thiloho@users.noreply.github.com> Date: Thu, 4 Jan 2024 14:07:22 +0100 Subject: [PATCH] Format code --- flake.nix | 31 ++--- nixos-configurations/laptop/default.nix | 7 +- .../laptop/hardware-configuration.nix | 29 +++-- nixos-configurations/pc/default.nix | 27 ++--- .../pc/hardware-configuration.nix | 29 +++-- nixos-configurations/server/default.nix | 112 +++++++++--------- .../server/hardware-configuration.nix | 26 ++-- nixos-configurations/shared-desktop.nix | 18 +-- nixos-configurations/shared.nix | 6 +- secrets/secrets.nix | 9 +- 10 files changed, 141 insertions(+), 153 deletions(-) diff --git a/flake.nix b/flake.nix index 5971049..2d20545 100644 --- a/flake.nix +++ b/flake.nix @@ -32,21 +32,22 @@ outputs = inputs@{ nixpkgs, home-manager, ... }: { nixosConfigurations = let - mkSystem = entrypoint: nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = { inherit inputs; }; - modules = [ - entrypoint - { nix.registry.nixpkgs.flake = nixpkgs; } - home-manager.nixosModules.home-manager - { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - }; - } - ]; - }; + mkSystem = entrypoint: + nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; }; + modules = [ + entrypoint + { nix.registry.nixpkgs.flake = nixpkgs; } + home-manager.nixosModules.home-manager + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + }; + } + ]; + }; in { pc = mkSystem ./nixos-configurations/pc; laptop = mkSystem ./nixos-configurations/laptop; diff --git a/nixos-configurations/laptop/default.nix b/nixos-configurations/laptop/default.nix index d62ea97..4c0f5d3 100644 --- a/nixos-configurations/laptop/default.nix +++ b/nixos-configurations/laptop/default.nix @@ -23,9 +23,10 @@ home-manager.users.thiloho = { pkgs, ... }: { programs.git.signing.key = "1142F33FFA8ADAAC"; home = { - packages = with pkgs; [ - # ciscoPacketTracer8 - ]; + packages = with pkgs; + [ + # ciscoPacketTracer8 + ]; stateVersion = "23.05"; }; }; diff --git a/nixos-configurations/laptop/hardware-configuration.nix b/nixos-configurations/laptop/hardware-configuration.nix index bf3d33b..54f5617 100644 --- a/nixos-configurations/laptop/hardware-configuration.nix +++ b/nixos-configurations/laptop/hardware-configuration.nix @@ -4,28 +4,26 @@ { config, lib, pkgs, modulesPath, ... }: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usb_storage" "sd_mod" ]; + boot.initrd.availableKernelModules = + [ "xhci_pci" "nvme" "usb_storage" "sd_mod" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/58cf62a5-3ab2-411d-86ef-c6c4d5877bb8"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/58cf62a5-3ab2-411d-86ef-c6c4d5877bb8"; + fsType = "ext4"; + }; - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/C2DA-F1B0"; - fsType = "vfat"; - }; + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/C2DA-F1B0"; + fsType = "vfat"; + }; swapDevices = - [ { device = "/dev/disk/by-uuid/4d298153-87ea-4a12-a244-a64b2075bd40"; } - ]; + [{ device = "/dev/disk/by-uuid/4d298153-87ea-4a12-a244-a64b2075bd40"; }]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's @@ -37,5 +35,6 @@ nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + hardware.cpu.intel.updateMicrocode = + lib.mkDefault config.hardware.enableRedistributableFirmware; } diff --git a/nixos-configurations/pc/default.nix b/nixos-configurations/pc/default.nix index ca012d2..0ced3a7 100644 --- a/nixos-configurations/pc/default.nix +++ b/nixos-configurations/pc/default.nix @@ -12,19 +12,21 @@ networking = { hostName = "pc"; firewall = { - allowedTCPPorts = [ 5173 ]; - allowedUDPPorts = [ 5173 ]; + allowedTCPPorts = [ 5173 8081 ]; + allowedUDPPorts = [ 5173 8081 ]; }; }; - services.postgresql = { - enable = true; - package = pkgs.postgresql_15; - ensureDatabases = [ "dcbot" "todos" ]; - authentication = pkgs.lib.mkOverride 10 '' - #type database DBuser auth-method - local all all trust - ''; + services = { + postgresql = { + enable = true; + package = pkgs.postgresql_15; + ensureDatabases = [ "dcbot" "todos" ]; + authentication = pkgs.lib.mkOverride 10 '' + #type database DBuser auth-method + local all all trust + ''; + }; }; programs.adb.enable = true; @@ -33,10 +35,7 @@ home-manager.users.thiloho = { pkgs, lib, ... }: { programs.git.signing.key = "5ECD00BDC15A987E"; home = { - packages = with pkgs; [ - blender - inkscape - ]; + packages = with pkgs; [ blender inkscape ]; stateVersion = "23.05"; }; }; diff --git a/nixos-configurations/pc/hardware-configuration.nix b/nixos-configurations/pc/hardware-configuration.nix index 195aab7..701d978 100644 --- a/nixos-configurations/pc/hardware-configuration.nix +++ b/nixos-configurations/pc/hardware-configuration.nix @@ -4,28 +4,26 @@ { config, lib, pkgs, modulesPath, ... }: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.availableKernelModules = + [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-amd" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/ff159d0e-c92c-4329-8aaf-b71e48aba39c"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/ff159d0e-c92c-4329-8aaf-b71e48aba39c"; + fsType = "ext4"; + }; - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/B975-C979"; - fsType = "vfat"; - }; + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/B975-C979"; + fsType = "vfat"; + }; swapDevices = - [ { device = "/dev/disk/by-uuid/253466d8-15b0-412c-8860-ffff0572fece"; } - ]; + [{ device = "/dev/disk/by-uuid/253466d8-15b0-412c-8860-ffff0572fece"; }]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's @@ -35,5 +33,6 @@ # networking.interfaces.enp9s0.useDHCP = lib.mkDefault true; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + hardware.cpu.amd.updateMicrocode = + lib.mkDefault config.hardware.enableRedistributableFirmware; } diff --git a/nixos-configurations/server/default.nix b/nixos-configurations/server/default.nix index 1017450..9b3b542 100644 --- a/nixos-configurations/server/default.nix +++ b/nixos-configurations/server/default.nix @@ -10,26 +10,35 @@ nix.settings.trusted-users = [ "thiloho" ]; age.secrets = { - hedgedoc-environment-file.file = ../../secrets/hedgedoc-environment-file.age; + hedgedoc-environment-file.file = + ../../secrets/hedgedoc-environment-file.age; discord-bot-token.file = ../../secrets/discord-bot-token.age; todos-environment-file.file = ../../secrets/todos-environment-file.age; - "restic/minecraft-environment-file".file = ../../secrets/restic/minecraft-environment-file.age; - "restic/minecraft-repository".file = ../../secrets/restic/minecraft-repository.age; - "restic/minecraft-password".file = ../../secrets/restic/minecraft-password.age; - "restic/hedgedoc-environment-file".file = ../../secrets/restic/hedgedoc-environment-file.age; - "restic/hedgedoc-repository".file = ../../secrets/restic/hedgedoc-repository.age; - "restic/hedgedoc-password".file = ../../secrets/restic/hedgedoc-password.age; - "restic/todos-environment-file".file = ../../secrets/restic/todos-environment-file.age; + "restic/minecraft-environment-file".file = + ../../secrets/restic/minecraft-environment-file.age; + "restic/minecraft-repository".file = + ../../secrets/restic/minecraft-repository.age; + "restic/minecraft-password".file = + ../../secrets/restic/minecraft-password.age; + "restic/hedgedoc-environment-file".file = + ../../secrets/restic/hedgedoc-environment-file.age; + "restic/hedgedoc-repository".file = + ../../secrets/restic/hedgedoc-repository.age; + "restic/hedgedoc-password".file = + ../../secrets/restic/hedgedoc-password.age; + "restic/todos-environment-file".file = + ../../secrets/restic/todos-environment-file.age; "restic/todos-repository".file = ../../secrets/restic/todos-repository.age; "restic/todos-password".file = ../../secrets/restic/todos-password.age; - "restic/discord-bot-environment-file".file = ../../secrets/restic/discord-bot-environment-file.age; - "restic/discord-bot-repository".file = ../../secrets/restic/discord-bot-repository.age; - "restic/discord-bot-password".file = ../../secrets/restic/discord-bot-password.age; + "restic/discord-bot-environment-file".file = + ../../secrets/restic/discord-bot-environment-file.age; + "restic/discord-bot-repository".file = + ../../secrets/restic/discord-bot-repository.age; + "restic/discord-bot-password".file = + ../../secrets/restic/discord-bot-password.age; }; - environment.systemPackages = with pkgs; [ - nodejs_20 - ]; + environment.systemPackages = with pkgs; [ nodejs_20 ]; networking = { hostName = "server"; @@ -153,43 +162,37 @@ minecraft-backup = { initialize = true; - environmentFile = config.age.secrets."restic/minecraft-environment-file".path; + environmentFile = + config.age.secrets."restic/minecraft-environment-file".path; repositoryFile = config.age.secrets."restic/minecraft-repository".path; passwordFile = config.age.secrets."restic/minecraft-password".path; - paths = [ - "/var/lib/minecraft/world" - ]; + paths = [ "/var/lib/minecraft/world" ]; - pruneOpts = [ - "--keep-daily 7" - "--keep-weekly 5" - "--keep-monthly 12" - ]; + pruneOpts = [ "--keep-daily 7" "--keep-weekly 5" "--keep-monthly 12" ]; }; hedgedoc-database-backup = { initialize = true; - environmentFile = config.age.secrets."restic/hedgedoc-environment-file".path; + environmentFile = + config.age.secrets."restic/hedgedoc-environment-file".path; repositoryFile = config.age.secrets."restic/hedgedoc-repository".path; passwordFile = config.age.secrets."restic/hedgedoc-password".path; - - paths = [ "/var/lib/hedgedoc/uploads" "/var/lib/hedgedoc/hedgedoc.dump" ]; + + paths = + [ "/var/lib/hedgedoc/uploads" "/var/lib/hedgedoc/hedgedoc.dump" ]; backupPrepareCommand = '' ${config.services.postgresql.package}/bin/pg_dump -U postgres -Fc hedgedoc > /var/lib/hedgedoc/hedgedoc.dump ''; - pruneOpts = [ - "--keep-daily 7" - "--keep-weekly 5" - "--keep-monthly 12" - ]; + pruneOpts = [ "--keep-daily 7" "--keep-weekly 5" "--keep-monthly 12" ]; }; todos-database-backup = { initialize = true; - environmentFile = config.age.secrets."restic/todos-environment-file".path; + environmentFile = + config.age.secrets."restic/todos-environment-file".path; repositoryFile = config.age.secrets."restic/todos-repository".path; passwordFile = config.age.secrets."restic/todos-password".path; @@ -199,17 +202,15 @@ ${config.services.postgresql.package}/bin/pg_dump -U postgres -Fc todos > /var/lib/todos.dump ''; - pruneOpts = [ - "--keep-daily 7" - "--keep-weekly 5" - "--keep-monthly 12" - ]; + pruneOpts = [ "--keep-daily 7" "--keep-weekly 5" "--keep-monthly 12" ]; }; discord-bot-database-backup = { initialize = true; - environmentFile = config.age.secrets."restic/discord-bot-environment-file".path; - repositoryFile = config.age.secrets."restic/discord-bot-repository".path; + environmentFile = + config.age.secrets."restic/discord-bot-environment-file".path; + repositoryFile = + config.age.secrets."restic/discord-bot-repository".path; passwordFile = config.age.secrets."restic/discord-bot-password".path; paths = [ "/var/lib/dcbot.dump" ]; @@ -218,11 +219,7 @@ ${config.services.postgresql.package}/bin/pg_dump -U postgres -Fc dcbot > /var/lib/dcbot.dump ''; - pruneOpts = [ - "--keep-daily 7" - "--keep-weekly 5" - "--keep-monthly 12" - ]; + pruneOpts = [ "--keep-daily 7" "--keep-weekly 5" "--keep-monthly 12" ]; }; }; }; @@ -240,40 +237,39 @@ systemd.services = { todoapp = { description = "Todo application to plan your daily tasks effectively"; - wantedBy = ["multi-user.target"]; + wantedBy = [ "multi-user.target" ]; serviceConfig = { Type = "simple"; - Environment = "PORT=5173 DOTENV_CONFIG_PATH=${config.age.secrets.todos-environment-file.path}"; + Environment = + "PORT=5173 DOTENV_CONFIG_PATH=${config.age.secrets.todos-environment-file.path}"; ExecStart = "${pkgs.nodejs_20}/bin/node -r dotenv/config ."; WorkingDirectory = inputs.todos.packages.${pkgs.system}.default; Restart = "always"; }; }; todoapp-check-due-dates = { - description = "Set is_overdue for todo in database to true if todo is overdue"; - wantedBy = ["timers.target"]; - path = [ - pkgs.postgresql_15 - ]; + description = + "Set is_overdue for todo in database to true if todo is overdue"; + wantedBy = [ "timers.target" ]; + path = [ pkgs.postgresql_15 ]; script = '' psql -d todos -c "UPDATE user_todo SET is_overdue = true WHERE NOW() AT TIME ZONE 'CET' >= due_date AND is_completed = false AND is_overdue = false" ''; - serviceConfig = { - User = "postgres"; - }; + serviceConfig = { User = "postgres"; }; partOf = [ "todoapp.service" ]; startAt = "daily"; }; denbot = { description = "Thilo's Den discord bot"; - wantedBy = ["multi-user.target"]; + wantedBy = [ "multi-user.target" ]; serviceConfig = { Type = "simple"; ExecStartPre = [ "${pkgs.nodejs_20}/bin/node dbInit.js" "${pkgs.nodejs_20}/bin/node deploy-commands.js --token=${config.age.secrets.discord-bot-token.path} --clientId=1142441791459704912" ]; - ExecStart = "${pkgs.nodejs_20}/bin/node index.js --token=${config.age.secrets.discord-bot-token.path}"; + ExecStart = + "${pkgs.nodejs_20}/bin/node index.js --token=${config.age.secrets.discord-bot-token.path}"; WorkingDirectory = inputs.denbot.packages.${pkgs.system}.default; Restart = "always"; }; @@ -286,9 +282,7 @@ ]; home-manager.users.thiloho = { pkgs, lib, ... }: { - home = { - stateVersion = "23.05"; - }; + home = { stateVersion = "23.05"; }; }; system.stateVersion = "23.05"; } diff --git a/nixos-configurations/server/hardware-configuration.nix b/nixos-configurations/server/hardware-configuration.nix index 842dbf6..b32cf25 100644 --- a/nixos-configurations/server/hardware-configuration.nix +++ b/nixos-configurations/server/hardware-configuration.nix @@ -4,28 +4,26 @@ { config, lib, pkgs, modulesPath, ... }: { - imports = - [ (modulesPath + "/profiles/qemu-guest.nix") - ]; + imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; - boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ]; + boot.initrd.availableKernelModules = + [ "ahci" "xhci_pci" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/950d0289-1ae9-4c4b-8792-3f369e2d0f05"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/950d0289-1ae9-4c4b-8792-3f369e2d0f05"; + fsType = "ext4"; + }; - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/08B5-9946"; - fsType = "vfat"; - }; + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/08B5-9946"; + fsType = "vfat"; + }; swapDevices = - [ { device = "/dev/disk/by-uuid/d3ecc375-0371-4391-ad48-b79168737ec7"; } - ]; + [{ device = "/dev/disk/by-uuid/d3ecc375-0371-4391-ad48-b79168737ec7"; }]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's diff --git a/nixos-configurations/shared-desktop.nix b/nixos-configurations/shared-desktop.nix index 3738702..1ae7d5a 100644 --- a/nixos-configurations/shared-desktop.nix +++ b/nixos-configurations/shared-desktop.nix @@ -27,18 +27,15 @@ }; java.enable = true; }; - + hardware.pulseaudio.enable = false; home-manager.users.thiloho = { pkgs, lib, config, ... }: { programs = { firefox = { enable = true; - package = pkgs.firefox.override { - cfg = { - speechSynthesisSupport = true; - }; - }; + package = + pkgs.firefox.override { cfg = { speechSynthesisSupport = true; }; }; }; chromium = { enable = true; @@ -65,16 +62,12 @@ enable = true; userName = "thiloho"; userEmail = "123883702+thiloho@users.noreply.github.com"; - signing = { - signByDefault = true; - }; + signing = { signByDefault = true; }; }; obs-studio.enable = true; }; home = { - sessionVariables = { - NIXOS_OZONE_WL=1; - }; + sessionVariables = { NIXOS_OZONE_WL = 1; }; packages = with pkgs; [ libreoffice airshipper @@ -82,6 +75,7 @@ prismlauncher ventoy-full psensor + nil zoom-us teamspeak5_client discord diff --git a/nixos-configurations/shared.nix b/nixos-configurations/shared.nix index 894a783..6b8b87e 100644 --- a/nixos-configurations/shared.nix +++ b/nixos-configurations/shared.nix @@ -31,8 +31,10 @@ shellAliases = { rbs = "sudo nixos-rebuild switch --flake ."; off = "sudo systemctl poweroff"; - cleanup = "nix store optimise && nix-collect-garbage -d && sudo nix store optimise && sudo nix-collect-garbage -d"; - listboots = "nix profile history --profile /nix/var/nix/profiles/system"; + cleanup = + "nix store optimise && nix-collect-garbage -d && sudo nix store optimise && sudo nix-collect-garbage -d"; + listboots = + "nix profile history --profile /nix/var/nix/profiles/system"; }; }; helix = { diff --git a/secrets/secrets.nix b/secrets/secrets.nix index d3793e8..84f385f 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -1,8 +1,9 @@ let - server = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIN82ukcaWQZcihgh+n0h+ihwTafm64SO1wngibOA6Vro root@server"; - pc = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMkvr+vT7Ik0fjquxb9xQBfVVWJPgrfC+vJZsyG2V+/G thiloho@pc"; -in -{ + server = + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIN82ukcaWQZcihgh+n0h+ihwTafm64SO1wngibOA6Vro root@server"; + pc = + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMkvr+vT7Ik0fjquxb9xQBfVVWJPgrfC+vJZsyG2V+/G thiloho@pc"; +in { "hedgedoc-environment-file.age".publicKeys = [ server pc ]; "discord-bot-token.age".publicKeys = [ server pc ]; "todos-environment-file.age".publicKeys = [ server pc ];