2022-05-02 01:55:43 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with pkgs;
|
|
|
|
|
|
|
|
{
|
2019-10-11 14:26:37 +02:00
|
|
|
# NixOS wants to enable GRUB by default
|
|
|
|
boot.loader.grub.enable = false;
|
2020-05-11 06:36:55 +02:00
|
|
|
|
2020-12-22 14:49:13 +01:00
|
|
|
# A bunch of boot parameters needed for optimal runtime on RPi 4B
|
2022-05-02 01:55:43 +02:00
|
|
|
boot.kernelPackages = linuxPackages_rpi4;
|
2021-02-03 03:41:40 +01:00
|
|
|
boot.kernelParams = [
|
|
|
|
"zfs.zfs_arc_max=134217728"
|
|
|
|
"console=TTYAMA0,115200"
|
|
|
|
"console=tty1"
|
|
|
|
"8250.nr_uarts=1"
|
2021-05-15 16:51:46 +02:00
|
|
|
"iomem=relaxed"
|
|
|
|
"strict-devmem=0"
|
2021-02-03 03:41:40 +01:00
|
|
|
];
|
2022-05-04 19:28:18 +02:00
|
|
|
|
|
|
|
# Enable SATA-HAT GPIO features
|
2019-10-22 22:04:06 +02:00
|
|
|
boot.loader.raspberryPi = {
|
|
|
|
enable = true;
|
2020-12-22 14:49:13 +01:00
|
|
|
version = 4;
|
2022-05-04 19:28:18 +02:00
|
|
|
firmwareConfig = ''
|
|
|
|
iomem=relaxed
|
|
|
|
strict-devmem=0
|
|
|
|
dtoverlay=pwm-2chan,pin=12,func=4,pin2=13,func2=4
|
|
|
|
dtoverlay=w1-gpio
|
|
|
|
dtparam=i2c1=on
|
|
|
|
'';
|
2020-05-09 00:22:43 +02:00
|
|
|
};
|
2019-10-22 22:04:06 +02:00
|
|
|
|
2022-05-02 01:55:43 +02:00
|
|
|
environment.systemPackages = [ libraspberrypi htop vim ];
|
2019-10-11 19:14:18 +02:00
|
|
|
|
2022-05-04 19:28:18 +02:00
|
|
|
# Load PWM hardware timers
|
|
|
|
boot.kernelModules = [ "pwm_bcm2835" "w1-gpio" ];
|
|
|
|
hardware.deviceTree = {
|
|
|
|
enable = true;
|
|
|
|
filter = "*-rpi-*.dtb";
|
|
|
|
overlays = [
|
|
|
|
{
|
|
|
|
name = "pwm-2chan";
|
|
|
|
dtboFile = "${device-tree_rpi.overlays}/pwm-2chan.dtbo";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "w1-gpio";
|
|
|
|
dtboFile = "${device-tree_rpi.overlays}/w1-gpio.dtbo";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
# Enable I2C
|
|
|
|
hardware.i2c.enable = true;
|
|
|
|
|
2022-05-02 01:55:43 +02:00
|
|
|
# Add a swap file
|
2020-05-11 06:36:55 +02:00
|
|
|
swapDevices = [{
|
|
|
|
device = "/swapfile";
|
2020-12-22 14:49:13 +01:00
|
|
|
size = 4096;
|
2020-05-11 06:36:55 +02:00
|
|
|
}];
|
2019-10-11 19:14:18 +02:00
|
|
|
|
|
|
|
# Configure basic SSH access
|
2019-10-22 22:04:06 +02:00
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
|
|
|
permitRootLogin = "yes";
|
|
|
|
};
|
2019-10-15 00:18:57 +02:00
|
|
|
|
|
|
|
# Cleanup tmp on startup
|
|
|
|
boot.cleanTmpDir = true;
|
|
|
|
|
2019-10-17 01:28:40 +02:00
|
|
|
# Create coolneng user
|
2019-10-16 22:17:37 +02:00
|
|
|
users.users.coolneng = {
|
|
|
|
isNormalUser = true;
|
|
|
|
home = "/home/coolneng";
|
2020-10-28 01:19:35 +01:00
|
|
|
extraGroups = [ "wheel" "docker" ];
|
2020-05-11 06:36:55 +02:00
|
|
|
openssh.authorizedKeys.keys = [
|
2021-02-02 20:04:21 +01:00
|
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFRqINHR7/zc+c3/PuR+NeSsBHXXzBiEtFWSK6QaxQTW coolneng@panacea"
|
2020-05-11 06:36:55 +02:00
|
|
|
];
|
2022-05-02 01:55:43 +02:00
|
|
|
shell = "${fish}/bin/fish";
|
2019-10-16 22:17:37 +02:00
|
|
|
};
|
|
|
|
|
2019-10-17 01:28:40 +02:00
|
|
|
# Set vim as default editor
|
|
|
|
programs.vim.defaultEditor = true;
|
|
|
|
|
2019-10-17 23:20:21 +02:00
|
|
|
# Set timezone and synchronize NTP
|
|
|
|
time.timeZone = "Europe/Brussels";
|
|
|
|
services.timesyncd.enable = true;
|
|
|
|
|
2020-03-29 06:21:19 +02:00
|
|
|
# Enable ZFS support
|
2021-03-09 13:24:27 +01:00
|
|
|
boot.supportedFilesystems = [ "zfs" ];
|
2019-10-18 00:31:34 +02:00
|
|
|
|
2021-05-21 01:27:08 +02:00
|
|
|
# Don't import encrypted datasets
|
|
|
|
boot.zfs.requestEncryptionCredentials = false;
|
|
|
|
|
2019-10-18 00:31:34 +02:00
|
|
|
# Scrub zpool monthly
|
2019-10-22 22:04:06 +02:00
|
|
|
services.zfs.autoScrub = {
|
|
|
|
enable = true;
|
|
|
|
interval = "monthly";
|
|
|
|
};
|
2019-10-18 00:31:34 +02:00
|
|
|
|
2019-10-18 00:04:03 +02:00
|
|
|
# Auto-upgrade the system and reboot if needed
|
2019-10-22 22:04:06 +02:00
|
|
|
system.autoUpgrade = {
|
|
|
|
enable = true;
|
2020-02-21 12:24:13 +01:00
|
|
|
allowReboot = true;
|
2019-10-23 00:51:57 +02:00
|
|
|
};
|
|
|
|
|
2021-01-01 16:52:31 +01:00
|
|
|
# Run Nix garbage collector, while avoiding recompilation
|
2020-03-29 06:21:19 +02:00
|
|
|
nix = {
|
2022-03-21 16:25:09 +01:00
|
|
|
settings.auto-optimise-store = true;
|
2020-03-29 06:21:19 +02:00
|
|
|
gc = {
|
|
|
|
automatic = true;
|
2020-10-28 01:18:25 +01:00
|
|
|
options = "--delete-older-than 14d";
|
2020-03-29 06:21:19 +02:00
|
|
|
};
|
|
|
|
extraOptions = ''
|
|
|
|
keep-outputs = true
|
2021-01-01 16:52:31 +01:00
|
|
|
keep-derivations = true
|
2020-03-29 06:21:19 +02:00
|
|
|
gc-keep-outputs = true
|
|
|
|
'';
|
2019-11-07 14:25:27 +01:00
|
|
|
};
|
|
|
|
|
2019-11-06 23:04:16 +01:00
|
|
|
# Configure fish shell
|
2019-11-15 00:55:48 +01:00
|
|
|
programs.fish.enable = true;
|
2020-04-22 22:50:13 +02:00
|
|
|
users.users.root = {
|
2022-05-02 01:55:43 +02:00
|
|
|
shell = "${fish}/bin/fish";
|
2020-05-11 06:36:55 +02:00
|
|
|
openssh.authorizedKeys.keys = [
|
2021-02-02 20:04:21 +01:00
|
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFRqINHR7/zc+c3/PuR+NeSsBHXXzBiEtFWSK6QaxQTW coolneng@panacea"
|
2020-05-11 06:36:55 +02:00
|
|
|
];
|
2020-04-22 22:50:13 +02:00
|
|
|
};
|
2019-11-06 23:04:16 +01:00
|
|
|
|
2020-02-23 14:59:06 +01:00
|
|
|
# Rotate logs after 7 days
|
|
|
|
services.journald.extraConfig = "SystemMaxFiles=7";
|
|
|
|
|
2020-08-20 15:03:45 +02:00
|
|
|
# Increase inotify limits
|
|
|
|
boot.kernel.sysctl = { "fs.inotify.max_user_watches" = 204800; };
|
|
|
|
|
2021-02-11 05:06:24 +01:00
|
|
|
# MOTD message
|
|
|
|
programs.fish.interactiveShellInit = "${./scripts/motd.sh}";
|
|
|
|
|
2019-10-17 01:01:20 +02:00
|
|
|
# Import other configuration modules
|
2019-11-06 23:04:16 +01:00
|
|
|
imports = [
|
2020-09-06 00:39:40 +02:00
|
|
|
./modules/hardware-configuration.nix
|
2019-11-06 23:04:16 +01:00
|
|
|
./modules/networking.nix
|
2019-11-07 14:25:27 +01:00
|
|
|
./modules/datasync.nix
|
2019-11-10 23:40:31 +01:00
|
|
|
./modules/webstack.nix
|
2019-11-16 10:55:10 +01:00
|
|
|
./modules/devops.nix
|
2020-09-06 00:39:40 +02:00
|
|
|
./modules/monitoring.nix
|
2020-11-30 02:03:58 +01:00
|
|
|
./modules/periodic.nix
|
2020-12-28 18:42:26 +01:00
|
|
|
./modules/communication.nix
|
2021-01-19 00:14:57 +01:00
|
|
|
./modules/information.nix
|
2019-11-06 23:04:16 +01:00
|
|
|
];
|
2019-10-23 00:51:57 +02:00
|
|
|
|
2019-10-11 14:26:37 +02:00
|
|
|
}
|