Autogenderate XDG Dirs

This commit is contained in:
Jimbo 2024-11-24 09:55:02 -05:00
parent 28d611ae12
commit 87a53e364f
17 changed files with 126 additions and 258 deletions

View file

@ -201,22 +201,6 @@
"type": "github" "type": "github"
} }
}, },
"hardware": {
"locked": {
"lastModified": 1731797098,
"narHash": "sha256-UhWmEZhwJZmVZ1jfHZFzCg+ZLO9Tb/v3Y6LC0UNyeTo=",
"owner": "nixos",
"repo": "nixos-hardware",
"rev": "672ac2ac86f7dff2f6f3406405bddecf960e0db6",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "master",
"repo": "nixos-hardware",
"type": "github"
}
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -517,7 +501,6 @@
"inputs": { "inputs": {
"blender-bin": "blender-bin", "blender-bin": "blender-bin",
"disko": "disko", "disko": "disko",
"hardware": "hardware",
"home-manager": "home-manager", "home-manager": "home-manager",
"impermanence": "impermanence", "impermanence": "impermanence",
"jovian": "jovian", "jovian": "jovian",

View file

@ -3,7 +3,6 @@
# System inputs # System inputs
nixpkgs.url = "nixpkgs/nixos-24.11"; nixpkgs.url = "nixpkgs/nixos-24.11";
unstable.url = "nixpkgs/nixos-unstable"; unstable.url = "nixpkgs/nixos-unstable";
hardware.url = "github:nixos/nixos-hardware/master";
lanzaboote = { lanzaboote = {
url = "github:nix-community/lanzaboote/v0.4.1"; url = "github:nix-community/lanzaboote/v0.4.1";
@ -33,7 +32,6 @@
outputs = { outputs = {
nixpkgs, nixpkgs,
unstable, unstable,
hardware,
lanzaboote, lanzaboote,
disko, disko,
impermanence, impermanence,
@ -51,7 +49,6 @@
specialArgs = { specialArgs = {
inherit inherit
unstable unstable
hardware
lanzaboote lanzaboote
disko disko
impermanence impermanence

View file

@ -1,38 +1,7 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
boot = { boot = {
kernelPackages = pkgs.linuxPackages_5_10; kernelPackages = pkgs.linuxPackages_latest;
kernel.sysctl."vm.max_map_count" = 2147483642; kernel.sysctl."vm.max_map_count" = 2147483642;
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
'';
};
};
}; };
} }

View file

@ -1,14 +1,16 @@
{ ... }: { lib, ... }:
{ {
imports = [ imports = [
./boot ./boot
./disko
./hardware ./hardware
./nixmodules
./wireguard ./wireguard
../../modules/system ../../modules/system
]; ];
system.lanzaboote.enable = true; boot.loader.systemd-boot.enable = lib.mkForce false;
services.btrfs.autoScrub.enable = lib.mkForce false;
system.video.nvidia.enable = true; system.video.nvidia.enable = true;
networking.hostName = "extern"; networking.hostName = "extern";

View file

@ -1,97 +0,0 @@
{ disko, config, ... }:
{
imports = [ disko.nixosModules.disko ];
disko.devices = {
disk = {
"${config.networking.hostName}" = {
type = "disk";
device = "/dev/sdh";
content = {
type = "gpt";
partitions = {
ESP = {
priority = 1;
size = "2G";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
};
};
luks = {
size = "100%";
content = {
type = "luks";
name = "${config.networking.hostName}-disk";
settings.allowDiscards = true;
passwordFile = "/tmp/secret.key";
content = {
type = "lvm_pv";
vg = "${config.networking.hostName}";
};
};
};
};
};
};
};
lvm_vg = {
"${config.networking.hostName}" = {
type = "lvm_vg";
lvs = {
root = {
size = "100%";
content = {
type = "btrfs";
extraArgs = [ "-f" ];
subvolumes = {
"/root" = {
mountpoint = "/";
mountOptions = [ "compress=zstd" "noatime" ];
};
"/prev" = {
mountpoint = "/prev";
mountOptions = [ "compress=zstd" "noatime" ];
};
"/nix" = {
mountpoint = "/nix";
mountOptions = [ "compress=zstd" "noatime" ];
};
# Impermanence
"/persist" = {
mountpoint = "/persist";
mountOptions = [ "compress=zstd" "noatime" ];
};
"/persist/.snapshots" = { };
"/jimbo" = {
mountpoint = "/persist/home/jimbo";
mountOptions = [ "compress=zstd" "noatime" ];
};
"/jimbo/.snapshots" = { };
};
};
};
swap = {
size = "2G";
content = {
type = "swap";
discardPolicy = "both";
};
};
};
};
};
};
# Needed for impermanence
fileSystems = {
"/persist".neededForBoot = true;
"/persist/home/jimbo".neededForBoot = true;
};
}

7
hosts/extern/nixmodules/default.nix vendored Normal file
View file

@ -0,0 +1,7 @@
{ modulesPath, ... }:
{
imports = [
"${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix"
"${modulesPath}/installer/cd-dvd/channel.nix"
];
}

View file

@ -3,6 +3,7 @@
imports = [ imports = [
./boot ./boot
./disko ./disko
./filesystems
./hardware ./hardware
./wireguard ./wireguard
../../modules/system ../../modules/system

View file

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

View file

@ -1,33 +1,15 @@
{ config, lib, modulesPath, ... }: { config, lib, ... }:
{ {
boot = { boot.initrd.availableKernelModules = [
initrd = {
availableKernelModules = [
"nvme" "nvme"
"xhci_pci" "xhci_pci"
"ahci"
"usbhid"
"usb_storage" "usb_storage"
"usbhid"
"sd_mod" "sd_mod"
"sdhci_pci"
]; ];
kernelModules = [ boot.kernelModules = [ "kvm-amd" ];
"dm-snapshot"
"vfio"
"vfio_pci"
"vfio_iommu_type1"
"kvm-amd"
];
};
};
fileSystems = {
# Remote
"/home/jimbo/JimboNFS" = {
device = "10.100.0.1:/export/JimboNFS";
fsType = "nfs4";
options = [ "x-systemd.automount" "_netdev" "nofail" "noauto" ];
};
};
networking.useDHCP = lib.mkDefault true; networking.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";

View file

@ -21,6 +21,13 @@ in {
kernelParams = commonKernelParams ++ [ "vfio-pci.ids=10de:1f82,10de:10fa" ]; kernelParams = commonKernelParams ++ [ "vfio-pci.ids=10de:1f82,10de:10fa" ];
blacklistedKernelModules = [ "pcspkr" ]; blacklistedKernelModules = [ "pcspkr" ];
# Needed for GPU passthrough
initrd.kernelModules = [
"vfio"
"vfio_pci"
"vfio_iommu_type1"
];
initrd.systemd = { initrd.systemd = {
enable = true; enable = true;
services.root-reset = { services.root-reset = {

View file

@ -3,6 +3,7 @@
imports = [ imports = [
./boot ./boot
./disko ./disko
./filesystems
./firewall ./firewall
./hardware ./hardware
../../modules/system ../../modules/system

View file

@ -0,0 +1,43 @@
{ config, ... }:
{
fileSystems = {
# Games and such
"/mnt/Linux1" = {
device = "/dev/disk/by-uuid/b2901f8c-ffda-4b88-bb63-a9ea0c96ccb4";
options = [ "nosuid" "nodev" "nofail" "x-gvfs-show" ];
};
"/mnt/Linux2" = {
device = "/dev/disk/by-uuid/f08e4f38-162c-402f-ba2a-5925151b78bf";
options = [ "nosuid" "nodev" "nofail" "x-gvfs-show" ];
};
"/mnt/Linux3" = {
device = "/dev/disk/by-uuid/e7bc75bd-c371-4b28-b212-7be9b1fad339";
options = [ "nosuid" "nodev" "nofail" "x-gvfs-show" ];
};
"/mnt/Windows1" = {
device = "/dev/disk/by-uuid/48F5C6E06416229C";
options = [ "nosuid" "nodev" "noauto" ];
};
"/mnt/Windows2" = {
device = "/dev/disk/by-uuid/0A5A3420237C863A";
options = [ "nosuid" "nodev" "noauto" ];
};
# Bulk storage mounts
"/persist/var/lib/libvirt" = {
device = "/dev/disk/by-uuid/abf78669-de2a-4afa-8e62-604f4e4cb355";
options = [ "subvol=libvirt" "nosuid" "nodev" "nofail" ];
};
"/persist/home/jimbo/VMs" = {
device = "/dev/disk/by-uuid/abf78669-de2a-4afa-8e62-604f4e4cb355";
options = [ "subvol=images" "nosuid" "nodev" "nofail" ];
};
# Network mounts
"/home/jimbo/JimboNFS" = {
device = "${config.ips.server}:/export/JimboNFS";
fsType = "nfs4";
options = [ "x-systemd.automount" "_netdev" "nofail" "noauto" ];
};
};
}

View file

@ -1,65 +1,9 @@
{ config, lib, modulesPath, ... }: # nixos-generate-config --root ./ --no-filesystems
{ config, lib, ... }:
{ {
boot = { boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "sd_mod" ];
initrd = { boot.initrd.kernelModules = [ "dm-snapshot" ];
availableKernelModules = [ boot.kernelModules = [ "kvm-amd" ];
"nvme"
"xhci_pci"
"ahci"
"usbhid"
"usb_storage"
"sd_mod"
];
kernelModules = [
"dm-snapshot"
"vfio"
"vfio_pci"
"vfio_iommu_type1"
"kvm-amd"
];
};
};
fileSystems = {
# Games and such
"/mnt/Linux1" = {
device = "/dev/disk/by-uuid/b2901f8c-ffda-4b88-bb63-a9ea0c96ccb4";
options = [ "nosuid" "nodev" "nofail" "x-gvfs-show" ];
};
"/mnt/Linux2" = {
device = "/dev/disk/by-uuid/f08e4f38-162c-402f-ba2a-5925151b78bf";
options = [ "nosuid" "nodev" "nofail" "x-gvfs-show" ];
};
"/mnt/Linux3" = {
device = "/dev/disk/by-uuid/e7bc75bd-c371-4b28-b212-7be9b1fad339";
options = [ "nosuid" "nodev" "nofail" "x-gvfs-show" ];
};
"/mnt/Windows1" = {
device = "/dev/disk/by-uuid/48F5C6E06416229C";
options = [ "nosuid" "nodev" "noauto" ];
};
"/mnt/Windows2" = {
device = "/dev/disk/by-uuid/0A5A3420237C863A";
options = [ "nosuid" "nodev" "noauto" ];
};
# Bulk storage mounts
"/persist/var/lib/libvirt" = {
device = "/dev/disk/by-uuid/abf78669-de2a-4afa-8e62-604f4e4cb355";
options = [ "subvol=libvirt" "nosuid" "nodev" "nofail" ];
};
"/persist/home/jimbo/VMs" = {
device = "/dev/disk/by-uuid/abf78669-de2a-4afa-8e62-604f4e4cb355";
options = [ "subvol=images" "nosuid" "nodev" "nofail" ];
};
# Network mounts
"/home/jimbo/JimboNFS" = {
device = "${config.ips.server}:/export/JimboNFS";
fsType = "nfs4";
options = [ "x-systemd.automount" "_netdev" "nofail" "noauto" ];
};
};
networking.useDHCP = lib.mkDefault true; networking.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";

View file

@ -1,11 +1,7 @@
{ ... }: { ... }:
{ {
xdg.mimeApps.defaultApplications = { imports = [
"inode/directory" = [ "pcmanfm-qt.desktop" ]; ./defaults
"text/plain" = [ "nvim.desktop" ]; ./folders
"image/png" = [ "imv.desktop" ]; ];
"image/jpeg" = [ "imv.desktop" ];
"image/jp2" = [ "imv.desktop" ];
"video/*" = [ "mpv.desktop" ];
};
} }

View file

@ -0,0 +1,11 @@
{ ... }:
{
xdg.mimeApps.defaultApplications = {
"inode/directory" = [ "pcmanfm-qt.desktop" ];
"text/plain" = [ "nvim.desktop" ];
"image/png" = [ "imv.desktop" ];
"image/jpeg" = [ "imv.desktop" ];
"image/jp2" = [ "imv.desktop" ];
"video/*" = [ "mpv.desktop" ];
};
}

View file

@ -0,0 +1,11 @@
{ ... }:
{
xdg.userDirs = {
enable = true;
createDirectories = true;
desktop = null;
music = null;
publicShare = null;
templates = null;
};
}

View file

@ -1,11 +1,11 @@
{ ... }: { lib, ... }:
{ {
imports = [ ./fail2ban ]; imports = [ ./fail2ban ];
services.openssh = { services.openssh = {
enable = true; enable = true;
settings = { settings = {
PermitRootLogin = "no"; PermitRootLogin = lib.mkForce "no";
PrintLastLog = "no"; PrintLastLog = "no";
PasswordAuthentication = false; PasswordAuthentication = false;
UsePAM = false; UsePAM = false;