it-infra/nixops/rpi.nix

76 lines
2.2 KiB
Nix
Raw Normal View History

2020-09-08 13:34:36 +08:00
{ host, rpi4, experimental-users ? false }:
2020-06-20 17:54:21 +08:00
{ config, pkgs, ... }:
let
m-labs = import (fetchTarball https://nixbld.m-labs.hk/channel/custom/artiq/full/artiq-full/nixexprs.tar.xz) { inherit pkgs; };
in
{
deployment.targetHost = host;
2020-12-12 15:01:38 +08:00
nix.nixPath = [ "nixpkgs=${pkgs.path}" ];
2020-06-20 17:54:21 +08:00
nixpkgs.system = "aarch64-linux";
boot.loader.grub.enable = false;
boot.loader.generic-extlinux-compatible.enable = !rpi4;
boot.loader.raspberryPi = pkgs.lib.mkIf rpi4 {
enable = true;
version = 4;
};
boot.kernelPackages = pkgs.lib.mkIf rpi4 pkgs.linuxPackages_latest;
fileSystems = if rpi4 then {
"/boot" = {
device = "/dev/disk/by-label/FIRMWARE";
fsType = "vfat";
};
"/" = {
device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
};
} else {
"/" = {
device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
};
};
services.openssh.enable = true;
services.openssh.passwordAuthentication = false;
2021-01-28 16:05:15 +08:00
services.openssh.gatewayPorts = "clientspecified";
2020-07-15 12:32:57 +08:00
services.openssh.extraConfig =
''
StreamLocalBindUnlink yes
'';
2020-07-18 10:16:03 +08:00
programs.mosh.enable = true;
2020-06-20 17:54:21 +08:00
networking.hostName = host;
2021-01-23 18:56:22 +08:00
networking.firewall.allowedTCPPorts = if host == "rpi-2" then [ 6000 ] else [];
2020-06-20 17:54:21 +08:00
time.timeZone = "Asia/Hong_Kong";
users.extraGroups.plugdev = { };
users.mutableUsers = false;
users.defaultUserShell = pkgs.fish;
2020-09-08 13:34:36 +08:00
users.extraUsers = (import ./common-users.nix { inherit pkgs; }) //
(pkgs.lib.optionalAttrs experimental-users (import ./experimental-users.nix { inherit pkgs; })) // {
2020-06-20 17:54:21 +08:00
nix = {
isNormalUser = true;
};
};
security.sudo.wheelNeedsPassword = false;
services.udev.packages = [ m-labs.openocd ];
2020-09-11 15:27:01 +08:00
services.udev.extraRules = (import ./extra-udev.nix);
2020-06-20 17:54:21 +08:00
documentation.enable = false;
environment.systemPackages = with pkgs; [
2020-10-13 16:29:50 +08:00
psmisc wget vim git sshfs usbutils uhubctl lm_sensors file telnet mosh tmux xc3sprog m-labs.openocd screen gdb minicom picocom
2020-06-20 17:54:21 +08:00
];
programs.fish.enable = true;
programs.wireshark.enable = true;
nix.binaryCachePublicKeys = ["nixbld.m-labs.hk-1:5aSRVA5b320xbNvu30tqxVPXpld73bhtOeH6uAjRyHc="];
nix.binaryCaches = ["https://cache.nixos.org" "https://nixbld.m-labs.hk"];
nix.trustedUsers = ["root" "nix"];
}