2021-09-25 16:21:13 +02:00
|
|
|
|
{ hostRegistry, config, lib, pkgs, modulesPath, ... }:
|
2021-09-23 03:32:17 +02:00
|
|
|
|
|
2021-10-08 00:34:39 +02:00
|
|
|
|
let
|
|
|
|
|
# soapysdr = with pkgs; soapysdr.override {
|
|
|
|
|
# extraPackages = [
|
|
|
|
|
# soapyhackrf
|
|
|
|
|
# ];
|
|
|
|
|
# };
|
|
|
|
|
soapysdr = pkgs.soapysdr-with-plugins;
|
|
|
|
|
in
|
2021-09-23 03:32:17 +02:00
|
|
|
|
{
|
|
|
|
|
boot.initrd.availableKernelModules = [ "usbhid" ];
|
|
|
|
|
boot.initrd.kernelModules = [ ];
|
|
|
|
|
boot.kernelModules = [ ];
|
|
|
|
|
boot.extraModulePackages = [ ];
|
2021-10-13 19:29:25 +02:00
|
|
|
|
boot.blacklistedKernelModules = [
|
|
|
|
|
# no watching TV intended
|
|
|
|
|
"dvb_usb_rtl28xxu"
|
|
|
|
|
];
|
2021-09-23 03:32:17 +02:00
|
|
|
|
|
|
|
|
|
fileSystems."/" = {
|
|
|
|
|
device = "/dev/disk/by-label/NIXOS_SD";
|
|
|
|
|
fsType = "ext4";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
fileSystems."/boot/firmware" = {
|
|
|
|
|
device = "/dev/disk/by-label/FIRMWARE";
|
|
|
|
|
fsType = "vfat";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
swapDevices = [ ];
|
|
|
|
|
|
|
|
|
|
hardware.enableRedistributableFirmware = true;
|
|
|
|
|
#networking.wireless.enable = true;
|
2021-10-07 20:19:48 +02:00
|
|
|
|
hardware.deviceTree.enable = false;
|
2021-09-23 03:32:17 +02:00
|
|
|
|
powerManagement.cpuFreqGovernor = lib.mkDefault "performance";
|
|
|
|
|
|
|
|
|
|
boot = {
|
|
|
|
|
loader = {
|
|
|
|
|
grub.enable = false;
|
2021-10-07 20:19:48 +02:00
|
|
|
|
generic-extlinux-compatible.enable = lib.mkDefault true;
|
2021-09-23 03:32:17 +02:00
|
|
|
|
raspberryPi = {
|
|
|
|
|
enable = true;
|
2021-10-07 20:19:48 +02:00
|
|
|
|
version = 4;
|
2021-09-23 03:32:17 +02:00
|
|
|
|
uboot.enable = true;
|
|
|
|
|
firmwareConfig = ''
|
|
|
|
|
gpu_mem=192
|
|
|
|
|
dtparam=audio=on
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
2021-10-07 20:19:48 +02:00
|
|
|
|
kernelPackages = pkgs.linuxPackages_latest;
|
2021-09-23 19:33:40 +02:00
|
|
|
|
# Don't build ZFS for aarch64 (broken?)
|
|
|
|
|
supportedFilesystems = lib.mkForce [ "vfat" "ext4" ];
|
2021-09-23 03:32:17 +02:00
|
|
|
|
|
|
|
|
|
tmpOnTmpfs = true;
|
|
|
|
|
};
|
2021-09-23 19:34:09 +02:00
|
|
|
|
sdImage = {
|
|
|
|
|
compressImage = false;
|
|
|
|
|
imageBaseName = config.networking.hostName;
|
|
|
|
|
firmwareSize = 512;
|
|
|
|
|
};
|
2021-09-23 03:32:17 +02:00
|
|
|
|
|
2021-09-26 01:47:20 +02:00
|
|
|
|
c3d2 = {
|
|
|
|
|
isInHq = false;
|
|
|
|
|
hq.statistics.enable = true;
|
2021-10-14 15:40:19 +02:00
|
|
|
|
pi-sensors = [ {
|
2021-10-07 20:19:48 +02:00
|
|
|
|
type = "dht22";
|
|
|
|
|
pin = 17;
|
|
|
|
|
location = "Schrank";
|
|
|
|
|
} {
|
|
|
|
|
type = "dht22";
|
|
|
|
|
pin = 23;
|
|
|
|
|
location = "Aussen";
|
|
|
|
|
} ];
|
2021-09-26 01:47:20 +02:00
|
|
|
|
};
|
2021-09-23 03:32:17 +02:00
|
|
|
|
|
|
|
|
|
nix = {
|
|
|
|
|
buildCores = 4;
|
|
|
|
|
maxJobs = 2;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
|
hostName = "radiobert"; # Define your hostname.
|
|
|
|
|
useDHCP = false;
|
2021-09-25 16:21:13 +02:00
|
|
|
|
interfaces.eth0.ipv4.addresses = [{
|
|
|
|
|
address = hostRegistry.hosts.${config.networking.hostName}.ip4;
|
|
|
|
|
prefixLength = 26;
|
|
|
|
|
}];
|
|
|
|
|
defaultGateway = "172.20.73.1";
|
2021-10-07 22:06:28 +02:00
|
|
|
|
firewall.enable = false;
|
2021-09-26 20:52:53 +02:00
|
|
|
|
nameservers = [ "172.20.73.8" "9.9.9.9" ];
|
2021-09-23 03:32:17 +02:00
|
|
|
|
};
|
|
|
|
|
|
2021-10-07 22:06:28 +02:00
|
|
|
|
users.users.soapysdr = {
|
|
|
|
|
isSystemUser = true;
|
|
|
|
|
group = "soapysdr";
|
|
|
|
|
};
|
|
|
|
|
users.groups.soapysdr = {};
|
|
|
|
|
systemd.services.soapysdr-server = {
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
serviceConfig = {
|
2021-10-08 00:34:39 +02:00
|
|
|
|
ExecStart = "${soapysdr}/bin/SoapySDRServer --bind";
|
2021-10-07 22:06:28 +02:00
|
|
|
|
User = "soapysdr";
|
|
|
|
|
Group = "soapysdr";
|
|
|
|
|
ProtectSystem = "full";
|
|
|
|
|
ProtectHome = true;
|
|
|
|
|
};
|
|
|
|
|
};
|
2021-09-23 03:32:17 +02:00
|
|
|
|
|
2021-10-13 21:43:23 +02:00
|
|
|
|
users.users.dump1090 = {
|
|
|
|
|
isSystemUser = true;
|
|
|
|
|
group = "dump10190";
|
2021-09-26 01:47:20 +02:00
|
|
|
|
};
|
2021-10-13 21:43:23 +02:00
|
|
|
|
users.groups.dump1090 = {};
|
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
|
"d /tmp/dump1090 0755 dump1090 dump1090 -"
|
|
|
|
|
];
|
|
|
|
|
systemd.services.dump1090 = {
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
serviceConfig = {
|
|
|
|
|
ExecStart = "${pkgs.dump1090_sdrplus}/bin/dump1090 --aggressive --net";
|
|
|
|
|
User = "dump1090";
|
|
|
|
|
Group = "dump1090";
|
|
|
|
|
ProtectSystem = "full";
|
|
|
|
|
ProtectHome = true;
|
|
|
|
|
WorkingDirectory = "/tmp/dump1090";
|
|
|
|
|
WritablePaths = "/tmp/dump1090";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: `services.collectd.plugins.exec` is already defined by pi-sensors
|
|
|
|
|
# (https://github.com/NixOS/nixpkgs/pull/141551)
|
2021-10-14 15:40:19 +02:00
|
|
|
|
services.collectd.extraConfig =
|
2021-10-13 21:43:23 +02:00
|
|
|
|
let
|
|
|
|
|
distanceRb = pkgs.fetchurl {
|
|
|
|
|
url = "https://github.com/djberg96/gis-distance/raw/main/lib/gis/distance.rb";
|
|
|
|
|
sha256 = "1m9zzikcl5pzad66r8vnlj2p2hbbcqb8vdcf34nrhyd4mg1wkgkh";
|
|
|
|
|
};
|
|
|
|
|
libDir = pkgs.runCommandNoCC "libdir" {} ''
|
|
|
|
|
mkdir $out
|
|
|
|
|
cp ${distanceRb} $out/distance.rb
|
|
|
|
|
'';
|
|
|
|
|
in ''
|
2021-10-14 15:40:19 +02:00
|
|
|
|
<Plugin exec>
|
|
|
|
|
Exec "${config.services.collectd.user}" "${pkgs.ruby}/bin/ruby" "-I${libDir}" "${./collectd-adsb.rb}"
|
|
|
|
|
</Plugin>
|
2021-10-13 21:43:23 +02:00
|
|
|
|
'';
|
2021-09-26 01:47:20 +02:00
|
|
|
|
|
2021-09-23 03:32:17 +02:00
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
|
libraspberrypi
|
2021-10-07 20:19:48 +02:00
|
|
|
|
raspberrypi-eeprom
|
|
|
|
|
vim
|
|
|
|
|
wget
|
2021-09-24 00:52:32 +02:00
|
|
|
|
dump1090_sdrplus
|
2021-10-07 20:19:48 +02:00
|
|
|
|
soapysdr-with-plugins
|
2021-10-09 23:03:22 +02:00
|
|
|
|
hackrf
|
2021-09-23 03:32:17 +02:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
programs.tmux.enable = true;
|
|
|
|
|
|
|
|
|
|
# Do not log to flash:
|
|
|
|
|
services.journald.extraConfig = ''
|
|
|
|
|
Storage=volatile
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
# Enable the OpenSSH daemon.
|
|
|
|
|
services.openssh = {
|
|
|
|
|
enable = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Allow access to USB
|
|
|
|
|
services.udev.extraRules = ''
|
|
|
|
|
SUBSYSTEM=="usb", MODE:="0666"
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
# This value determines the NixOS release from which the default
|
|
|
|
|
# settings for stateful data, like file locations and database versions
|
|
|
|
|
# on your system were taken. It‘s perfectly fine and recommended to leave
|
|
|
|
|
# this value at the release version of the first install of this system.
|
|
|
|
|
# Before changing this value read the documentation for this option
|
|
|
|
|
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
|
|
|
|
|
system.stateVersion = "21.05"; # Did you read the comment?
|
|
|
|
|
}
|