1
0
Fork 0
it-infra/nixops/rpi-server.nix

123 lines
3.3 KiB
Nix
Raw Normal View History

2021-01-13 17:31:44 +08:00
{ host, rpi4 }:
{ config, pkgs, ... }:
{
deployment.targetHost = host;
2021-06-02 08:56:36 +08:00
deployment.hasFastConnection = true;
2021-01-13 17:31:44 +08:00
nix.nixPath = [ "nixpkgs=${pkgs.path}" ];
2021-03-29 14:01:46 +08:00
programs.command-not-found.dbPath = "${pkgs.path}/programs.sqlite";
2021-01-13 17:31:44 +08:00
nixpkgs.system = "aarch64-linux";
boot.loader.grub.enable = false;
2021-03-28 20:42:59 +08:00
boot.loader.generic-extlinux-compatible.enable = true;
2021-04-17 16:56:36 +08:00
boot.kernelParams = ["cma=64M"]; # work around https://github.com/raspberrypi/linux/issues/3208
boot.kernelPackages = pkgs.linuxPackages_rpi4;
2021-06-02 08:57:07 +08:00
boot.initrd.includeDefaultModules = false;
2021-03-28 20:42:59 +08:00
fileSystems = {
2021-01-13 17:31:44 +08:00
"/" = {
device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
};
};
services.openssh.enable = true;
services.openssh.passwordAuthentication = false;
services.openssh.extraConfig =
''
StreamLocalBindUnlink yes
'';
programs.mosh.enable = true;
networking.hostName = host;
time.timeZone = "Asia/Hong_Kong";
2021-03-04 15:54:55 +08:00
hardware.enableRedistributableFirmware = true;
services.hostapd = {
enable = true;
interface = "wlan0";
hwMode = "g";
ssid = "M-Labs-ext";
wpaPassphrase = (import /etc/nixos/secret/wifi_ext_password.nix);
extraConfig = ''
ieee80211d=1
country_code=HK
ieee80211n=1
wmm_enabled=1
auth_algs=1
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
'';
};
2021-03-04 17:19:13 +08:00
networking.interfaces.eth0 = {
ipv4.addresses = [{
2021-03-05 18:42:54 +08:00
address = "192.168.1.30";
2021-03-04 17:19:13 +08:00
prefixLength = 24;
}];
ipv6.addresses = [{
address = "2001:470:f821:1:dea6:32ff:fe95:2fcf";
prefixLength = 64;
}];
ipv4.routes = [{
address = "0.0.0.0";
prefixLength = 0;
via = "192.168.1.1";
}];
ipv6.routes = [{
address = "::";
prefixLength = 0;
via = "fe80::523e:aaff:fe0c:e49d";
}];
};
2021-03-04 15:54:55 +08:00
networking.interfaces.wlan0 = {
ipv4.addresses = [{
address = "192.168.13.1";
prefixLength = 24;
}];
ipv6.addresses = [{
address = "2001:470:f821:3::";
prefixLength = 64;
}];
};
services.dnsmasq = {
enable = true;
2021-03-04 17:19:13 +08:00
servers = ["192.168.1.1#53"];
2021-03-04 15:54:55 +08:00
extraConfig = ''
interface=wlan0
bind-interfaces
dhcp-range=192.168.13.10,192.168.13.254,24h
enable-ra
dhcp-range=::,constructor:wlan0,ra-only
2021-03-04 17:19:13 +08:00
no-resolv
2021-03-04 15:54:55 +08:00
'';
};
boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = "1";
boot.kernel.sysctl."net.ipv6.conf.default.forwarding" = "1";
users.extraGroups.plugdev = { };
2021-01-13 17:31:44 +08:00
users.mutableUsers = false;
users.defaultUserShell = pkgs.fish;
users.extraUsers = import ./common-users.nix { inherit pkgs; };
security.sudo.wheelNeedsPassword = false;
services.udev.extraRules = (import ./extra-udev.nix);
2021-01-13 17:31:44 +08:00
documentation.enable = false;
environment.systemPackages = with pkgs; [
2022-05-26 13:18:48 +08:00
psmisc wget vim git sshfs usbutils lm_sensors file mosh tmux
imagemagick
2021-01-13 17:31:44 +08:00
];
programs.fish.enable = true;
2021-06-15 14:32:29 +08:00
networking.firewall.allowedTCPPorts = [ 631 ];
2021-03-17 20:58:47 +08:00
networking.firewall.interfaces.wlan0.allowedUDPPorts = [ 53 67 ];
2021-01-13 17:31:44 +08:00
nix.binaryCachePublicKeys = ["nixbld.m-labs.hk-1:5aSRVA5b320xbNvu30tqxVPXpld73bhtOeH6uAjRyHc="];
nix.binaryCaches = ["https://cache.nixos.org" "https://nixbld.m-labs.hk"];
2022-10-14 19:38:12 +08:00
nix.trustedUsers = ["root" "sb"];
2021-12-01 22:09:51 +08:00
nix.extraOptions = ''
experimental-features = nix-command flakes impure-derivations
2021-12-01 22:09:51 +08:00
'';
2021-01-13 17:31:44 +08:00
}