refactor(treewide)
This commit is contained in:
parent
25d48ac2ac
commit
c4fc882042
99 changed files with 634 additions and 477 deletions
|
|
@ -1,23 +1,11 @@
|
|||
{ lib, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./shell
|
||||
./boot
|
||||
./nix
|
||||
./displayManager
|
||||
./networking
|
||||
./locale.nix
|
||||
./virtualization
|
||||
./nix
|
||||
./security
|
||||
./services
|
||||
./host
|
||||
./shell
|
||||
./locale.nix
|
||||
];
|
||||
|
||||
|
||||
options.ooknet = {
|
||||
virtualisation = {
|
||||
enable = lib.mkEnableOption "Enable virtualisation module";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
{ lib, config, pkgs, inputs, outputs, self, ... }:
|
||||
|
||||
let
|
||||
cfg = config.ooknet.host.admin;
|
||||
ifTheyExist = groups: builtins.filter (group: builtins.hasAttr group config.users.groups) groups;
|
||||
inherit (lib) mkIf;
|
||||
in
|
||||
|
||||
{
|
||||
config = {
|
||||
users.users.${cfg.name} = {
|
||||
isNormalUser = true;
|
||||
shell = pkgs.${cfg.shell};
|
||||
initialPassword = "password";
|
||||
openssh.authorizedKeys.keys = [ "${cfg.sshKey}" ];
|
||||
extraGroups = [
|
||||
"wheel"
|
||||
"video"
|
||||
"audio"
|
||||
] ++ ifTheyExist [
|
||||
"git"
|
||||
"media"
|
||||
"network"
|
||||
"libvirtd"
|
||||
"deluge"
|
||||
"streamer"
|
||||
"torrenter"
|
||||
];
|
||||
};
|
||||
home-manager = mkIf cfg.homeManager {
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
backupFileExtension = "hm.old";
|
||||
verbose = true;
|
||||
extraSpecialArgs = { inherit inputs outputs self; };
|
||||
users.${cfg.name} = {
|
||||
imports = [ "${self}/home" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
imports = [
|
||||
./admin.nix
|
||||
./name.nix
|
||||
./type.nix
|
||||
./role.nix
|
||||
./hardware
|
||||
];
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
{ lib, config, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
host = config.ooknet.host;
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (host.type != "phone") {
|
||||
hardware = {
|
||||
enableRedistributableFirmware = true;
|
||||
enableAllFirmware = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
{ lib, config, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkMerge mkIf versionAtLeast versionOlder;
|
||||
inherit (builtins) elem;
|
||||
cpu = config.ooknet.host.hardware.cpu;
|
||||
cfg = cpu.amd;
|
||||
kernelVersion = config.boot.kernelPackages.kernel.version;
|
||||
kernelVersionAtLeast = versionAtLeast kernelVersion;
|
||||
kernelVersionOlder= versionOlder kernelVersion;
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (elem cpu.type ["amd"]) {
|
||||
environment.systemPackages = [pkgs.amdctl];
|
||||
hardware.cpu.amd.updateMicrocode = true;
|
||||
boot = mkMerge [
|
||||
{
|
||||
kernelModules = [
|
||||
"amd-pstate"
|
||||
"amd-kvm" # virtulization
|
||||
"msr" # required for amdctl
|
||||
];
|
||||
}
|
||||
|
||||
(mkIf (cfg.pstate.enable && (kernelVersionAtLeast "5.27") && (kernelVersionOlder "6.1")) {
|
||||
kernelParams = ["initcall_blacklist-acpi_cpufreq_init"];
|
||||
kernelModules = ["amd-pstate"];
|
||||
})
|
||||
|
||||
(mkIf (cfg.pstate.enable && (kernelVersionAtLeast "6.1") && (kernelVersionOlder "6.3")) {
|
||||
kernelParams = ["amd_pstate=passive"];
|
||||
})
|
||||
|
||||
(mkIf (cfg.pstate.enable && (kernelVersionAtLeast "6.3")) {
|
||||
kernelParams = ["amd_pstate=active"];
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
imports = [
|
||||
./amd.nix
|
||||
./intel.nix
|
||||
];
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
inherit (builtins) elem;
|
||||
cpu = config.ooknet.host.hardware.cpu;
|
||||
in
|
||||
|
||||
{
|
||||
# TODO: put kvm/gvt behind virtualization module flag
|
||||
|
||||
config = mkIf (elem cpu.type ["intel"]) {
|
||||
boot = {
|
||||
kernelModules = ["kvm-intel"];
|
||||
kernelParams = ["i915.fastboot=1" "enable_gvt=1"];
|
||||
};
|
||||
hardware.cpu.intel.updateMicrocode = true;
|
||||
environment.systemPackages = [pkgs.intel-gpu-tools];
|
||||
};
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
imports = [
|
||||
./cpu
|
||||
./gpu
|
||||
./features
|
||||
./common.nix
|
||||
./monitors.nix
|
||||
];
|
||||
}
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
inherit (lib.generators) toLua;
|
||||
inherit (lib.lists) elem optionals;
|
||||
# inherit (builtins) elem;
|
||||
features = config.ooknet.host.hardware.features;
|
||||
hasBT = (elem "bluetooth" features);
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (elem "audio" features) {
|
||||
hardware.pulseaudio.enable = !config.services.pipewire.enable;
|
||||
security.rtkit.enable = config.services.pipewire.enable;
|
||||
services.pipewire =
|
||||
let
|
||||
quantum = 64;
|
||||
rate = 48000;
|
||||
qr = "${toString quantum}/${toString rate}";
|
||||
in
|
||||
{
|
||||
enable = true;
|
||||
|
||||
alsa.enable = true;
|
||||
alsa.support32Bit = true;
|
||||
pulse.enable = true;
|
||||
jack.enable = true;
|
||||
|
||||
# Low latency module provided by notashelf/nyx
|
||||
extraConfig.pipewire."99-lowlatency" = {
|
||||
context = {
|
||||
properties.default.clock.min-quantum = quantum;
|
||||
modules = [
|
||||
{
|
||||
name = "libpipewire-module-rtkit";
|
||||
flags = ["ifexists" "nofail"];
|
||||
args = {
|
||||
nice.level = -15;
|
||||
rt = {
|
||||
prio = 88;
|
||||
time.soft = 200000;
|
||||
time.hard = 200000;
|
||||
};
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "libpipewire-module-protocol-pulse";
|
||||
args = {
|
||||
server.address = ["unix:native"];
|
||||
pulse.min = {
|
||||
req = qr;
|
||||
quantum = qr;
|
||||
frag = qr;
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
stream.properties = {
|
||||
node.latency = qr;
|
||||
resample.quality = 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
wireplumber = {
|
||||
enable = true;
|
||||
configPackages = let
|
||||
matches = toLua {
|
||||
multiline = false;
|
||||
indent = false;
|
||||
} [[["node.name" "matches" "alsa_output.*"]]];
|
||||
|
||||
apply_properties = toLua {} {
|
||||
"audio.format" = "S32LE";
|
||||
"audio.rate" = rate * 2;
|
||||
"api.alsa.period-size" = 2;
|
||||
};
|
||||
in
|
||||
[
|
||||
(pkgs.writeTextDir "share/lowlatency.lua.d/99-alsa-lowlatency.lua" ''
|
||||
alsa_monitor.rules = {
|
||||
{
|
||||
matches = ${matches};
|
||||
apply_properties = ${apply_properties};
|
||||
}
|
||||
}
|
||||
'')
|
||||
]
|
||||
++ optionals hasBT [
|
||||
(pkgs.writeTextDir "share/bluetooth.lua.d/51-bluez-config.lua" /* lua */ ''
|
||||
bluez_monitor.properties = {
|
||||
["bluez5.enable-sbc-xq"] = true,
|
||||
["bluez5.enable-msbc"] = true,
|
||||
["bluez5.enable-hw-volume"] = true,
|
||||
["bluez5.headset-roles"] = "[ hsp_hs hsp_ag hfp_hf hfp_ag ]"
|
||||
}
|
||||
'')
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.services = {
|
||||
pipewire.wantedBy = ["default.target"];
|
||||
pipewire-pulse.wantedBy = ["default.target"];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
{ lib, config, ... }:
|
||||
|
||||
let
|
||||
features = config.ooknet.host.hardware.features;
|
||||
inherit (lib) mkIf;
|
||||
inherit (builtins) elem;
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (elem "backlight" features) {
|
||||
hardware.brillo.enable = true;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
|
||||
{ lib, config, pkgs, ... }:
|
||||
|
||||
let
|
||||
features = config.ooknet.host.hardware.features;
|
||||
cfg = config.ooknet.host.hardware.battery;
|
||||
inherit (lib) mkIf mkDefault;
|
||||
inherit (builtins) elem;
|
||||
MHz = x: x * 1000;
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (elem "battery" features) {
|
||||
boot = {
|
||||
kernelModules = ["acpi_call"];
|
||||
extraModulePackages = with config.boot.kernelPackages; [
|
||||
acpi_call
|
||||
cpupower
|
||||
];
|
||||
};
|
||||
|
||||
services = {
|
||||
auto-cpufreq = {
|
||||
enable = true;
|
||||
settings = {
|
||||
battery = {
|
||||
governor = "powersave";
|
||||
scaling_min_freq = mkDefault (MHz cfg.powersave.minFreq);
|
||||
scaling_max_freq = mkDefault (MHz cfg.powersave.maxFreq);
|
||||
turbo = "never";
|
||||
};
|
||||
charger = {
|
||||
governor = "performance";
|
||||
scaling_min_freq = mkDefault (MHz cfg.performance.minFreq);
|
||||
scaling_max_freq = mkDefault (MHz cfg.performance.maxFreq);
|
||||
turbo = "auto";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
upower = {
|
||||
enable = true;
|
||||
percentageLow = 25;
|
||||
percentageCritical = 5;
|
||||
percentageAction = 3;
|
||||
criticalPowerAction = "Hibernate";
|
||||
};
|
||||
|
||||
undervolt = {
|
||||
enable = true;
|
||||
tempBat = 65;
|
||||
};
|
||||
|
||||
thermald.enable = true;
|
||||
|
||||
power-profiles-daemon.enable = true;
|
||||
|
||||
logind = {
|
||||
lidSwitch = "suspend";
|
||||
};
|
||||
};
|
||||
environment.systemPackages = with pkgs; [
|
||||
acpi
|
||||
powertop
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
{ config, lib, pkgs, self, ... }:
|
||||
|
||||
let
|
||||
features = config.ooknet.host.hardware.features;
|
||||
inherit (lib) mkIf;
|
||||
inherit (builtins) elem;
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (elem "bluetooth" features) {
|
||||
hardware.bluetooth = {
|
||||
enable = true;
|
||||
package = pkgs.bluez5-experimental;
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
self.packages.${pkgs.system}.live-buds-cli
|
||||
bluetuith
|
||||
];
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/issues/114222
|
||||
systemd.user.services.telephony_client.enable = false;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
imports = [
|
||||
./bluetooth.nix
|
||||
./backlight.nix
|
||||
./battery.nix
|
||||
./ssd.nix
|
||||
./audio.nix
|
||||
./video.nix
|
||||
];
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
{ lib, config, ... }:
|
||||
|
||||
let
|
||||
features = config.ooknet.host.hardware.features;
|
||||
inherit (lib) mkIf;
|
||||
inherit (builtins) elem;
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (elem "ssd" features) {
|
||||
services.fstrim = {
|
||||
enable = true;
|
||||
};
|
||||
# only run fstrim while connected on AC
|
||||
systemd.services.fstrim = {
|
||||
unitConfig.ConditionACPower = true;
|
||||
serviceConfig = {
|
||||
Nice = 19;
|
||||
IOSchedulingClass = "idle";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
{ lib, config, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
inherit (builtins) elem;
|
||||
isx86Linux = pkgs: with pkgs.stdenv; hostPlatform.isLinux && hostPlatform.isx86;
|
||||
features = config.ooknet.host.hardware.features;
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (elem "video" features) {
|
||||
hardware = {
|
||||
opengl = {
|
||||
enable = true;
|
||||
driSupport = true;
|
||||
driSupport32Bit = isx86Linux pkgs;
|
||||
};
|
||||
};
|
||||
xdg.portal = {
|
||||
enable = true;
|
||||
xdgOpenUsePortal = true;
|
||||
extraPortals = with pkgs; [
|
||||
xdg-desktop-portal-hyprland
|
||||
xdg-desktop-portal-gtk
|
||||
];
|
||||
config = {
|
||||
common.default = ["gtk"];
|
||||
hyprland.default = ["gtk" "hyprland"];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
gpu = config.ooknet.host.hardware.gpu;
|
||||
inherit (lib) mkIf mkDefault;
|
||||
inherit (builtins) elem;
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (elem gpu.type ["amd"]) {
|
||||
hardware.opengl = {
|
||||
extraPackages = with pkgs; [
|
||||
vulkan-tools
|
||||
vulkan-loader
|
||||
vulkan-extension-layer
|
||||
vulkan-validation-layers
|
||||
# amdvlk
|
||||
mesa
|
||||
];
|
||||
extraPackages32 = [ pkgs.driversi686Linux.amdvlk ];
|
||||
};
|
||||
boot = {
|
||||
initrd.kernelModules = ["amdgpu"];
|
||||
kernelModules = ["amdgpu"];
|
||||
};
|
||||
environment.systemPackages = [ pkgs.nvtopPackages.amd ];
|
||||
services.xserver.videoDrivers = mkDefault ["modesetting" "amdgpu"];
|
||||
};
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
imports = [
|
||||
./amd.nix
|
||||
./intel.nix
|
||||
./nvidia.nix
|
||||
];
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
gpu = config.ooknet.host.hardware.gpu;
|
||||
inherit (lib) mkIf;
|
||||
inherit (builtins) elem;
|
||||
|
||||
# vaapiIntel = pkgs.vaapiIntel.override {enableHybridCodec = true;};
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (elem gpu.type ["intel"]) {
|
||||
|
||||
services.xserver.videoDrivers = ["modesetting"];
|
||||
hardware.opengl = {
|
||||
extraPackages = with pkgs; [
|
||||
vaapiIntel
|
||||
vaapiVdpau
|
||||
libvdpau-va-gl
|
||||
|
||||
intel-compute-runtime
|
||||
intel-media-driver
|
||||
];
|
||||
extraPackages32 = with pkgs.pkgsi686Linux; [
|
||||
vaapiIntel
|
||||
vaapiVdpau
|
||||
libvdpau-va-gl
|
||||
|
||||
intel-media-driver
|
||||
];
|
||||
};
|
||||
boot.initrd.kernelModules = ["i915"];
|
||||
environment.variables = mkIf config.hardware.opengl.enable {
|
||||
VDPAU_DRIVER = "va_gl";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
gpu = config.ooknet.host.hardware.gpu;
|
||||
inherit (lib) mkIf mkDefault;
|
||||
inherit (builtins) elem;
|
||||
production = config.boot.kernelPackages.nvidiaPackages.production;
|
||||
# beta = config.boot.kernelPackages.nvidiaPackages.beta;
|
||||
in
|
||||
|
||||
{
|
||||
# TODO: make option to choose nvidia package
|
||||
config = mkIf (elem gpu.type ["nvidia"]) {
|
||||
hardware = {
|
||||
nvidia = {
|
||||
open = mkDefault true;
|
||||
package = production;
|
||||
forceFullCompositionPipeline = true;
|
||||
nvidiaSettings = false;
|
||||
nvidiaPersistenced = true;
|
||||
modesetting.enable = true;
|
||||
powerManagement = {
|
||||
enable = mkDefault true;
|
||||
finegrained = mkDefault false;
|
||||
};
|
||||
};
|
||||
opengl = {
|
||||
extraPackages = with pkgs; [ nvidia-vaapi-driver ];
|
||||
extraPackages32 = with pkgs.pkgsi686Linux; [ nvidia-vaapi-driver ];
|
||||
};
|
||||
};
|
||||
environment.systemPackages = with pkgs; [
|
||||
|
||||
libva
|
||||
libva-utils
|
||||
|
||||
vulkan-loader
|
||||
vulkan-validation-layers
|
||||
vulkan-tools
|
||||
vulkan-extension-layer
|
||||
|
||||
mesa
|
||||
|
||||
nvtopPackages.nvidia
|
||||
];
|
||||
environment.sessionVariables = {
|
||||
LIBVA_DRIVER_NAME = "nvidia";
|
||||
NVD_BACKEND = "direct";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
{ config, ... }:
|
||||
|
||||
let
|
||||
cfg = config.ooknet.host;
|
||||
in
|
||||
|
||||
{
|
||||
config = {
|
||||
networking.hostName = cfg.name;
|
||||
environment.sessionVariables.HN = cfg.name;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
{ lib, config, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
inherit (lib.lists) any elem;
|
||||
hasFunction = f: elem f config.ooknet.host.function;
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (any hasFunction ["workstation" "gaming"]) {
|
||||
services.dbus = {
|
||||
enable = true;
|
||||
packages = with pkgs; [ dconf gcr udisks2 ];
|
||||
implementation = "broker";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
imports = [
|
||||
./system76Scheduler.nix
|
||||
./dbus.nix
|
||||
./gnome.nix
|
||||
./gvfs.nix
|
||||
];
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
{ lib, config, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
host = config.ooknet.host;
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (host.type != "phone" && host.type != "server") {
|
||||
services = {
|
||||
gnome = {
|
||||
glib-networking.enable = true;
|
||||
gnome-keyring.enable = true;
|
||||
};
|
||||
udev.packages = [ pkgs.gnome.gnome-settings-daemon ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
{ lib, config, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
host = config.ooknet.host;
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf ( host.type != "phone") {
|
||||
services.gvfs.enable = true;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
{ lib, config, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
host = config.ooknet.host;
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (host.type != "phone") {
|
||||
|
||||
services.system76-scheduler = {
|
||||
enable = true;
|
||||
};
|
||||
# fix suspend issues
|
||||
powerManagement = {
|
||||
powerDownCommands = "systemctl stop system76-scheduler";
|
||||
resumeCommands = "systemctl start system76-scheduler";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
{ lib, config, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.ooknet.virtualisation;
|
||||
in
|
||||
|
||||
{
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.systemPackages = with pkgs; [
|
||||
virt-manager
|
||||
virt-viewer
|
||||
spice
|
||||
spice-gtk
|
||||
spice-protocol
|
||||
win-virtio
|
||||
win-spice
|
||||
gnome.adwaita-icon-theme
|
||||
];
|
||||
|
||||
virtualisation = {
|
||||
libvirtd = {
|
||||
enable = true;
|
||||
qemu = {
|
||||
swtpm.enable = true;
|
||||
ovmf.enable = true;
|
||||
ovmf.packages = [ pkgs.OVMFFull.fd ];
|
||||
};
|
||||
};
|
||||
spiceUSBRedirection.enable = true;
|
||||
};
|
||||
services.spice-vdagentd.enable = true;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue