2022-04-28 17:24:48 +02:00
|
|
|
{ config, lib, pkgs, inputs, ... }:
|
2020-04-16 19:14:10 +02:00
|
|
|
|
2021-11-16 16:12:01 +01:00
|
|
|
with pkgs;
|
|
|
|
|
2022-10-18 00:18:59 +02:00
|
|
|
{
|
2020-04-16 19:14:10 +02:00
|
|
|
# Kernel configuration
|
|
|
|
boot = {
|
2023-03-22 23:21:10 +01:00
|
|
|
kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
|
2024-01-05 21:30:49 +01:00
|
|
|
kernelParams =
|
2024-02-08 17:34:59 +01:00
|
|
|
[ "zfs.zfs_arc_max=8589934592" "zfs.zfs_arc_min=1073741824" ];
|
2023-01-19 12:52:49 +01:00
|
|
|
blacklistedKernelModules = [ "btusb" "bluetooth" ];
|
2020-04-16 19:14:10 +02:00
|
|
|
supportedFilesystems = [ "zfs" ];
|
2021-08-09 02:11:33 +02:00
|
|
|
zfs = {
|
|
|
|
requestEncryptionCredentials = true;
|
|
|
|
enableUnstable = true;
|
|
|
|
};
|
2020-04-16 19:14:10 +02:00
|
|
|
};
|
|
|
|
|
2024-01-05 21:30:49 +01:00
|
|
|
# Device firmware updates
|
2021-05-05 00:40:14 +02:00
|
|
|
services.fwupd.enable = true;
|
2020-04-16 19:14:10 +02:00
|
|
|
|
2024-01-08 03:06:19 +01:00
|
|
|
# Secure boot using lanzaboote
|
2020-04-16 19:14:10 +02:00
|
|
|
boot.loader = {
|
2020-05-08 21:53:52 +02:00
|
|
|
efi.canTouchEfiVariables = true;
|
|
|
|
systemd-boot = {
|
2024-01-08 03:06:19 +01:00
|
|
|
enable = false;
|
2020-04-16 19:14:10 +02:00
|
|
|
configurationLimit = 50;
|
2021-02-17 03:06:37 +01:00
|
|
|
editor = false;
|
2020-04-16 19:14:10 +02:00
|
|
|
};
|
2020-09-13 16:58:56 +02:00
|
|
|
timeout = 3;
|
2020-04-16 19:14:10 +02:00
|
|
|
};
|
2024-01-08 03:06:19 +01:00
|
|
|
boot.lanzaboote = {
|
|
|
|
enable = true;
|
|
|
|
pkiBundle = "/etc/secureboot";
|
|
|
|
};
|
2020-04-16 19:14:10 +02:00
|
|
|
|
2021-08-08 20:56:16 +02:00
|
|
|
# Run Nix garbage collector and enable flakes
|
2020-04-16 19:14:10 +02:00
|
|
|
nix = {
|
2022-01-30 22:06:17 +01:00
|
|
|
settings = {
|
|
|
|
auto-optimise-store = true;
|
|
|
|
trusted-users = [ "root" "coolneng" ];
|
|
|
|
};
|
2020-04-16 19:14:10 +02:00
|
|
|
gc = {
|
|
|
|
automatic = true;
|
2020-09-03 02:36:54 +02:00
|
|
|
options = "--delete-older-than 7d";
|
2021-03-23 00:14:00 +01:00
|
|
|
dates = "Tue 23:00";
|
2020-04-16 19:14:10 +02:00
|
|
|
};
|
|
|
|
extraOptions = ''
|
|
|
|
keep-outputs = true
|
2020-09-30 12:12:00 +02:00
|
|
|
keep-derivations = true
|
2020-04-16 19:14:10 +02:00
|
|
|
gc-keep-outputs = true
|
2021-08-08 20:56:16 +02:00
|
|
|
experimental-features = nix-command flakes
|
2020-04-16 19:14:10 +02:00
|
|
|
'';
|
2021-11-16 16:12:01 +01:00
|
|
|
package = nixUnstable;
|
2020-04-16 19:14:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
# Clean tmp directory on shutdown
|
2023-04-18 12:35:55 +02:00
|
|
|
boot.tmp.cleanOnBoot = true;
|
2020-04-16 19:14:10 +02:00
|
|
|
|
2023-09-09 08:18:15 +02:00
|
|
|
# Keep logs for a month
|
|
|
|
services.journald.extraConfig = "MaxRetentionSec=4week";
|
2020-04-18 21:04:14 +02:00
|
|
|
|
2020-04-22 22:13:03 +02:00
|
|
|
# Scrub zpool monthly
|
|
|
|
services.zfs.autoScrub = {
|
|
|
|
enable = true;
|
|
|
|
interval = "monthly";
|
|
|
|
};
|
|
|
|
|
|
|
|
# Set timezone and synchronize NTP
|
2023-07-14 18:34:26 +02:00
|
|
|
time.timeZone = "Europe/Brussels";
|
2023-01-19 12:28:05 +01:00
|
|
|
services.chrony.enable = true;
|
2020-04-22 22:13:03 +02:00
|
|
|
|
2020-05-08 21:53:52 +02:00
|
|
|
# NixOS version
|
2024-01-05 21:32:05 +01:00
|
|
|
system.stateVersion = "24.05";
|
2020-05-08 21:53:52 +02:00
|
|
|
|
2020-05-09 01:17:35 +02:00
|
|
|
# Create coolneng user
|
|
|
|
users.users.coolneng = {
|
|
|
|
isNormalUser = true;
|
|
|
|
home = "/home/coolneng";
|
2024-01-05 21:52:58 +01:00
|
|
|
extraGroups = [ "wheel" "video" "audio" "lp" ];
|
2021-11-16 16:12:01 +01:00
|
|
|
shell = fish;
|
2020-05-11 06:40:41 +02:00
|
|
|
};
|
|
|
|
|
2021-08-09 22:59:07 +02:00
|
|
|
# Set shell for root user
|
2021-11-16 16:12:01 +01:00
|
|
|
users.users.root.shell = fish;
|
2020-05-11 06:40:41 +02:00
|
|
|
|
2021-08-09 02:10:51 +02:00
|
|
|
# Specify secrets
|
2021-08-13 10:48:58 +02:00
|
|
|
age = {
|
2022-06-08 16:44:07 +02:00
|
|
|
secrets.wireguard = {
|
|
|
|
file = secrets/wireguard.age;
|
|
|
|
owner = "systemd-network";
|
|
|
|
group = "systemd-network";
|
|
|
|
};
|
2021-08-13 11:00:13 +02:00
|
|
|
secrets.syncthing.file = secrets/syncthing.age;
|
2022-01-27 00:29:15 +01:00
|
|
|
secrets.samba-ugent.file = secrets/samba-ugent.age;
|
2022-05-02 05:47:52 +02:00
|
|
|
secrets.msmtp.file = secrets/msmtp.age;
|
2021-12-07 10:53:59 +01:00
|
|
|
identityPaths = [ "/etc/ssh/id_ed25519" ];
|
2021-08-13 10:48:58 +02:00
|
|
|
};
|
2021-08-09 02:10:51 +02:00
|
|
|
|
2022-04-28 17:24:48 +02:00
|
|
|
# Use same version of nixpkgs for nix-shell
|
|
|
|
nix.nixPath = let path = toString ./.;
|
|
|
|
in [ "nixpkgs=${inputs.nixpkgs}" "nixos-config=${path}/configuration.nix" ];
|
|
|
|
|
2022-05-02 00:14:06 +02:00
|
|
|
# Auto-upgrade the system
|
|
|
|
system.autoUpgrade = {
|
2023-07-14 18:34:26 +02:00
|
|
|
enable = true;
|
2022-05-02 00:14:06 +02:00
|
|
|
dates = "22:30";
|
|
|
|
flake = "/home/coolneng/Projects/panacea";
|
2024-02-07 22:14:16 +01:00
|
|
|
flags = [ "--update-input" "nixpkgs" "--commit-lock-file" ];
|
2022-05-02 00:14:06 +02:00
|
|
|
};
|
2023-04-02 22:43:36 +02:00
|
|
|
|
|
|
|
# Add required dependencies to the auto-upgrade service
|
2022-10-27 12:31:59 +02:00
|
|
|
systemd.services.nixos-upgrade.path = [
|
|
|
|
coreutils
|
|
|
|
gnutar
|
|
|
|
xz.bin
|
|
|
|
gzip
|
|
|
|
gitMinimal
|
|
|
|
config.nix.package.out
|
|
|
|
config.programs.ssh.package
|
|
|
|
git-crypt
|
2023-05-04 10:08:10 +02:00
|
|
|
git-lfs
|
2024-01-05 20:24:49 +01:00
|
|
|
inputs.agenix.packages.${config.nixpkgs.localSystem.system}.default
|
2022-10-27 12:31:59 +02:00
|
|
|
];
|
2022-05-02 00:14:06 +02:00
|
|
|
|
2022-05-16 14:38:45 +02:00
|
|
|
# Configure git for auto-upgrade
|
|
|
|
programs.git = {
|
|
|
|
enable = true;
|
|
|
|
config = {
|
2022-05-23 01:58:28 +02:00
|
|
|
user.name = "coolneng";
|
2022-05-16 14:38:45 +02:00
|
|
|
user.email = "akasroua@gmail.com";
|
|
|
|
safe.directory = "/home/coolneng/Projects/panacea";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-06-08 16:43:53 +02:00
|
|
|
# Enable fish package completion
|
|
|
|
programs.fish.enable = true;
|
|
|
|
|
2023-02-11 15:18:44 +01:00
|
|
|
# Enable nix-index
|
|
|
|
programs.command-not-found.enable = false;
|
|
|
|
programs.nix-index = {
|
|
|
|
enable = true;
|
|
|
|
enableFishIntegration = true;
|
|
|
|
};
|
|
|
|
|
2020-04-18 21:04:14 +02:00
|
|
|
# Import other configuration modules
|
|
|
|
imports = [
|
2020-09-03 02:36:09 +02:00
|
|
|
./modules/hardware-configuration.nix
|
2020-04-24 04:08:44 +02:00
|
|
|
./modules/software.nix
|
2020-04-18 21:04:14 +02:00
|
|
|
./modules/networking.nix
|
2020-04-22 22:13:03 +02:00
|
|
|
./modules/gui.nix
|
2020-05-09 18:53:22 +02:00
|
|
|
./modules/datasync.nix
|
2020-05-08 21:53:52 +02:00
|
|
|
./modules/audio.nix
|
2020-05-09 18:45:10 +02:00
|
|
|
./modules/development.nix
|
2020-05-14 03:04:30 +02:00
|
|
|
./modules/printing.nix
|
2020-08-10 23:45:26 +02:00
|
|
|
./modules/periodic.nix
|
2020-09-03 02:36:09 +02:00
|
|
|
./modules/power.nix
|
2022-05-02 05:47:52 +02:00
|
|
|
./modules/monitoring.nix
|
2020-04-18 21:04:14 +02:00
|
|
|
];
|
|
|
|
|
2020-04-16 19:14:10 +02:00
|
|
|
}
|