zion/configuration.nix

221 lines
5.3 KiB
Nix
Raw Normal View History

2022-06-06 23:12:54 +02:00
{ config, inputs, pkgs, lib, ... }:
with pkgs;
{
# Declare system packages
2022-06-06 23:12:54 +02:00
environment.systemPackages = [
libraspberrypi
htop
neovim
git
inputs.agenix.packages.aarch64-linux.default
2022-06-06 23:12:54 +02:00
];
2019-10-11 19:14:18 +02:00
2023-02-27 23:15:32 +01:00
# Enable zswap
zramSwap.enable = true;
2019-10-11 19:14:18 +02:00
# Configure basic SSH access
services.openssh = {
enable = true;
2023-06-08 18:30:16 +02:00
settings = {
PermitRootLogin = "yes";
PasswordAuthentication = false;
};
};
2019-10-15 00:18:57 +02:00
# Cleanup tmp on startup
2023-06-08 18:30:16 +02:00
boot.tmp.cleanOnBoot = true;
2019-10-15 00:18:57 +02:00
# Create coolneng user
2019-10-16 22:17:37 +02:00
users.users.coolneng = {
isNormalUser = true;
home = "/home/coolneng";
extraGroups = [ "wheel" "docker" ];
2020-05-11 06:36:55 +02:00
openssh.authorizedKeys.keys = [
2023-02-20 17:13:12 +01:00
# panacea
2021-02-02 20:04:21 +01:00
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFRqINHR7/zc+c3/PuR+NeSsBHXXzBiEtFWSK6QaxQTW coolneng@panacea"
2023-02-20 17:13:12 +01:00
# caravanserai
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPTBWNtNp+vI2So4vISZX/yQv754ZzXqobFgUP3zk4FY zion"
2020-05-11 06:36:55 +02:00
];
shell = "${fish}/bin/fish";
2019-10-16 22:17:37 +02:00
};
2022-07-12 19:52:41 +02:00
# Set neovim as default editor
2022-07-20 14:21:42 +02:00
programs.neovim = {
enable = true;
defaultEditor = true;
};
2019-10-17 23:20:21 +02:00
# Set timezone and synchronize NTP
time.timeZone = "Europe/Brussels";
services.timesyncd.enable = true;
# Enable ZFS support
2021-03-09 13:24:27 +01:00
boot.supportedFilesystems = [ "zfs" ];
2019-10-18 00:31:34 +02:00
# Don't import encrypted datasets
boot.zfs.requestEncryptionCredentials = false;
2019-10-18 00:31:34 +02:00
# Scrub zpool monthly
services.zfs.autoScrub = {
enable = true;
interval = "monthly";
};
2019-10-18 00:31:34 +02:00
2022-06-06 23:12:54 +02:00
# Run Nix garbage collector, while avoiding recompilation and enable flakes
nix = {
2022-09-30 21:30:28 +02:00
settings = {
auto-optimise-store = true;
experimental-features = [ "nix-command" "flakes" ];
};
gc = {
automatic = true;
options = "--delete-older-than 14d";
dates = "Mon 03:00";
};
extraOptions = ''
keep-outputs = true
2021-01-01 16:52:31 +01:00
keep-derivations = true
gc-keep-outputs = true
'';
2019-11-07 14:25:27 +01:00
};
2022-06-06 23:12:54 +02:00
# Use same version of nixpkgs for nix-shell
nix.nixPath = let path = toString ./.;
in [ "nixpkgs=${inputs.nixpkgs}" "nixos-config=${path}/configuration.nix" ];
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 = {
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
# Keep logs for a week
services.journald.extraConfig = "MaxRetentionSec=1week";
2020-02-23 14:59:06 +01:00
2020-08-20 15:03:45 +02:00
# Increase inotify limits
boot.kernel.sysctl = { "fs.inotify.max_user_watches" = 204800; };
# MOTD message
programs.fish.interactiveShellInit = "${./scripts/motd.sh}";
2022-06-06 12:05:47 +02:00
# NixOS version
system.stateVersion = "22.05";
2022-06-06 23:12:54 +02:00
# Specify secrets
age = {
2022-12-20 15:04:11 +01:00
secrets.wireguard = {
file = secrets/wireguard.age;
owner = "systemd-network";
group = "systemd-network";
};
2022-06-06 23:12:54 +02:00
secrets.syncthing.file = secrets/syncthing.age;
secrets.msmtp.file = secrets/msmtp.age;
secrets.gitea = {
file = secrets/gitea.age;
owner = "gitea";
group = "gitea";
};
secrets.ddclient.file = secrets/ddclient.age;
secrets.miniflux = {
file = secrets/miniflux.age;
owner = "miniflux";
group = "miniflux";
};
2022-06-23 20:10:32 +02:00
secrets.git = {
file = secrets/git.age;
owner = "coolneng";
group = "users";
};
2022-07-20 16:34:14 +02:00
# HACK The owner and group is set by systemd due to the use of DynamicUser
secrets.dendrite = {
file = secrets/dendrite.age;
owner = "63026";
group = "63026";
};
secrets.dendrite-postgres = {
file = secrets/dendrite-postgres.age;
owner = "63026";
group = "63026";
};
2022-07-20 22:38:20 +02:00
secrets.telegram = {
file = secrets/telegram.age;
owner = "matrix-as-telegram";
group = "matrix-as-telegram";
};
2023-04-03 00:50:47 +02:00
secrets.mqtt-sender = {
file = secrets/mqtt-sender.age;
owner = "mosquitto";
group = "mosquitto";
};
secrets.mqtt-receiver = {
file = secrets/mqtt-receiver.age;
owner = "mosquitto";
group = "mosquitto";
};
2023-05-24 14:15:15 +02:00
secrets.nightscout = {
file = secrets/nightscout.age;
owner = "coolneng";
group = "podman";
};
secrets.facebook = {
file = secrets/facebook.age;
owner = "matrix-as-facebook";
group = "matrix-as-facebook";
};
secrets.signal = {
file = secrets/signal.age;
owner = "matrix-as-signal";
group = "matrix-as-signal";
};
2023-01-22 17:53:14 +01:00
identityPaths = [ "/etc/ssh/id_ed25519" ];
2022-06-06 23:12:54 +02:00
};
2022-06-07 00:11:57 +02:00
# Auto-upgrade the system
system.autoUpgrade = {
enable = true;
flake = "/home/coolneng/system";
flags = [
"--update-input"
"agenix"
"--update-input"
"nixpkgs"
"--commit-lock-file"
];
};
# Configure git for auto-upgrade
programs.git = {
enable = true;
config = {
user.name = "coolneng";
user.email = "akasroua@gmail.com";
safe.directory = "/home/coolneng/system";
credential.helper = "store --file ${config.age.secrets.git.path}";
};
};
2022-12-20 15:43:52 +01:00
# Disable man pages
documentation.man.enable = false;
# 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
./modules/device.nix
./modules/containers.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
}