refactor: reorganized systems

This commit is contained in:
Alejandro Angulo 2023-03-04 07:59:23 -08:00
parent 73f0dcd6ee
commit 1231503914
Signed by: alejandro-angulo
GPG key ID: 75579581C74554B6
10 changed files with 0 additions and 155 deletions

View file

@ -0,0 +1,184 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{
config,
pkgs,
...
}: {
imports = [
# Include the results of the hardware scan.
./hardware-configuration-zfs.nix
./zfs.nix
./vpn.nix
];
nixpkgs.config.allowUnfree = true;
# Make ready for nix flakes
nix.package = pkgs.nixVersions.stable;
nix.extraOptions = ''
experimental-features = nix-command flakes
'';
networking = {
hostName = "carbon"; # Define your hostname.
networkmanager.enable = true; # Enables wireless support via wpa_supplicant.
#wg-quick.interfaces = {
#wg0 = {
#address = [ "10.10.13.25/32" ];
#dns = [ "192.168.113.69" ];
#listenPort = 51820;
#privateKeyFile = "/home/alejandro/wireguard_keys/carbon.pub";
#peers = [
#{
#publicKey = "HGm7lx+DbACPxEN7gaiuz4XklV/RdzmBj//FBSO7QUU=";
#allowedIPs = [ "10.13.13.0/24" "192.168.113.0/24" ];
#endpoint = "wg.kilonull.com:51820";
#}
#];
#};
#};
};
# Set your time zone.
time.timeZone = "America/Los_Angeles";
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Select internationalisation properties.
# i18n.defaultLocale = "en_US.UTF-8";
# console = {
# font = "Lat2-Terminus16";
# keyMap = "us";
# };
# Enable the X11 windowing system.
# services.xserver.enable = true;
# Configure keymap in X11
# services.xserver.layout = "us";
# services.xserver.xkbOptions = "eurosign:e";
# Enable CUPS to print documents.
# services.printing.enable = true;
# Enable sound.
# sound.enable = true;
# hardware.pulseaudio.enable = true;
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
# Define a user account. Don't forget to set a password with passwd.
users.users.alejandro = {
isNormalUser = true;
extraGroups = ["wheel" "video" "networkmanager"];
shell = pkgs.zsh;
};
fonts.fonts = with pkgs; [
(nerdfonts.override {fonts = ["Hack"];})
];
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
git
vim_configurable # Using this instead of vim for python3 support
wget
firefox
wl-clipboard
stow
tmux
zsh
home-manager
sanoid
killall
usbutils
# Below 3 installed for sanoid
pv
lzop
mbuffer
# Installed for gammastep
geoclue2
wireguard-tools
prusa-slicer
traceroute
gnumake
hugo
nixos-generators
vlc
];
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
programs.zsh.enable = true;
programs.light.enable = true;
programs.sway = {
enable = true;
wrapperFeatures.gtk = true; # so that gtk works properly
extraPackages = with pkgs; [
swaylock
swayidle
wl-clipboard
mako
alacritty
rofi
waybar
pavucontrol
];
};
# List services that you want to enable:
# Enable the OpenSSH daemon.
services.openssh.enable = true;
services.avahi.enable = true;
services.geoclue2 = {
enable = true;
#appConfig."gammastep" = {
#isAllowed = true;
#isSystem = true;
#users = ["1000"];
#};
};
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "21.11"; # Did you read the comment?
}

View file

@ -0,0 +1,114 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = ["xhci_pci" "nvme" "usb_storage" "sd_mod"];
boot.initrd.kernelModules = [];
boot.kernelModules = ["kvm-intel"];
boot.extraModulePackages = [];
fileSystems."/" = {
device = "rpool_/nixos/ROOT/default";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/boot" = {
device = "bpool_/nixos/BOOT/default";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/home" = {
device = "rpool_/nixos/DATA/default/home";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/root" = {
device = "rpool_/nixos/DATA/default/root";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/srv" = {
device = "rpool_/nixos/DATA/default/srv";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/usr/local" = {
device = "rpool_/nixos/DATA/default/usr/local";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/var/log" = {
device = "rpool_/nixos/DATA/default/var/log";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/var/spool" = {
device = "rpool_/nixos/DATA/default/var/spool";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/nix" = {
device = "rpool_/nixos/DATA/local/nix";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/state" = {
device = "rpool_/nixos/DATA/default/state";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/etc/nixos" = {
device = "/state/etc/nixos";
fsType = "none";
options = ["bind"];
};
fileSystems."/etc/cryptkey.d" = {
device = "/state/etc/cryptkey.d";
fsType = "none";
options = ["bind"];
};
fileSystems."/boot/efis/nvme-SAMSUNG_MZVLW256HEHP-000L7_S35ENX1K539085-part1" = {
device = "/dev/disk/by-uuid/F429-235F";
fsType = "vfat";
options = ["x-systemd.idle-timeout=1min" "x-systemd.automount" "noauto"];
};
fileSystems."/boot/efis/nvme-WDC_PC_SN520_SDAPTUW-512G_182747800010-part1" = {
device = "/dev/disk/by-uuid/F429-AB41";
fsType = "vfat";
options = ["x-systemd.idle-timeout=1min" "x-systemd.automount" "noauto"];
};
fileSystems."/var/lib/docker" = {
device = "rpool_/nixos/DATA/default/var/lib/docker";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
# high-resolution display
hardware.video.hidpi.enable = lib.mkDefault true;
}

View file

@ -0,0 +1,28 @@
{
config,
pkgs,
...
}: {
# enable the tailscale daemon; this will do a
# variety of tasks:
# 1. create the TUN network device
# 2. setup some IP routes to route through the TUN
services.tailscale = {
enable = true;
useRoutingFeatures = "client"; # Make sure to pass `--accept-routes` to `tailscale up`
};
# Let's open the UDP port with which the network is tunneled through
networking.firewall.allowedUDPPorts = [41641];
# Disable SSH access through the firewall Only way into the machine will be
# through This may cause a chicken & egg problem since you need to register
# a machine first using `tailscale up`
# Better to rely on EC2 SecurityGroups
# services.openssh.openFirewall = false;
# Let's make the tailscale binary avilable to all users
environment.systemPackages = [pkgs.tailscale];
# TODO: Enable SSH via tailscale
}

View file

@ -0,0 +1,62 @@
{
config,
pkgs,
...
}: {
boot.supportedFilesystems = ["zfs"];
networking.hostId = "b2d25606";
boot.zfs.devNodes = "/dev/disk/by-id";
boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
swapDevices = [
{
device = "/dev/disk/by-id/nvme-SAMSUNG_MZVLW256HEHP-000L7_S35ENX1K539085-part4";
randomEncryption.enable = true;
}
{
device = "/dev/disk/by-id/nvme-WDC_PC_SN520_SDAPTUW-512G_182747800010-part4";
randomEncryption.enable = true;
}
];
systemd.services.zfs-mount.enable = false;
environment.etc."machine-id".source = "/state/etc/machine-id";
environment.etc."zfs/zpool.cache".source = "/state/etc/zfs/zpool.cache";
boot.loader.efi.efiSysMountPoint = "/boot/efis/nvme-SAMSUNG_MZVLW256HEHP-000L7_S35ENX1K539085-part1";
boot.loader.efi.canTouchEfiVariables = false;
##if UEFI firmware can detect entries
#boot.loader.efi.canTouchEfiVariables = true;
boot.loader = {
generationsDir.copyKernels = true;
##for problematic UEFI firmware
grub.efiInstallAsRemovable = true;
grub.enable = true;
grub.version = 2;
grub.copyKernels = true;
grub.efiSupport = true;
grub.zfsSupport = true;
# for systemd-autofs
grub.extraPrepareConfig = ''
mkdir -p /boot/efis /boot/efi
for i in /boot/efis/*; do mount $i ; done
mount /boot/efi
'';
grub.extraInstallCommands = ''
export ESP_MIRROR=$(mktemp -d -p /tmp)
cp -r /boot/efis/nvme-SAMSUNG_MZVLW256HEHP-000L7_S35ENX1K539085-part1/EFI $ESP_MIRROR
for i in /boot/efis/*; do
cp -r $ESP_MIRROR/EFI $i
done
rm -rf $ESP_MIRROR
'';
grub.devices = [
"/dev/disk/by-id/nvme-SAMSUNG_MZVLW256HEHP-000L7_S35ENX1K539085"
"/dev/disk/by-id/nvme-WDC_PC_SN520_SDAPTUW-512G_182747800010"
];
};
users.users.root.initialHashedPassword = "$6$VOzIHqv12iJGQIFl$NQf1GeiGhtdLfZFmtZl4vab.xvtVvI7.5ty9zbMFI2dpmHoFdc6XnGwTlClVe./CbcrsQjtPpt7NKf0dNttcw.";
services.zfs = {
autoScrub.enable = true;
autoSnapshot.enable = true;
};
}

View file

@ -0,0 +1,205 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{
config,
pkgs,
...
}: {
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
./zfs.nix
./vpn.nix
];
boot.binfmt.emulatedSystems = ["aarch64-linux" "armv6l-linux"];
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
};
nixpkgs.config.allowUnfree = true;
nix = {
# Make ready for nix flakes
package = pkgs.nixVersions.stable;
extraOptions = ''
experimental-features = nix-command flakes
'';
};
networking.hostName = "gospel"; # Define your hostname.
# Pick only one of the below networking options.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# networking.networkmanager.enable = true; # Easiest to use and most distros use this by default.
# Set your time zone.
time.timeZone = "America/Los_Angeles";
virtualisation.docker = {
# TODO: How to make sure docker systemd service is enabled for user?
enable = true;
rootless = {
enable = true;
setSocketVariable = true;
};
};
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Select internationalisation properties.
# i18n.defaultLocale = "en_US.UTF-8";
# console = {
# font = "Lat2-Terminus16";
# keyMap = "us";
# useXkbConfig = true; # use xkbOptions in tty.
# };
# Enable the X11 windowing system.
# Configure keymap in X11
# "eurosign:e";
# "caps:escape" # map caps to escape.
# };
# Enable CUPS to print documents.
# services.printing.enable = true;
# Enable sound.
# sound.enable = true;
# hardware.pulseaudio.enable = true;
# Enable touchpad support (enabled default in most desktopManager).
# Define a user account. Don't forget to set a password with passwd.
users.users.alejandro = {
isNormalUser = true;
extraGroups = ["wheel" "video" "networkmanager" "docker"];
shell = pkgs.zsh;
};
programs.sway = {
enable = true;
wrapperFeatures.gtk = true; # so that gtk works properly
extraPackages = with pkgs; [swaylock];
};
programs.steam = {
enable = true;
remotePlay.openFirewall = true;
dedicatedServer.openFirewall = true;
};
fonts.fonts = with pkgs; [
(nerdfonts.override {fonts = ["Hack"];})
];
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
wget
git
killall
usbutils
pavucontrol
cachix
nixos-generators
config.nur.repos.mic92.yubikey-touch-detector
cryptsetup
paperkey
unzip
p7zip
nix-index
vlc
xfce.thunar
prusa-slicer
esptool
minicom
file
];
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
# List services that you want to enable:
# Enable the OpenSSH daemon.
services.openssh = {
enable = true;
settings = {
PermitRootLogin = "no";
PasswordAuthentication = false;
};
};
services.geoclue2.enable = true;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
# Setup printing over the network
services.printing.enable = true;
services.avahi = {
enable = true;
nssmdns = true;
};
services.nix-serve = {
enable = true;
secretKeyFile = "/var/gospelCache";
};
services.nginx = {
enable = true;
virtualHosts = {
"gospel.kilonull.com" = {
serverAliases = ["gospel"];
locations."/".extraConfig = ''
proxy_pass http://localhost:${toString config.services.nix-serve.port};
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
'';
};
};
};
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
networking.firewall = {
allowedTCPPorts = [80];
};
# 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 value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.05"; # Did you read the comment?
}

View file

@ -0,0 +1,72 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod"];
boot.initrd.kernelModules = [];
boot.kernelModules = ["kvm-intel"];
boot.extraModulePackages = [];
fileSystems."/" = {
device = "rpool/nixos/root";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/home" = {
device = "rpool/nixos/home";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/var/lib" = {
device = "rpool/nixos/var/lib";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/var/log" = {
device = "rpool/nixos/var/log";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/boot" = {
device = "bpool/nixos/root";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/boot/efis/nvme-WDC_WDS100T2B0C-00PXH0_21111Y801086-part1" = {
device = "/dev/disk/by-uuid/1443-371C";
fsType = "vfat";
};
fileSystems."/boot/efi" = {
device = "/boot/efis/nvme-WDC_WDS100T2B0C-00PXH0_21111Y801086-part1";
fsType = "none";
options = ["bind"];
};
swapDevices = [];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.eno1.useDHCP = lib.mkDefault true;
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View file

@ -0,0 +1,23 @@
{
config,
pkgs,
...
}: {
# enable the tailscale daemon; this will do a
# variety of tasks:
# 1. create the TUN network device
# 2. setup some IP routes to route through the TUN
services.tailscale = {enable = true;};
# Let's open the UDP port with which the network is tunneled through
networking.firewall.allowedUDPPorts = [41641];
# Disable SSH access through the firewall Only way into the machine will be
# through This may cause a chicken & egg problem since you need to register
# a machine first using `tailscale up`
# Better to rely on EC2 SecurityGroups
# services.openssh.openFirewall = false;
# Let's make the tailscale binary avilable to all users
environment.systemPackages = [pkgs.tailscale];
}

View file

@ -0,0 +1,37 @@
{
config,
pkgs,
...
}: {
boot.supportedFilesystems = ["zfs"];
networking.hostId = "f8616592";
boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
boot.loader.efi.efiSysMountPoint = "/boot/efi";
boot.loader.efi.canTouchEfiVariables = false;
boot.loader.generationsDir.copyKernels = true;
boot.loader.grub.efiInstallAsRemovable = true;
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
boot.loader.grub.copyKernels = true;
boot.loader.grub.efiSupport = true;
boot.loader.grub.zfsSupport = true;
boot.loader.grub.extraPrepareConfig = ''
mkdir -p /boot/efis
for i in /boot/efis/*; do mount $i ; done
mkdir -p /boot/efi
mount /boot/efi
'';
boot.loader.grub.extraInstallCommands = ''
ESP_MIRROR=$(mktemp -d)
cp -r /boot/efi/EFI $ESP_MIRROR
for i in /boot/efis/*; do
cp -r $ESP_MIRROR/EFI $i
done
rm -rf $ESP_MIRROR
'';
boot.loader.grub.devices = [
"/dev/disk/by-id/nvme-WDC_WDS100T2B0C-00PXH0_21111Y801086"
];
users.users.root.initialHashedPassword = "$6$3Ps2Vmff.gUBkiCv$FCeCQjDvNTdWynQU81qtCXFHQht86w4unWNalUgkcyq7lkkI2klzRyTK3dZiQUjIrn8qPKtwJcY9SNdyE8v1L/";
}