machine_setup/nix/configuration/configuration.nix

233 lines
6.6 KiB
Nix
Raw Normal View History

2024-12-20 22:37:44 -05:00
{
config,
lib,
pkgs,
home-manager,
...
}:
2024-12-17 15:26:10 -05:00
{
2024-12-20 22:37:44 -05:00
imports = [
./roles/reset
2025-01-20 19:27:49 -05:00
./roles/global_options
./util/unfree_polyfill
2024-12-21 10:18:28 -05:00
./roles/iso
2024-12-20 22:37:44 -05:00
"${
builtins.fetchTarball {
url = "https://github.com/nix-community/disko/archive/refs/tags/v1.9.0.tar.gz";
sha256 = "0j76ar4qz320fakdii4659w5lww8wiz6yb7g47npywqvf2lbp388";
}
}/module.nix"
./roles/boot
./roles/zfs
./roles/network
2024-12-20 22:37:44 -05:00
./roles/firewall
2024-12-23 11:14:18 -05:00
./roles/zsh
2025-01-13 17:59:03 -05:00
./roles/zrepl
2024-12-20 22:37:44 -05:00
./roles/graphics
./roles/sound
./roles/sway
./roles/kanshi
2024-12-20 22:37:44 -05:00
./roles/alacritty
./roles/firefox
./roles/chromium
2024-12-20 22:37:44 -05:00
./roles/emacs
./roles/git
./roles/fonts
./roles/gpg
2024-12-21 10:18:28 -05:00
./roles/waybar
./roles/qemu
2024-12-27 15:44:00 -05:00
./roles/wireguard
2025-01-11 12:09:02 -05:00
./roles/ares
2024-12-31 06:59:22 -05:00
./roles/ssh
2024-12-31 07:37:48 -05:00
./roles/python
2025-01-01 14:10:08 -05:00
./roles/docker
2025-01-01 14:14:55 -05:00
./roles/kubernetes
2025-01-01 19:16:08 -05:00
./roles/rust
2025-01-10 22:54:32 -05:00
./roles/media
./roles/steam
2025-01-14 18:04:04 -05:00
./roles/latex
./roles/launch_keyboard
./roles/lvfs
2025-01-14 21:51:53 -05:00
./roles/nvme
2025-01-14 23:17:26 -05:00
./roles/terraform
2025-01-14 23:50:24 -05:00
./roles/vscode
2025-01-14 23:55:27 -05:00
./roles/wasm
2025-01-17 20:30:16 -05:00
./roles/vnc_client
2025-01-19 13:44:01 -05:00
./roles/chromecast
./roles/memtest86
2025-01-20 19:40:54 -05:00
./roles/kodi
2024-12-20 22:37:44 -05:00
];
2024-12-17 15:26:10 -05:00
2024-12-20 22:37:44 -05:00
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
2024-12-19 18:09:48 -05:00
nix.settings.trusted-users = [ "@wheel" ];
2024-12-17 15:26:10 -05:00
# boot.kernelPackages = pkgs.linuxPackages_6_11;
2024-12-19 19:52:27 -05:00
hardware.enableRedistributableFirmware = true;
2024-12-21 17:15:54 -05:00
services.getty = {
autologinUser = "talexander"; # I use full disk encryption so the user password is irrelevant.
autologinOnce = true;
};
2024-12-17 15:26:10 -05:00
users.mutableUsers = false;
users.users.talexander = {
isNormalUser = true;
createHome = true; # https://github.com/NixOS/nixpkgs/issues/6481
2024-12-20 15:22:46 -05:00
group = "talexander";
2024-12-17 15:26:10 -05:00
extraGroups = [ "wheel" ];
2024-12-20 15:22:46 -05:00
uid = 11235;
2024-12-17 15:26:10 -05:00
packages = with pkgs; [
tree
];
# Generate with `mkpasswd -m scrypt`
hashedPassword = "$7$CU..../....VXvNQ8za3wSGpdzGXNT50/$HcFtn/yvwPMCw4888BelpiAPLAxe/zU87fD.d/N6U48";
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGu+k5lrirokdW5zVdRVBOqEOAvAPlIkG/MdJNc9g5ky"
"sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIEI6mu6I5Jp+Ib0vJxapGHbEShZjyvzV8jz5DnzDrI39AAAABHNzaDo="
"sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIAFNcSXwvy+brYTOGo56G93Ptuq2MmZsjvRWAfMqbmMLAAAABHNzaDo="
];
};
2024-12-20 15:22:46 -05:00
users.groups.talexander.gid = 11235;
2024-12-20 22:37:44 -05:00
home-manager.users.talexander =
{ pkgs, ... }:
{
home.packages = [
pkgs.atool
pkgs.httpie
];
programs.bash.enable = true;
# The state version is required and should stay at the version you
# originally installed.
home.stateVersion = "24.11";
};
2024-12-17 15:26:10 -05:00
# Automatic garbage collection
nix.gc = lib.mkIf (!config.me.buildingIso) {
2024-12-17 15:26:10 -05:00
# Runs nix-collect-garbage --delete-older-than 5d
automatic = true;
randomizedDelaySec = "14m";
2025-01-01 13:31:45 -05:00
options = "--delete-older-than 30d";
2024-12-17 15:26:10 -05:00
};
2025-01-19 10:35:31 -05:00
nix.settings.auto-optimise-store = !config.me.buildingIso;
2024-12-17 15:26:10 -05:00
# Use doas instead of sudo
security.doas.enable = true;
security.doas.wheelNeedsPassword = false;
security.sudo.enable = false;
2024-12-20 22:37:44 -05:00
security.doas.extraRules = [
{
# Retain environment (for example NIX_PATH)
keepEnv = true;
persist = true; # Only ask for a password the first time.
}
];
2024-12-17 15:26:10 -05:00
# Do not use default packages (nixos includes some defaults like nano)
2024-12-20 22:37:44 -05:00
environment.defaultPackages = lib.mkForce [ ];
2024-12-17 15:26:10 -05:00
environment.systemPackages = with pkgs; [
wget
mg
rsync
libinput
htop
tmux
file
usbutils # for lsusb
pciutils # for lspci
2024-12-20 17:06:02 -05:00
ripgrep
2024-12-20 21:06:04 -05:00
strace
2025-01-15 21:12:28 -05:00
ltrace
trace-cmd # ftrace
2024-12-20 21:06:04 -05:00
tcpdump
2024-12-26 21:28:31 -05:00
git-crypt
2025-01-06 14:32:07 -05:00
nix-index-unwrapped
gnumake
2025-01-19 11:05:00 -05:00
ncdu
2024-12-17 15:26:10 -05:00
];
services.openssh = {
enable = true;
settings = {
PasswordAuthentication = false;
KbdInteractiveAuthentication = false;
};
hostKeys = [
{
path = "/persist/ssh/ssh_host_ed25519_key";
type = "ed25519";
}
{
path = "/persist/ssh/ssh_host_rsa_key";
type = "rsa";
bits = 4096;
}
];
};
2024-12-21 10:18:28 -05:00
environment.persistence."/persist" = lib.mkIf (!config.me.buildingIso) {
2024-12-17 15:26:10 -05:00
hideMounts = true;
directories = [
"/var/lib/iwd" # Wifi settings
"/var/lib/nixos" # Contains user information (uids/gids)
2024-12-21 10:18:28 -05:00
"/var/lib/systemd" # Systemd state directory for random seed, persistent timers, core dumps, persist hardware state like backlight and rfkill
"/var/log/journal" # Logs, alternatively set `services.journald.storage = "volatile";` to write to /run/log/journal
2024-12-17 15:26:10 -05:00
];
files = [
2024-12-21 10:18:28 -05:00
"/etc/machine-id" # Systemd unique machine id "otherwise, the system journal may fail to list earlier boots, etc"
2024-12-17 15:26:10 -05:00
"/etc/ssh/ssh_host_rsa_key"
"/etc/ssh/ssh_host_rsa_key.pub"
"/etc/ssh/ssh_host_ed25519_key"
"/etc/ssh/ssh_host_ed25519_key.pub"
];
# users.talexander = {
# directories = [];
# files = [];
# };
};
# Write a list of the currently installed packages to /etc/current-system-packages
environment.etc."current-system-packages".text =
let
packages = builtins.map (p: "${p.name}") config.environment.systemPackages;
sortedUnique = builtins.sort builtins.lessThan (lib.unique packages);
formatted = builtins.concatStringsSep "\n" sortedUnique;
in
2024-12-20 22:37:44 -05:00
formatted;
2024-12-17 15:26:10 -05:00
# nixpkgs.overlays = [
# (final: prev: {
# nix = pkgs-unstable.nix;
# })
# ];
# Copy the NixOS configuration file and link it from the resulting system
# (/run/current-system/configuration.nix). This is useful in case you
# accidentally delete configuration.nix.
# system.copySystemConfiguration = true;
# This option defines the first version of NixOS you have installed on this particular machine,
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
#
# Most users should NEVER change this value after the initial install, for any reason,
# even if you've upgraded your system to a new NixOS release.
#
# This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
# so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how
# to actually do that.
#
# This value being lower than the current NixOS release does NOT mean your system is
# out of date, out of support, or vulnerable.
#
# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
# and migrated your data accordingly.
#
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
system.stateVersion = "24.11"; # Did you read the comment?
}