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

77 lines
2.7 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;
2021-06-02 08:56:36 +08:00
deployment.hasFastConnection = true;
2020-12-12 15:01:38 +08:00
nix.nixPath = [ "nixpkgs=${pkgs.path}" ];
2021-03-29 14:01:46 +08:00
programs.command-not-found.dbPath = "${pkgs.path}/programs.sqlite";
2020-06-20 17:54:21 +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-24 17:13:05 +08:00
boot.kernelParams = if rpi4 then ["cma=64M"] else []; # work around https://github.com/raspberrypi/linux/issues/3208
2021-02-01 19:33:35 +08:00
boot.kernelPackages = if rpi4 then pkgs.linuxPackages_rpi4 else pkgs.linuxPackages_rpi3;
2021-06-02 08:57:07 +08:00
boot.initrd.includeDefaultModules = false;
# work around https://github.com/NixOS/nixpkgs/issues/125354
disabledModules = [ "hardware/device-tree.nix" ];
imports = [ ./device-tree-module.nix ];
nixpkgs.config.packageOverrides = super: let self = super.pkgs; in {
deviceTree = super.callPackage ./device-tree-pkg.nix {};
};
2021-02-01 19:33:35 +08:00
hardware.deviceTree.enable = true;
hardware.deviceTree.base = pkgs.device-tree_rpi;
hardware.deviceTree.overlays = [ "${pkgs.device-tree_rpi.overlays}/rpi-poe.dtbo" ];
2020-06-20 17:54:21 +08:00
2021-03-28 20:42:59 +08:00
fileSystems = {
2020-06-20 17:54:21 +08:00
"/" = {
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"];
2021-07-13 16:55:51 +08:00
nix.trustedUsers = ["root" "nix" "sb"];
2020-06-20 17:54:21 +08:00
}