From dce1f40f9b80bc221d1b960efced2369384a278f Mon Sep 17 00:00:00 2001 From: spl3g Date: Thu, 1 May 2025 15:16:02 +0300 Subject: feat: add the actual server configuration --- nixos/server/configuration.nix | 137 +++++++++++++++++++++++++---------------- 1 file changed, 83 insertions(+), 54 deletions(-) (limited to 'nixos/server/configuration.nix') diff --git a/nixos/server/configuration.nix b/nixos/server/configuration.nix index 6e14300..2a5afa4 100644 --- a/nixos/server/configuration.nix +++ b/nixos/server/configuration.nix @@ -1,71 +1,100 @@ -{ pkgs, inputs, outputs, lib, config, ... }: +{ modulesPath, config, lib, pkgs, ... }: { + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + (modulesPath + "/profiles/qemu-guest.nix") + ./disk-config.nix + ]; + boot.loader.grub = { + efiSupport = true; + efiInstallAsRemovable = true; + }; -{ - nixpkgs = { - overlays = [ - outputs.overlays.additions - outputs.overlays.modifications - outputs.overlays.unstable-packages - ]; - config = { - allowUnfree = true; + networking = { + interfaces.ens3 = { + ipv4.addresses = [{ + address = "147.45.40.6"; + prefixLength = 32; + }]; + }; + defaultGateway = { + address = "10.0.0.1"; + interface = "ens3"; }; }; - nix = { - # This will add each flake input as a registry - # To make nix3 commands consistent with your flake - registry = lib.mapAttrs (_: value: { flake = value; }) inputs; + networking.useDHCP = lib.mkDefault false; - # This will additionally add your inputs to the system's legacy channels - # Making legacy nix commands consistent as well, awesome! - nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry; + networking.nameservers = [ "8.8.8.8" "1.1.1.1" ]; + networking.hosts = { + "192.168.100.100" = ["stereotyped-sheet.aeza.network"]; + "147.45.40.6" = ["stereotyped-sheet.aeza.network" "stereotyped-sheet"]; + }; + + services.openssh = { + enable = true; + }; + + environment.systemPackages = map lib.lowPrio [ + pkgs.curl + pkgs.gitMinimal + ]; - gc = { - automatic = true; - dates = "weekly"; + users.users = { + root = { + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDJ8UW1BXDGDmlaiARO3a9boTG8wknUyITMz0Z0OJpHx spleefer6@yandex.ru" + ]; }; - - settings = { - # Enable flakes and new 'nix' command - experimental-features = "nix-command flakes"; - # Deduplicate and optimize nix store - auto-optimise-store = true; - - trusted-users = [ "root" "@wheel" ]; + fimoz = { + isNormalUser = true; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ//SNTK/qZmoT0YH7tHxXg6VGEbxbxPLXQVC1zsBPb4 90ts@mail.ru" + ]; }; }; - virtualisation.docker.enable = true; + networking.firewall.allowedTCPPorts = [ 80 443 57625 ]; - # services.nginx = { - # enable = true; - # virtualHosts."kcu.su" = { - # forceSSL = true; - # enableACME = true; - # locations."/xray" = { - # proxyPass = "http://127.0.0.1:42069"; - # extraConfig = "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - # proxy_set_header X-Forwarded-Proto $scheme; - # proxy_set_header Host $http_host; - # proxy_set_header X-Real-IP $remote_addr; - # proxy_set_header Range $http_range; - # proxy_set_header If-Range $http_if_range; - # proxy_redirect off;"; - # }; - # }; - # }; + + security.acme = { + acceptTerms = true; + defaults.email = "notspl3g+acme@duck.com"; + }; - services.k3s = { + services.nginx = { enable = true; - role = "server"; + virtualHosts = { + "xray.kcu.su" = { + forceSSL = true; + enableACME = true; + + locations."/" = { + proxyPass = "http://127.0.0.1:2053"; + extraConfig = " + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Range $http_range; + proxy_set_header If-Range $http_if_range; + proxy_redirect off; + "; + }; + }; + }; }; - security.acme = { - acceptTerms = true; - defaults.email = "notspl3g@duck.com"; + virtualisation.oci-containers = { + backend = "docker"; + containers.xui = { + image = "ghcr.io/mhsanaei/3x-ui:latest"; + ports = ["127.0.0.1:2053:2053" "57625:57625"]; + volumes = [ + "/root/x-ui:/etc/x-ui" + ]; + }; }; - - # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion - system.stateVersion = "24.04"; + + + system.stateVersion = "24.05"; } -- cgit v1.2.3