pre-format

This commit is contained in:
Gerg-L 2023-09-23 17:35:09 -04:00
parent 3ad599c6aa
commit de7683556e
Signed by: gerg-l
SSH key fingerprint: SHA256:FPYDHIkvMocr4wdmZXpgpJjsb2Tw6rASs2ISPbOb0KI
21 changed files with 462 additions and 403 deletions

View file

@ -1,139 +1,97 @@
{disko, ...}: _: {
{disko, ...}: {lib, ...}: {
imports = [disko.nixosModules.disko];
disko.devices = {
disk = {
"0E" = let
baseDevice = "/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N0E";
in {
type = "disk";
device = baseDevice;
content = {
type = "gpt";
partitions = {
BOOT = {
device = "${baseDevice}-part1";
type = "EF00";
start = "0";
end = "4G";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/efi0E";
};
};
swap = {
device = "${baseDevice}-part2";
start = "5G";
end = "21G";
content = {
type = "swap";
randomEncryption = true;
};
};
zfsroot = {
device = "${baseDevice}-part3";
start = "21G";
end = "100%";
content = {
type = "zfs";
pool = "rpool";
};
};
disko.devices.disk = lib.genAttrs ["0E" "22"] (name: let
fullName = "/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N${name}";
in {
type = "disk";
device = fullName;
content = {
type = "gpt";
partitions = {
BOOT = {
device = "${fullName}-part1";
type = "EF00";
start = "0";
end = "4G";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/efi${name}";
};
};
};
"22" = let
baseDevice = "/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N22";
in {
type = "disk";
device = baseDevice;
content = {
type = "gpt";
partitions = {
BOOT = {
device = "${baseDevice}-part1";
type = "EF00";
start = "0";
end = "4G";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/efi22";
};
};
swap = {
device = "${baseDevice}-part2";
start = "5G";
end = "21G";
content = {
type = "swap";
randomEncryption = true;
};
};
zfsroot = {
device = "${baseDevice}-part3";
start = "21G";
end = "100%";
content = {
type = "zfs";
pool = "rpool";
};
};
swap = {
device = "${fullName}-part2";
start = "5G";
end = "21G";
content = {
type = "swap";
randomEncryption = true;
};
};
zfsroot = {
device = "${fullName}-part3";
start = "21G";
end = "100%";
content = {
type = "zfs";
pool = "rpool";
};
};
};
};
zpool = {
rpool = {
type = "zpool";
mode = "mirror";
rootFsOptions = {
acltype = "posixacl";
compression = "zstd";
dnodesize = "auto";
normalization = "formD";
relatime = "on";
xattr = "sa";
encryption = "on";
keyformat = "passphrase";
keylocation = "prompt";
};
options = {
ashift = "12";
autotrim = "on";
};
});
datasets = {
"root" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/";
postCreateHook = "zfs snapshot rpool/root@empty";
};
"nix" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/nix";
postCreateHook = "zfs snapshot rpool/nix@empty";
};
"var" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/var";
postCreateHook = "zfs snapshot rpool/var@empty";
};
"persist" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/persist";
postCreateHook = "zfs snapshot rpool/persist@empty";
};
"home" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/home";
postCreateHook = "zfs snapshot rpool/home@empty";
};
disko.devices.zpool = {
rpool = {
type = "zpool";
mode = "mirror";
rootFsOptions = {
acltype = "posixacl";
compression = "zstd";
dnodesize = "auto";
normalization = "formD";
relatime = "on";
xattr = "sa";
encryption = "on";
keyformat = "passphrase";
keylocation = "prompt";
};
options = {
ashift = "12";
autotrim = "on";
};
datasets = {
"root" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/";
postCreateHook = "zfs snapshot rpool/root@empty";
};
"nix" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/nix";
postCreateHook = "zfs snapshot rpool/nix@empty";
};
"var" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/var";
postCreateHook = "zfs snapshot rpool/var@empty";
};
"persist" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/persist";
postCreateHook = "zfs snapshot rpool/persist@empty";
};
"home" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/home";
postCreateHook = "zfs snapshot rpool/home@empty";
};
};
};

View file

@ -1,4 +1,4 @@
{nvim-flake, ...}: {
{nvim-flake, nixfmt, ...}: {
pkgs,
config,
...
@ -43,32 +43,56 @@
nix.settings.system-features = ["kvm" "big-parallel" "nixos-test" "benchmark"];
environment = {
systemPackages = builtins.attrValues {
inherit
(pkgs)
bitwarden #store stuff
qbittorrent #steal stuff
pavucontrol #gui volume control
pcmanfm #file manager
librewolf #best browser
vlc #play stuff
ripgrep
xautoclick
prismlauncher
deadnix
statix
alejandra
nix-index
element-desktop
webcord
;
inherit (nvim-flake.packages.${pkgs.system}) neovim;
lint = pkgs.writeShellScriptBin "lint" ''
deadnix -e "''${1:-.}"
statix fix -- "''${1:-.}"
alejandra "''${1:-.}"
'';
};
systemPackages = let
fmt = pkgs.nixfmt.overrideAttrs {
version = "0.6.0-${nixfmt.shortRev}";
src = nixfmt;
};
in
builtins.attrValues {
inherit
(pkgs)
bitwarden # store stuff
qbittorrent # steal stuff
pavucontrol # gui volume control
pcmanfm # file manager
librewolf # best browser
vlc # play stuff
ripgrep
fd
jq
xautoclick
prismlauncher
deadnix
statix
nix-index
element-desktop
webcord
;
inherit (nvim-flake.packages.${pkgs.system}) neovim;
inherit fmt;
lint = pkgs.writeShellApplication {
name = "lint";
runtimeInputs = [
fmt
pkgs.deadnix
pkgs.statix
pkgs.fd
];
text = ''
if [ -z "''${1:-""}" ]; then
fd '.*\.nix' . -x statix fix -- {} \;
fd '.*\.nix' . -X deadnix -e -- {} \; -X nixfmt {} \;
else
statix fix -- "$1"
deadnix -e "$1"
nixfmt "$1"
fi
'';
};
};
etc = {
"jdks/17".source = "${pkgs.openjdk17}/bin";
"jdks/8".source = "${pkgs.openjdk8}/bin";

View file

@ -7,7 +7,6 @@
config = lib.mkIf false {
networking.firewall.allowedTCPPorts = [25565];
system.stateVersion = "unstable";
users.users.minecraft = {
description = "Minecraft server service user";
home = "/persist/minecraft";
@ -64,7 +63,7 @@
serviceConfig = {
Restart = "always";
User = "minecraft";
WorkingDirectory = "/minecraft";
WorkingDirectory = "/persist/minecraft";
StandardInput = "socket";
StandardOutput = "journal";

View file

@ -16,6 +16,7 @@ _: {
enableBrokenCiphersForSSE = false;
database.createLocally = true;
config = {
overwriteProtocol = "https";
dbtype = "pgsql";
adminpassFile = config.sops.secrets.nextcloud.path;
adminuser = "admin-root";

View file

@ -1,16 +1,18 @@
{spicetify-nix, ...}: {pkgs, ...}: let
spicePkgs = spicetify-nix.legacyPackages.${pkgs.system};
ex = spicePkgs.extensions;
in {
imports = [spicetify-nix.nixosModules.default];
local.allowedUnfree = ["spotify"];
programs.spicetify = {
enable = true;
enabledExtensions = [
ex.adblock
ex.hidePodcasts
ex.shuffle
];
enabledExtensions = builtins.attrValues {
inherit
(spicePkgs.extensions)
adblock
hidePodcasts
shuffle
;
};
theme = spicePkgs.themes.Comfy;
colorScheme = "custom";
customColorScheme = {

View file

@ -37,6 +37,16 @@ let
echo >> $out
'';
###END OF TAKEN PART
cfg_monitors = pkgs.writeShellApplication {
name = "cfg_monitors";
runtimeInputs = [pkgs.xorg.xrandr pkgs.xorg.xset pkgs.gawk pkgs.gnugrep];
text = ''
xrandr --output DP-0 --auto --mode 3440x1440 --rate 120 --primary --pos 0x0
xrandr --output "$(xrandr | grep -e 'HDMI.* connected.*'| awk '{ print$1 }')" --auto --mode 1920x1080 --rate 144 --set TearFree on --pos 3440x360
xset -dpms
'';
};
in {
environment.etc = {
"Xorg/1_mon.conf".source = pkgs.runCommand "1_mon.conf" {} (
@ -103,6 +113,7 @@ in {
systemPackages = [
pkgs.virt-manager
pkgs.dmidecode
cfg_monitors
];
shellAliases = {
vm-start = "virsh start Windows";
@ -110,53 +121,58 @@ in {
};
};
programs.dconf.enable = true;
users.users.gerg.extraGroups = ["kvm" "libvirtd"];
services.xserver.displayManager.xserverArgs = lib.mkAfter ["-config /etc/Xorg/active.conf"];
services.xserver.displayManager.sessionCommands = lib.mkBefore ''
if ! [ -e "/etc/Xorg/ONE_MONITOR" ] ; then
xrandr --output DP-0 --auto --mode 3440x1440 --rate 120 --primary --pos 0x0
xrandr --output "$(xrandr | grep -e 'HDMI.* connected.*'| awk '{ print$1 }')" --auto --mode 1920x1080 --rate 144 --set TearFree on --pos 3440x360
xset -dpms
${lib.getExe cfg_monitors}
fi
'';
systemd.tmpfiles.rules = let
qemuHook = pkgs.writeShellScript "qemu-hook" ''
GUEST_NAME="$1"
OPERATION="$2"
SUB_OPERATION="$3"
qemuHook = pkgs.writeShellApplication {
name = "qemu-hook";
if [ "$GUEST_NAME" == "Windows" ]; then
if [ "$OPERATION" == "prepare" ]; then
runtimeInputs = [pkgs.libvirt pkgs.systemd pkgs.kmod];
text = ''
GUEST_NAME="$1"
OPERATION="$2"
if [ "$GUEST_NAME" == "Windows" ]; then
if [ "$OPERATION" == "prepare" ]; then
systemctl stop display-manager.service
modprobe -r -a nvidia_uvm nvidia_drm nvidia nvidia_modeset
virsh nodedev-detach pci_0000_01_00_0
virsh nodedev-detach pci_0000_01_00_1
systemctl set-property --runtime -- user.slice AllowedCPUs=8-15,24-31
systemctl set-property --runtime -- system.slice AllowedCPUs=8-15,24-31
systemctl set-property --runtime -- init.scope AllowedCPUs=8-15,24-31
ln -fs /etc/Xorg/1_mon.conf /etc/Xorg/active.conf
touch /etc/Xorg/ONE_MONITOR
systemctl start display-manager.service
fi
if [ "$OPERATION" == "release" ]; then
systemctl stop display-manager.service
modprobe -r -a nvidia_uvm nvidia_drm nvidia nvidia_modeset
${pkgs.libvirt}/bin/virsh nodedev-detach pci_0000_01_00_0
${pkgs.libvirt}/bin/virsh nodedev-detach pci_0000_01_00_1
systemctl set-property --runtime -- user.slice AllowedCPUs=8-15,24-31
systemctl set-property --runtime -- system.slice AllowedCPUs=8-15,24-31
systemctl set-property --runtime -- init.scope AllowedCPUs=8-15,24-31
ln -fs /etc/Xorg/1_mon.conf /etc/Xorg/active.conf
touch /etc/Xorg/ONE_MONITOR
systemctl set-property --runtime -- user.slice AllowedCPUs=0-31
systemctl set-property --runtime -- system.slice AllowedCPUs=0-31
systemctl set-property --runtime -- init.scope AllowedCPUs=0-31
virsh nodedev-reattach pci_0000_01_00_0
virsh nodedev-reattach pci_0000_01_00_1
modprobe -a nvidia_uvm nvidia_drm nvidia nvidia_modeset
ln -fs /etc/Xorg/2_mon.conf /etc/Xorg/active.conf
rm /etc/Xorg/ONE_MONITOR
systemctl start display-manager.service
fi
fi
if [ "$OPERATION" == "release" ]; then
systemctl stop display-manager.service
systemctl set-property --runtime -- user.slice AllowedCPUs=0-31
systemctl set-property --runtime -- system.slice AllowedCPUs=0-31
systemctl set-property --runtime -- init.scope AllowedCPUs=0-31
${pkgs.libvirt}/bin/virsh nodedev-reattach pci_0000_01_00_0
${pkgs.libvirt}/bin/virsh nodedev-reattach pci_0000_01_00_1
modprobe -a nvidia_uvm nvidia_drm nvidia nvidia_modeset
ln -fs /etc/Xorg/2_mon.conf /etc/Xorg/active.conf
rm /etc/Xorg/ONE_MONITOR
systemctl start display-manager.service
fi
fi
'';
'';
};
in [
"L /etc/Xorg/active.conf - - - - /etc/Xorg/2_mon.conf"
"C /var/lib/libvirt/hooks/qemu - - - - ${qemuHook}"
"C /var/lib/libvirt/hooks/qemu - - - - ${lib.getExe qemuHook}"
"C /var/lib/libvirt/qemu/Windows.xml - - - - ${./Windows.xml}"
];
_file = ./vfio.nix;