You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
3.2 KiB

  1. { host, rpi4, experimental-users ? false }:
  2. { config, pkgs, ... }:
  3. let
  4. m-labs = import (fetchTarball https://nixbld.m-labs.hk/channel/custom/artiq/full/artiq-full/nixexprs.tar.xz) { inherit pkgs; };
  5. in
  6. {
  7. deployment.targetHost = host;
  8. deployment.hasFastConnection = true;
  9. nix.nixPath = [ "nixpkgs=${pkgs.path}" ];
  10. programs.command-not-found.dbPath = "${pkgs.path}/programs.sqlite";
  11. nixpkgs.system = "aarch64-linux";
  12. boot.loader.grub.enable = false;
  13. boot.loader.generic-extlinux-compatible.enable = true;
  14. boot.kernelParams = if rpi4 then ["cma=64M"] else []; # work around https://github.com/raspberrypi/linux/issues/3208
  15. boot.kernelPackages = if rpi4 then pkgs.linuxPackages_rpi4 else pkgs.linuxPackages_rpi3;
  16. boot.initrd.includeDefaultModules = false;
  17. # work around https://github.com/NixOS/nixpkgs/issues/125354
  18. disabledModules = [ "hardware/device-tree.nix" ];
  19. imports = [ ./device-tree-module.nix ];
  20. nixpkgs.config.packageOverrides = super: let self = super.pkgs; in {
  21. deviceTree = super.callPackage ./device-tree-pkg.nix {};
  22. };
  23. hardware.deviceTree.enable = true;
  24. hardware.deviceTree.base = pkgs.device-tree_rpi;
  25. hardware.deviceTree.overlays = [ "${pkgs.device-tree_rpi.overlays}/rpi-poe.dtbo" ];
  26. fileSystems = {
  27. "/" = {
  28. device = "/dev/disk/by-label/NIXOS_SD";
  29. fsType = "ext4";
  30. };
  31. };
  32. services.openssh.enable = true;
  33. services.openssh.passwordAuthentication = false;
  34. services.openssh.gatewayPorts = "clientspecified";
  35. services.openssh.extraConfig =
  36. ''
  37. StreamLocalBindUnlink yes
  38. '';
  39. programs.mosh.enable = true;
  40. networking.hostName = host;
  41. networking.firewall.allowedTCPPorts = if host == "rpi-2" then [ 6000 ] else [];
  42. time.timeZone = "Asia/Hong_Kong";
  43. users.extraGroups.plugdev = { };
  44. users.mutableUsers = false;
  45. users.defaultUserShell = pkgs.fish;
  46. users.extraUsers = (import ./common-users.nix { inherit pkgs; }) //
  47. (pkgs.lib.optionalAttrs experimental-users (import ./experimental-users.nix { inherit pkgs; })) // {
  48. nix = {
  49. isNormalUser = true;
  50. };
  51. nixbld = {
  52. isNormalUser = true;
  53. extraGroups = ["plugdev" "dialout"];
  54. openssh.authorizedKeys.keys = [
  55. "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCxqGdllmXCeadFvqhpWpPfeh/sSiORxCJQO6wCEnkctoYYn9chegj5tXz5dm7WvXQt73pFMytyXBXKidMMXpW2pTxLXVt3tV2rWf1MspznyMHND1xJTXZzPvmF3YiwMvJ2UkLCiW0ixlKn4z30rcsC+jn+aunNo8lsRCNeIIhHpe1JollM05w2YXE0/BUXTXDpqBXWPPvs0GdsSecwWMMhwvVQAFyms1aSevEPADrHa6Zbk8+MnS5FMFrPiJc8RSEsPkG0OOsAG1gWFyKqT5nXHpgcK1AjO5YOlBKfj//b8yLppP3BRmvnulnAJ9+uscWfzxi3cdofgcl4sT/J16Dh hydra-queue-runner@nixbld"
  56. ];
  57. };
  58. };
  59. security.sudo.wheelNeedsPassword = false;
  60. services.udev.packages = [ m-labs.openocd ];
  61. services.udev.extraRules = (import ./extra-udev.nix);
  62. documentation.enable = false;
  63. environment.systemPackages = with pkgs; [
  64. psmisc wget vim git sshfs usbutils uhubctl lm_sensors file telnet mosh tmux xc3sprog m-labs.openocd screen gdb minicom picocom
  65. ];
  66. programs.fish.enable = true;
  67. programs.wireshark.enable = true;
  68. nix.binaryCachePublicKeys = ["nixbld.m-labs.hk-1:5aSRVA5b320xbNvu30tqxVPXpld73bhtOeH6uAjRyHc="];
  69. nix.binaryCaches = ["https://cache.nixos.org" "https://nixbld.m-labs.hk"];
  70. nix.trustedUsers = ["root" "nix" "sb"];
  71. }