diff options
| author | spl3g <spleefer6@yandex.ru> | 2025-05-01 15:16:02 +0300 |
|---|---|---|
| committer | spl3g <spleefer6@yandex.ru> | 2025-05-02 19:58:18 +0300 |
| commit | dce1f40f9b80bc221d1b960efced2369384a278f (patch) | |
| tree | fbd84178cde34757dbcd74c1afe7668541227549 /nixos | |
| parent | 8e4059ac9d5a485f0e6eda771768aad541c43b49 (diff) | |
feat: add the actual server configuration
Diffstat (limited to 'nixos')
| -rw-r--r-- | nixos/server/configuration.nix | 137 | ||||
| -rw-r--r-- | nixos/server/disk-config.nix | 55 |
2 files changed, 138 insertions, 54 deletions
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"; } diff --git a/nixos/server/disk-config.nix b/nixos/server/disk-config.nix new file mode 100644 index 0000000..a51111a --- /dev/null +++ b/nixos/server/disk-config.nix @@ -0,0 +1,55 @@ +{ lib, ... }: +{ + disko.devices = { + disk.disk1 = { + device = lib.mkDefault "/dev/vda"; + type = "disk"; + content = { + type = "gpt"; + partitions = { + boot = { + name = "boot"; + size = "1M"; + type = "EF02"; + }; + esp = { + name = "ESP"; + size = "500M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + root = { + name = "root"; + size = "100%"; + content = { + type = "lvm_pv"; + vg = "pool"; + }; + }; + }; + }; + }; + lvm_vg = { + pool = { + type = "lvm_vg"; + lvs = { + root = { + size = "100%FREE"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + mountOptions = [ + "defaults" + ]; + }; + }; + }; + }; + }; + }; +} |
