ark/hosts/lungmen/default.nix

212 lines
5.0 KiB
Nix
Raw Normal View History

2022-02-18 20:31:01 +03:00
{
config,
lib,
pkgs,
2022-04-09 21:33:13 +03:00
inputs,
2022-02-18 20:31:01 +03:00
...
2022-03-09 23:55:02 +03:00
}: let
2020-11-22 18:34:10 +03:00
btrfsPartPath = "/dev/disk/by-label/NIXOS";
2022-02-18 20:31:01 +03:00
btrfsOptions = ["compress-force=zstd" "noatime"];
btrfsDiff =
pkgs.writeScriptBin
"btrfs-diff"
''
#!${pkgs.bash}/bin/bash
set -euo pipefail
sudo mkdir -p /mnt
sudo mount -o subvol=/ ${btrfsPartPath} /mnt
OLD_TRANSID=$(sudo btrfs subvolume find-new /mnt/root-blank 9999999)
sudo btrfs subvolume find-new "/mnt/root" "$OLD_TRANSID" |
sed '$d' |
cut -f17- -d' ' |
sort |
uniq |
while read path; do
path="/$path"
if [ -L "$path" ]; then
: # The path is a symbolic link, so is probably handled by NixOS already
elif [ -d "$path" ]; then
: # The path is a directory, ignore
else
echo "$path"
fi
done
sudo umount /mnt
'';
in {
2022-04-09 21:33:13 +03:00
imports = with inputs;
with nixos-hardware.nixosModules; [
2022-04-17 19:20:06 +03:00
nixpkgs.nixosModules.notDetected
2022-04-09 21:33:13 +03:00
nixos-persistence.nixosModule
common-pc-ssd
common-pc
common-gpu-amd
common-cpu-amd
../../modules/network/dns
2022-05-03 21:12:47 +03:00
../../modules/develop/nixbuild
2022-04-09 21:33:13 +03:00
../../users/root
../../users/patriot
];
2020-11-21 23:54:07 +03:00
boot = {
2022-04-09 21:33:13 +03:00
tmpOnTmpfs = true;
2020-11-21 23:54:07 +03:00
loader = {
efi.canTouchEfiVariables = true;
systemd-boot.enable = true;
2022-04-09 21:33:13 +03:00
systemd-boot.configurationLimit = 10;
2020-11-21 23:54:07 +03:00
};
kernelPackages = pkgs.linuxPackages_latest;
2022-02-18 20:31:01 +03:00
supportedFilesystems = ["btrfs"];
2020-11-21 23:54:07 +03:00
initrd = {
2022-02-18 20:31:01 +03:00
availableKernelModules = ["xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod"];
kernelModules = ["amdgpu"];
2021-01-02 16:21:55 +03:00
};
2022-02-18 20:31:01 +03:00
kernelModules = ["kvm-amd"];
extraModulePackages = [];
initrd.postDeviceCommands =
pkgs.lib.mkBefore
''
mkdir -p /mnt
mount -o subvol=/ ${btrfsPartPath} /mnt
btrfs subvolume list -o /mnt/root |
cut -f9 -d' ' |
while read subvolume; do
echo "deleting /$subvolume subvolume..."
btrfs subvolume delete "/mnt/$subvolume"
done &&
echo "deleting /root subvolume..." &&
btrfs subvolume delete /mnt/root
echo "restoring blank /root subvolume"
btrfs subvolume snapshot /mnt/root-blank /mnt/root
umount /mnt
'';
2022-03-09 23:55:02 +03:00
kernel.sysctl = {"fs.inotify.max_user_watches" = 524288;};
2020-11-21 23:54:07 +03:00
};
2022-04-09 21:33:13 +03:00
2020-11-21 23:54:07 +03:00
fileSystems."/" = {
device = btrfsPartPath;
fsType = "btrfs";
2022-02-18 20:31:01 +03:00
options = ["subvol=root"] ++ btrfsOptions;
2020-11-21 23:54:07 +03:00
};
fileSystems."/home" = {
device = btrfsPartPath;
fsType = "btrfs";
2022-02-18 20:31:01 +03:00
options = ["subvol=home"] ++ btrfsOptions;
2020-11-22 18:34:10 +03:00
};
2022-05-21 14:17:48 +03:00
/*
fileSystems."/media/archive" = {
device = "/dev/disk/by-uuid/f9b5f7f3-51e8-4357-8518-986b16311c71";
fsType = "btrfs";
options = btrfsOptions;
};
*/
2020-11-21 23:54:07 +03:00
fileSystems."/nix" = {
device = btrfsPartPath;
fsType = "btrfs";
2022-02-18 20:31:01 +03:00
options = ["subvol=nix"] ++ btrfsOptions;
2020-11-21 23:54:07 +03:00
};
fileSystems."/persist" = {
device = btrfsPartPath;
fsType = "btrfs";
2022-02-18 20:31:01 +03:00
options = ["subvol=persist"] ++ btrfsOptions;
2020-11-21 23:54:07 +03:00
neededForBoot = true;
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/5784-BBB1";
fsType = "vfat";
};
2022-04-09 21:33:13 +03:00
2022-02-18 20:31:01 +03:00
swapDevices = [];
2020-11-21 23:54:07 +03:00
zramSwap = {
enable = true;
algorithm = "zstd";
};
2022-04-09 21:33:13 +03:00
nix.maxJobs = lib.mkDefault 4;
2020-11-21 23:54:07 +03:00
security = {
2022-04-09 21:33:13 +03:00
pam.loginLimits = [
{
domain = "*";
type = "soft";
item = "nofile";
value = "524288";
}
{
domain = "*";
type = "hard";
item = "nofile";
value = "524288";
}
];
2020-11-21 23:54:07 +03:00
allowSimultaneousMultithreading = false;
# Deleting root subvolume makes sudo show lecture every boot
2022-03-09 23:55:02 +03:00
sudo.extraConfig = ''
Defaults lecture = never
'';
2021-05-14 22:10:53 +03:00
rtkit.enable = true;
2020-11-21 23:54:07 +03:00
};
2022-04-09 21:33:13 +03:00
2021-05-14 22:10:53 +03:00
sound.enable = false;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
2020-11-21 23:54:07 +03:00
hardware = {
opengl = {
driSupport = true;
driSupport32Bit = true;
enable = true;
2022-02-18 20:31:01 +03:00
extraPackages = with pkgs; [amdvlk libvdpau-va-gl vaapiVdpau libva vulkan-loader pipewire];
2022-03-09 23:55:02 +03:00
extraPackages32 = with pkgs.pkgsi686Linux;
2022-02-18 20:31:01 +03:00
[libvdpau-va-gl vaapiVdpau libva vulkan-loader pipewire] ++ [pkgs.driversi686Linux.amdvlk];
2020-11-21 23:54:07 +03:00
};
pulseaudio = {
2021-05-14 22:10:53 +03:00
enable = false;
2020-11-21 23:54:07 +03:00
support32Bit = true;
};
};
2022-04-09 21:33:13 +03:00
2021-07-24 16:37:53 +03:00
fonts = {
enableDefaultFonts = true;
2021-07-24 16:51:53 +03:00
fontconfig.enable = true;
2022-02-18 20:31:01 +03:00
fonts = [pkgs.dejavu_fonts];
2021-07-24 16:37:53 +03:00
};
2022-04-09 21:33:13 +03:00
2020-11-21 23:54:07 +03:00
environment = {
2022-04-10 05:48:34 +03:00
systemPackages = [btrfsDiff pkgs.ntfs3g];
2022-02-18 20:31:01 +03:00
pathsToLink = ["/share/zsh"];
2020-11-21 23:54:07 +03:00
persistence."/persist" = {
2022-02-18 20:31:01 +03:00
directories = ["/etc/nixos"];
files = ["/etc/machine-id"];
2020-11-21 23:54:07 +03:00
};
};
2022-04-09 21:33:13 +03:00
2022-05-21 14:17:48 +03:00
networking.firewall.checkReversePath = "loose";
2020-11-21 23:54:07 +03:00
networking.interfaces.enp6s0.useDHCP = true;
2021-02-13 20:30:31 +03:00
services = {
2022-05-21 14:17:48 +03:00
haveged.enable = true;
tailscale.enable = true;
2022-04-09 21:33:13 +03:00
earlyoom.enable = true;
2021-04-03 11:25:07 +03:00
ipfs = {
2021-04-15 16:54:00 +03:00
enable = false;
2021-04-03 11:25:07 +03:00
enableGC = true;
autoMount = true;
};
2022-05-21 14:17:48 +03:00
flatpak.enable = false;
2022-04-09 21:33:13 +03:00
xserver.videoDrivers = ["amdgpu"];
2020-12-23 19:54:51 +03:00
};
2022-04-09 21:33:13 +03:00
2021-03-26 21:03:40 +03:00
virtualisation = {
2022-03-09 23:55:02 +03:00
podman.enable = true;
2021-05-25 03:24:39 +03:00
libvirtd.enable = false;
2021-03-26 21:03:40 +03:00
};
2022-04-09 21:33:13 +03:00
2020-11-21 23:54:07 +03:00
system.stateVersion = "20.09";
}