nix/nixos/hosts/framework-server/default.nix

77 lines
2.6 KiB
Nix
Raw Normal View History

2023-12-04 03:55:18 +01:00
{ inputs, config, lib, pkgs, modulesPath, desktop, username, ... }: {
2023-11-25 07:17:29 +01:00
imports = [
2023-11-25 14:57:30 +01:00
# inputs.nixos-hardware.nixosModules.framework-13-inch-13th-gen-intel
2023-11-26 06:44:52 +01:00
inputs.nixos-hardware.nixosModules.framework-13th-gen-intel
2023-11-25 07:17:29 +01:00
(modulesPath + "/installer/scan/not-detected.nix")
./disks.nix
2023-11-30 12:33:54 +01:00
../../common/modules/secureboot.nix
2023-11-25 07:17:29 +01:00
../../common/services/fwupd.nix
2023-11-29 10:07:39 +01:00
./builder.nix
2023-11-29 12:31:44 +01:00
./ssh-luks.nix
2023-11-29 10:07:39 +01:00
./docker.nix
2023-12-01 13:25:48 +01:00
./wireguard.nix
2023-12-05 12:35:29 +01:00
] ++ lib.optional (builtins.isString desktop) ./rdesktop.nix;
2023-11-25 07:17:29 +01:00
# steam , etc
2023-12-04 03:56:02 +01:00
nixpkgs.config.allowUnfree = true;
2023-11-25 07:17:29 +01:00
2023-11-26 03:01:38 +01:00
boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "thunderbolt" "sd_mod" "uas" ];
2023-12-02 03:24:49 +01:00
boot.initrd.kernelModules = [ "r8152" ];
2023-11-26 03:01:38 +01:00
boot.kernelModules = [ "kvm-intel" ];
2023-11-30 12:20:41 +01:00
boot.extraModulePackages = with config.boot.kernelPackages; [ acpi_call ];
2023-11-25 07:17:29 +01:00
networking.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
2023-11-26 03:01:38 +01:00
powerManagement.cpuFreqGovernor = lib.mkDefault "performance";
2023-11-25 07:17:29 +01:00
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
# Set your time zone.
time.timeZone = "Asia/Tokyo";
# Set the networking hostname:
2023-11-25 11:04:12 +01:00
networking.hostName = "framework-server";
2023-11-25 07:17:29 +01:00
networking.firewall.allowedTCPPorts = [ 22 ];
2023-12-01 09:56:08 +01:00
# Generic Tailscale configs are in /nixos/common/services/tailscale.nix
# Set up the secrets file:
sops.secrets."tailscale_keys/framework-server" = {
owner = "root";
sopsFile = ../../../secrets/tailscale.yaml;
restartUnits = [
"tailscaled.service"
"tailscaled-autoconnect.service"
];
};
2023-12-02 14:51:23 +01:00
services.tailscale.authKeyFile = "/run/secrets/tailscale_keys/framework-server";
2023-12-02 14:36:39 +01:00
services.tailscale.extraUpFlags = [
"--advertise-exit-node"
"--advertise-routes=10.2.0.0/24"
];
2023-12-04 09:25:02 +01:00
boot.kernel.sysctl = {
"net.ipv4.ip_forward" = true;
};
2023-12-01 13:25:48 +01:00
2023-12-06 00:53:36 +01:00
# Forward mail port 25 to sysctl.io / linode
networking.firewall.extraCommands = ''
2023-12-06 03:30:40 +01:00
iptables -A PREROUTING -t nat -i wireguard0 -p tcp --dport 25 -j DNAT --to 10.100.0.1:25
iptables -A INPUT -p tcp -m state --state NEW --dport 25 -i wireguard0 -j ACCEPT
2023-12-06 00:53:36 +01:00
'';
2023-12-02 03:43:04 +01:00
boot.initrd.services.udev.rules = ''
2023-12-04 09:25:02 +01:00
# This is used to load the correct kernel module for the Framework USB-C Ethernet Adapter
2023-12-02 03:43:04 +01:00
ACTION!="add", GOTO="usb_realtek_net_end"
SUBSYSTEM!="usb", GOTO="usb_realtek_net_end"
ENV{DEVTYPE}!="usb_device", GOTO="usb_realtek_net_end"
# Modify this to change the default value
ENV{REALTEK_MODE1}="1"
# Realtek
ATTR{idVendor}=="0bda", ATTR{idProduct}=="815[2,3,5,6]", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
LABEL="usb_realtek_net_end"
'';
2023-12-02 14:36:39 +01:00
}