Compare commits

..

No commits in common. "70a1ab7e680c29fa1c5a04562625d72ed5b067c7" and "8d5d853492742ac32b4b968b1abe017fcb448696" have entirely different histories.

8 changed files with 142 additions and 62 deletions

View File

@ -116,7 +116,7 @@ in
let let
build_definition_lines = mapAttrsToList (name: value: "set \$${name} ${value}"); build_definition_lines = mapAttrsToList (name: value: "set \$${name} ${value}");
build_keybind_lines = mapAttrsToList (key: value: "bindsym ${key} ${value}"); build_keybind_lines = mapAttrsToList (key: value: "bindsym ${key} ${value}");
build_exec_lines = e: map (item: "${e} " + (if isDerivation item then (getExe item) else item)); build_exec_lines = e: map (item: "${e} " + (if isString item then item else (getExe item)));
build_mode_lines = mapAttrsToList ( build_mode_lines = mapAttrsToList (
name: value: '' name: value: ''
mode "${name}" { mode "${name}" {

View File

@ -18,12 +18,12 @@ in
lshw lshw
pciutils pciutils
usbutils usbutils
opentabletdriver
ddcutil ddcutil
python312Packages.py-cpuinfo python312Packages.py-cpuinfo
(writeShellScriptBin "lsiommu" ./lsiommu) (writeShellScriptBin "lsiommu" ./lsiommu)
] ]
++ lib.optionals graphical [ ++ lib.optionals graphical [
opentabletdriver
ddcui ddcui
wootility wootility
]; ];
@ -57,8 +57,14 @@ in
boot = { boot = {
kernelParams = [ kernelParams = [
# "splash"
"quiet" "quiet"
]; # "intel_iommu=on"
# "iommu=force"
# "pcie_acs_override=downstream"
# "mmio_stale_data=full,nosmt"
# "pcie_aspm=off"
]; # "vfio-pci.ids=10de:1aeb,10de:2191,10de:1aed,10de:1aec" ];
loader.efi.canTouchEfiVariables = true; loader.efi.canTouchEfiVariables = true;
initrd.availableKernelModules = [ initrd.availableKernelModules = [
"xhci_pci" "xhci_pci"
@ -80,10 +86,15 @@ in
})) }))
]; ];
kernelModules = [ kernelModules = [
# "kvm-intel"
# "vfio_pci"
# "vfio_iommu_type1"
# "vfio"
"ddcci_backlight" "ddcci_backlight"
"i2c-dev" "i2c-dev"
"ec_sys" "ec_sys"
]; ];
# blacklistedKernelModules = [ "i2c_nvidia_gpu" ];
}; };
}; };

View File

@ -61,8 +61,6 @@ in
qdirstat qdirstat
libva-utils libva-utils
gparted gparted
jetbrains.clion
jetbrains.idea-community
]; ];
programs.git = { programs.git = {

View File

@ -4,7 +4,10 @@
./overlays ./overlays
./common ./common
./fake_flake.nix ./fake_flake.nix
./users.nix ./specific/grimm-nixos-laptop/configuration.nix
./modules/users.nix
# ./modules/kvm.nix
./sway
]; ];
# Bootloader. # Bootloader.
@ -13,12 +16,49 @@
kernelPackages = pkgs.linuxPackages_zen; kernelPackages = pkgs.linuxPackages_zen;
}; };
# Enable flatpaks
# services.flatpak.enable = true;
grimmShared = { grimmShared = {
enable = true; enable = true;
locale = true; locale = true;
printing = true;
portals = true;
network = true; network = true;
tooling = { tooling = {
enable = true; enable = true;
pass = true;
lilypond = true;
}; };
sound = {
enable = true;
midi = true;
};
graphical = true;
firefox = {
enable = true;
plugins = {
"uBlock0@raymondhill.net" = "ublock-origin";
"gdpr@cavi.au.dk" = "consent-o-matic";
"{41f9e51d-35e4-4b29-af66-422ff81c8b41}" = "disable-javascript";
"{7a7a4a92-a2a0-41d1-9fd7-1e92480d612d}" = "styl-us";
"wappalyzer@crunchlabz.com" = "wappalyzer";
"{b9db16a4-6edc-47ec-a1f4-b86292ed211d}" = "video-downloadhelper";
"{1526fba1-ac33-4dfc-99d8-163e6129f7b9}" = "reveye-ris";
};
};
cloudSync = {
enable = true;
username = "Grimmauld";
server = "cloud.grimmauld.de";
passwordFile = config.age.secrets.nextcloud_pass.path;
};
spotify.enable = true;
};
age.secrets.nextcloud_pass = {
file = ./secrets/nextcloud_pass.age;
mode = "777";
}; };
} }

View File

@ -9,14 +9,6 @@ let
nivSources = import ./nix/sources.nix; nivSources = import ./nix/sources.nix;
asGithubRef = src: "github:${src.owner}/${src.repo}/${src.rev}"; asGithubRef = src: "github:${src.owner}/${src.repo}/${src.rev}";
build_target = let env_host = builtins.getEnv "NIXOS_TARGET_HOST"; in if env_host != "" then env_host else builtins.replaceStrings ["\n"] [""] (lib.toLower (builtins.readFile /proc/sys/kernel/hostname));
host_modules = {
grimmauld-nixos = [
./specific/grimm-nixos-laptop/configuration.nix
];
};
nixpkgs_patches = [ nixpkgs_patches = [
{ {
# tlpui # tlpui
@ -30,7 +22,7 @@ in
"${nivSources.agenix}/modules/age.nix" "${nivSources.agenix}/modules/age.nix"
(import "${nivSources.lix-module}/module.nix" { lix = nivSources.lix-pkg; }) (import "${nivSources.lix-module}/module.nix" { lix = nivSources.lix-pkg; })
(builtins.getFlake (asGithubRef nivSources.chaotic)).nixosModules.default # fixme: ideally we'd not rely on the flake syntax to load the module (builtins.getFlake (asGithubRef nivSources.chaotic)).nixosModules.default # fixme: ideally we'd not rely on the flake syntax to load the module
] ++ lib.optionals (builtins.hasAttr build_target host_modules) host_modules.${build_target}; ];
nixpkgs.hostPlatform = system; nixpkgs.hostPlatform = system;

76
modules/kvm.nix Normal file
View File

@ -0,0 +1,76 @@
{ pkgs, ... }:
let
loadvfio = pkgs.writeShellScriptBin "loadvfio" ''
udevadm trigger --verbose --type=devices --action=remove --subsystem-match=drm --property-match="MINOR=1"
sleep 2
rmmod -f nvidia_drm nvidia_modeset nvidia_uvm nvidia
echo -n 0000:01:00.0 > /sys/bus/pci/devices/0000:01:00.0/driver/unbind
echo -n 0000:01:00.1 > /sys/bus/pci/drivers/vfio-pci/bind
echo -n 0000:01:00.0 > /sys/bus/pci/drivers/vfio-pci/bind
'';
loadnvidia = pkgs.writeShellScriptBin "loadnvidia" ''
echo 0000:01:00.0 > /sys/bus/pci/devices/0000:01:00.0/driver/unbind
echo 0000:01:00.1 > /sys/bus/pci/devices/0000:01:00.1/driver/unbind
modprobe nvidia
modprobe nvidia_drm
modprobe nvidia_modeset
echo -n 0000:01:00.0 > /sys/bus/pci/drivers/snd_hda_intel/bind
nvidia-smi -i 0 -pm 1
'';
qemuHook = pkgs.writeShellScript "qemu" ''
#
# Author: Sebastiaan Meijer (sebastiaan@passthroughpo.st)
#
# Copy this file to /etc/libvirt/hooks, make sure it's called "qemu".
# After this file is installed, restart libvirt.
# From now on, you can easily add per-guest qemu hooks.
# Add your hooks in /etc/libvirt/hooks/qemu.d/vm_name/hook_name/state_name.
# For a list of available hooks, please refer to https://www.libvirt.org/hooks.html
#
GUEST_NAME="$1"
HOOK_NAME="$2"
STATE_NAME="$3"
MISC="''${@:4}"
BASEDIR="$(dirname $0)"
HOOKPATH="$BASEDIR/qemu.d/$GUEST_NAME/$HOOK_NAME/$STATE_NAME"
set -e # If a script exits with an error, we should as well.
# check if it's a non-empty executable file
if [ -f "$HOOKPATH" ] && [ -s "$HOOKPATH"] && [ -x "$HOOKPATH" ]; then
eval \"$HOOKPATH\" "$@"
elif [ -d "$HOOKPATH" ]; then
while read file; do
# check for null string
if [ ! -z "$file" ]; then
eval \"$file\" "$@"
fi
done <<< "$(find -L "$HOOKPATH" -maxdepth 1 -type f -executable -print;)"
fi
'';
in
{
environment.systemPackages = [
loadnvidia
loadvfio
];
security.sudo.extraConfig = "grimmauld ALL=(ALL) NOPASSWD:/run/current-system/sw/bin/loadnvidia, /run/current-system/sw/bin/loadvfio";
virtualisation.libvirtd = {
enable = true;
qemu = {
runAsRoot = false;
ovmf = {
enable = true;
packages = [
# pkgs.pkgsCross.aarch64-multiplatform.OVMF.fd # AAVMF
pkgs.OVMF.fd
];
};
};
onBoot = "ignore";
onShutdown = "shutdown";
};
programs.virt-manager.enable = true;
virtualisation.spiceUSBRedirection.enable = true;
}

View File

@ -9,7 +9,7 @@
isNormalUser = true; isNormalUser = true;
# shell = pkgs.xonsh; # shell = pkgs.xonsh;
description = "grimmauld"; description = "grimmauld";
extraGroups = lib.intersectLists (lib.attrNames config.users.groups) [ extraGroups = [
"networkmanager" "networkmanager"
"kvm" "kvm"
"wheel" "wheel"
@ -23,7 +23,7 @@
"pipewire" "pipewire"
"gamemode" "gamemode"
"i2c" "i2c"
]; # only add to groups that actually exist on this system ];
syncPaths = [ syncPaths = [
{ remote = "3d"; } { remote = "3d"; }
@ -32,7 +32,10 @@
{ remote = "Videos"; } { remote = "Videos"; }
]; ];
packages = with pkgs; lib.optionals config.grimmShared.graphical [ packages = with pkgs; [
jetbrains.clion
jetbrains.idea-community
webcord webcord
discord discord
obs-studio obs-studio

View File

@ -1,55 +1,15 @@
{ pkgs, config, ... }: { pkgs, ... }:
{ {
imports = [ imports = [
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
# ./modules/kvm.nix
./../../sway
]; ];
age.identityPaths = [ "/home/grimmauld/.ssh/id_ed25519" ]; age.identityPaths = [ "/home/grimmauld/.ssh/id_ed25519" ];
grimmShared = {
tooling = {
pass = true;
lilypond = true;
};
gaming = true;
printing = true;
portals = true;
sound = {
enable = true;
midi = true;
};
graphical = true;
firefox = {
enable = true;
plugins = {
"uBlock0@raymondhill.net" = "ublock-origin";
"gdpr@cavi.au.dk" = "consent-o-matic";
"{41f9e51d-35e4-4b29-af66-422ff81c8b41}" = "disable-javascript";
"{7a7a4a92-a2a0-41d1-9fd7-1e92480d612d}" = "styl-us";
"wappalyzer@crunchlabz.com" = "wappalyzer";
"{b9db16a4-6edc-47ec-a1f4-b86292ed211d}" = "video-downloadhelper";
"{1526fba1-ac33-4dfc-99d8-163e6129f7b9}" = "reveye-ris";
};
};
cloudSync = {
enable = true;
username = "Grimmauld";
server = "cloud.grimmauld.de";
passwordFile = config.age.secrets.nextcloud_pass.path;
};
spotify.enable = true;
};
age.secrets.nextcloud_pass = {
file = ./../../secrets/nextcloud_pass.age;
mode = "777";
};
networking.hostName = "grimmauld-nixos"; networking.hostName = "grimmauld-nixos";
system.stateVersion = "23.05"; system.stateVersion = "23.05";
grimmShared.gaming = true;
} }