Generalize and split up more files

This commit is contained in:
Jimbo 2024-11-24 20:02:09 -05:00
parent 93541beed7
commit a0447a18da
27 changed files with 161 additions and 156 deletions

View file

@ -1,28 +0,0 @@
{ lib, config, ... }:
{
networking = {
firewall.allowedUDPPorts = [ 51820 ];
nat = {
enable = config.system.wireguard.server.enable;
externalInterface = "eno1";
internalInterfaces = [ "wgs" ];
};
wireguard.interfaces.wgs = {
ips = [ "10.100.0.1/24" ];
listenPort = 51820;
privateKey = config.secrets.wgServerPriv;
peers = [
{ # NixOS Config Key
publicKey = "OKUH/h6YSURI4vgeTZKQD15QsqaygdbTn1mAWzQp9S0=";
allowedIPs = [ "10.100.0.16/28" ];
}
{ # Pixel 9
publicKey = "dPCtjm67adMZCnyL1O2L+uUOk0RbjA9T/tht1r+qcE4=";
allowedIPs = [ "10.100.0.2/32" ];
}
];
};
};
}

View file

@ -3,38 +3,5 @@
boot = {
kernelPackages = pkgs.linuxPackages_latest;
kernel.sysctl."vm.max_map_count" = 2147483642;
initrd = {
systemd = {
enable = true;
services.root-reset = {
description = "Reset BTRFS root and snapshot last boot";
wantedBy = [ "initrd.target" ];
after = [ "dev-nixos-root.device" ];
before = [ "sysroot.mount" ];
unitConfig.DefaultDependencies = "no";
serviceConfig.Type = "oneshot";
script = ''
mkdir -p /mnt
mount /dev/nixos/root /mnt
if [[ -e /mnt/@prev ]]; then
btrfs subvolume delete /mnt/@prev
fi
btrfs subvolume snapshot /mnt/@ /mnt/@prev
btrfs subvolume list -o /mnt/@ | cut -f9 -d' ' | while read subvolume; do
btrfs subvolume delete "/mnt/$subvolume"
done
btrfs subvolume delete /mnt/@
btrfs subvolume create /mnt/@
umount /mnt
'';
};
};
};
};
}

View file

@ -3,27 +3,15 @@
imports = [
./boot
./disko
./filesystems
./hardware
# Apps and programs
../../modules/system
../../modules/system/accounts
../../modules/system/desktop
../../modules/system/programs
../../modules/system/services
# Devices and hardware
../../modules/system/devices
../../modules/system/devices/boot/systemd
../../modules/system/devices/networking/wireless
../../modules/system/devices/networking/firewall/pc
../../modules/system/devices/networking/wireguard/pc
# Extras
../../overlays
../../variables
];
system.lanzaboote.enable = true;
system.wireguard.client.enable = true;
networking.wireguard.interfaces.wgc.ips = [ "10.100.0.23/24" ];
networking.hostName = "redmond";
networking.wireguard.interfaces."${config.ips.wgInt}".ips = [ "${config.ips.wgSpan}.20/24" ];
}

View file

@ -0,0 +1,10 @@
{ ... }:
{
fileSystems = {
"/home/jimbo/JimboNFS" = {
device = "10.100.0.1:/export/JimboNFS";
fsType = "nfs4";
options = [ "x-systemd.automount" "_netdev" "nofail" "noauto" ];
};
};
}

View file

@ -1,27 +1,7 @@
{ config, lib, pkgs, modulesPath, ... }:
{ config, lib, ... }:
{
boot = {
kernelModules = [ "kvm-amd" ];
initrd = {
availableKernelModules = [
"xhci_pci"
"ahci"
"ehci_pci"
"sd_mod"
"sr_mod"
"sdhci_pci"
"rtsx_usb_sdmmc"
];
};
};
fileSystems = {
"/home/jimbo/JimboNFS" = {
device = "${config.ips.wgSpan}.1:/export/JimboNFS";
fsType = "nfs4";
options = ["x-systemd.automount" "_netdev" "nofail" "noauto"];
};
};
boot.kernelModules = [ "kvm-amd" ];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "ehci_pci" "sd_mod" "sr_mod" "sdhci_pci" "rtsx_usb_sdmmc" ];
networking.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";

View file

@ -1 +1 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG9uITpyw5WgxT7UnswueFtyWxAqQCZv4h9DfcDkr+kn
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKsPwxV2qr4IFC63SxPM5bI9iFCbH5wVxorNHYKSvE7i

View file

@ -27,37 +27,6 @@ in {
"vfio_pci"
"vfio_iommu_type1"
];
initrd.systemd = {
enable = true;
services.root-reset = {
description = "Reset root and snapshot last boot";
wantedBy = [ "initrd.target" ];
before = [ "sysroot.mount" ];
after = [ "dev-${config.networking.hostName}-root.device" ];
unitConfig.DefaultDependencies = "no";
serviceConfig.Type = "oneshot";
script = ''
mkdir -p /mnt
mount /dev/${config.networking.hostName}/root /mnt
if [[ -e /mnt/prev ]]; then
btrfs subvolume delete /mnt/prev
fi
btrfs subvolume snapshot /mnt/root /mnt/prev
btrfs subvolume list -o /mnt/root | cut -f9 -d' ' | while read subvolume; do
btrfs subvolume delete "/mnt/$subvolume"
done
btrfs subvolume delete /mnt/root
btrfs subvolume create /mnt/root
umount /mnt
'';
};
};
};
# Use second GPU on boot

View file

@ -134,6 +134,7 @@ in {
"extensions.pocket.enabled" = false;
"extensions.autoDisableScopes" = 0;
"extensions.activeThemeID" = "firefox-compact-dark@mozilla.org";
"toolkit.legacyUserProfileCustomizations.stylesheets" = true;
"toolkit.tabbox.switchByScrolling" = true;

View file

@ -1,6 +1,6 @@
{ ... }:
{
imports = [ ./small ];
home.file.".config/fastfetch/config.jsonc".source = ./config.jsonc;
programs.fastfetch.enable = true;
home.file.".config/fastfetch/config.jsonc".source = ./config.jsonc;
}

View file

@ -1,9 +1,7 @@
{ pkgs, ... }:
{
home = {
packages = with pkgs; [ (pkgs.writeScriptBin "pfetch" "fastfetch --config ~/.config/fastfetch/small.jsonc") ];
file.".config/fastfetch/small.jsonc".source = ./small.jsonc;
packages = with pkgs; [
(pkgs.writeScriptBin "pfetch" "fastfetch --config ~/.config/fastfetch/small.jsonc")
];
};
}

View file

@ -16,7 +16,5 @@
services.mpd-discord-rpc.enable = true;
home.packages = with pkgs; [
mpc-cli
];
home.packages = with pkgs; [ mpc-cli ];
}

View file

@ -2,7 +2,6 @@
{
programs.zsh = {
enable = true;
enableCompletion = false;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
oh-my-zsh = {

View file

@ -1,8 +1,6 @@
{ pkgs, config, ... }:
{
imports = [
./swappy
];
imports = [ ./swappy ];
home.packages = with pkgs; [
(pkgs.writeScriptBin "swayshot" ''

View file

@ -0,0 +1,7 @@
{ ... }:
{
imports = [
./firmware
./systemd
];
}

View file

@ -0,0 +1,4 @@
{ ... }:
{
hardware.enableRedistributableFirmware = true;
}

View file

@ -0,0 +1,6 @@
{ ... }:
{
imports = [ ./root-reset ];
boot.initrd.systemd.enable = true;
}

View file

@ -0,0 +1,30 @@
{ config, ... }:
{
boot.initrd.systemd.services.root-reset = {
description = "Reset root and snapshot last boot";
wantedBy = [ "initrd.target" ];
before = [ "sysroot.mount" ];
after = [ "dev-${config.networking.hostName}-root.device" ];
unitConfig.DefaultDependencies = "no";
serviceConfig.Type = "oneshot";
script = ''
mkdir -p /mnt
mount /dev/${config.networking.hostName}/root /mnt
if [[ -e /mnt/prev ]]; then
btrfs subvolume delete /mnt/prev
fi
btrfs subvolume snapshot /mnt/root /mnt/prev
btrfs subvolume list -o /mnt/root | cut -f9 -d' ' | while read subvolume; do
btrfs subvolume delete "/mnt/$subvolume"
done
btrfs subvolume delete /mnt/root
btrfs subvolume create /mnt/root
umount /mnt
'';
};
}

View file

@ -2,6 +2,7 @@
{
imports = [
./accounts
./boot
./devices
./options
./programs
@ -10,8 +11,5 @@
../extras
];
time.timeZone = "America/Toronto";
programs.nano.enable = false;
hardware.enableRedistributableFirmware = true;
system.stateVersion = "24.05";
}

View file

@ -1,6 +1,9 @@
{ ... }:
{
imports = [ ./wireless ];
imports = [
./wireless
./wireguard
];
networking = {
wireless.enable = false;

View file

@ -0,0 +1,30 @@
{ lib, config, ... }:
{
options.system.wireguard.client.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable the wireguard client";
};
config = lib.mkIf config.system.wireguard.client.enable {
networking = {
firewall = {
allowedUDPPorts = [ 51820 ];
trustedInterfaces = [ "wgc" ];
};
wireguard.interfaces.wgc = {
listenPort = 51820;
privateKey = config.secrets.wgClientPriv;
peers = [
{ # Cyberspark Server
publicKey = "qnOT/lXOJMaQgDUdXpyfGZB2IEyUouRje2m/bCe9ux8=";
allowedIPs = [ "10.100.0.0/24" ];
endpoint = "sv.${config.domains.jim1}:51820";
persistentKeepalive = 25;
}
];
};
};
};
}

View file

@ -0,0 +1,7 @@
{ ... }:
{
imports = [
./client
./server
];
}

View file

@ -0,0 +1,36 @@
{ lib, config, ... }:
{
options.system.wireguard.server.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable the wireguard server";
};
config = lib.mkIf config.system.wireguard.server.enable {
networking = {
firewall.allowedUDPPorts = [ 51820 ];
nat = {
enable = config.system.wireguard.server.enable;
externalInterface = "eno1";
internalInterfaces = [ "wgs" ];
};
wireguard.interfaces.wgs = {
ips = [ "10.100.0.1/24" ];
listenPort = 51820;
privateKey = config.secrets.wgServerPriv;
peers = [
{ # NixOS Config Key
publicKey = "OKUH/h6YSURI4vgeTZKQD15QsqaygdbTn1mAWzQp9S0=";
allowedIPs = [ "10.100.0.16/28" ];
}
{ # Pixel 9
publicKey = "dPCtjm67adMZCnyL1O2L+uUOk0RbjA9T/tht1r+qcE4=";
allowedIPs = [ "10.100.0.2/32" ];
}
];
};
};
};
}

View file

@ -1,12 +1,10 @@
{ config, lib, pkgs, ... }:
{
options.system.wireless = {
enable = lib.mkOption {
options.system.wireless.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable Wifi with iwd";
};
};
config = lib.mkIf config.system.wireless.enable {
networking = {

View file

@ -5,5 +5,6 @@
./fonts
./minimal
./nix
./timezone
];
}

View file

@ -5,6 +5,7 @@
stub-ld.enable = false;
};
programs.nano.enable = false;
programs.less.lessopen = null;
services.logrotate.enable = false;

View file

@ -0,0 +1,4 @@
{ ... }:
{
time.timeZone = "America/Toronto";
}