refactor(treewide): format with alejandra

This commit is contained in:
ooks-io 2024-07-29 15:00:38 +12:00
parent 7fefb94400
commit 61cef505da
216 changed files with 5995 additions and 3969 deletions

View file

@ -1,40 +1,47 @@
{ lib, config, pkgs, inputs, outputs, self, keys, ... }:
let
{
lib,
config,
pkgs,
inputs,
outputs,
self,
keys,
...
}: let
cfg = config.ooknet.host.admin;
ifTheyExist = groups: builtins.filter (group: builtins.hasAttr group config.users.groups) groups;
inherit (lib) mkIf;
in
{
in {
config = {
users.users.${cfg.name} = {
isNormalUser = true;
shell = pkgs.${cfg.shell};
initialPassword = "password";
openssh.authorizedKeys.keys = [ (keys.users."${cfg.name}") ];
extraGroups = [
"wheel"
"video"
"audio"
] ++ ifTheyExist [
"git"
"media"
"network"
"libvirtd"
"deluge"
"streamer"
"torrenter"
];
openssh.authorizedKeys.keys = [(keys.users."${cfg.name}")];
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; };
extraSpecialArgs = {inherit inputs outputs self;};
users.${cfg.name} = {
imports = [ "${self}/home" ];
imports = ["${self}/home"];
};
};
};

View file

@ -1,11 +1,11 @@
{ lib, config, ... }:
let
{
lib,
config,
...
}: let
inherit (lib) mkIf;
host = config.ooknet.host;
in
{
in {
config = mkIf (host.type != "phone") {
hardware = {
enableRedistributableFirmware = true;

View file

@ -1,16 +1,17 @@
{ lib, config, pkgs, ... }:
let
{
lib,
config,
pkgs,
...
}: let
inherit (lib) mkMerge mkIf versionAtLeast versionOlder;
inherit (builtins) elem;
cpu = config.ooknet.host.hardware.cpu;
cpu = config.ooknet.host.hardware.cpu;
cfg = cpu.amd;
kernelVersion = config.boot.kernelPackages.kernel.version;
kernelVersionAtLeast = versionAtLeast kernelVersion;
kernelVersionOlder= versionOlder kernelVersion;
in
{
kernelVersionOlder = versionOlder kernelVersion;
in {
config = mkIf (elem cpu.type ["amd"]) {
environment.systemPackages = [pkgs.amdctl];
hardware.cpu.amd.updateMicrocode = true;
@ -22,7 +23,7 @@ in
"msr" # required for amdctl
];
}
(mkIf (cfg.pstate.enable && (kernelVersionAtLeast "5.27") && (kernelVersionOlder "6.1")) {
kernelParams = ["initcall_blacklist-acpi_cpufreq_init"];
kernelModules = ["amd-pstate"];

View file

@ -1,12 +1,13 @@
{ config, lib, pkgs, ... }:
let
{
config,
lib,
pkgs,
...
}: let
inherit (lib) mkIf;
inherit (builtins) elem;
cpu = config.ooknet.host.hardware.cpu;
in
{
in {
# TODO: put kvm/gvt behind virtualization module flag
config = mkIf (elem cpu.type ["intel"]) {

View file

@ -1,25 +1,24 @@
{ config, lib, pkgs, ... }:
let
{
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
{
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
services.pipewire = let
quantum = 64;
rate = 48000;
qr = "${toString quantum}/${toString rate}";
in
{
in {
enable = true;
alsa.enable = true;
@ -89,14 +88,18 @@ in
'')
]
++ 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 ]"
}
'')
(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 ]"
}
'')
];
};
};
@ -106,6 +109,4 @@ in
pipewire-pulse.wantedBy = ["default.target"];
};
};
}
}

View file

@ -1,12 +1,12 @@
{ lib, config, ... }:
let
{
lib,
config,
...
}: let
features = config.ooknet.host.hardware.features;
inherit (lib) mkIf;
inherit (builtins) elem;
in
{
in {
config = mkIf (elem "backlight" features) {
hardware.brillo.enable = true;
};

View file

@ -1,15 +1,15 @@
{ lib, config, pkgs, ... }:
let
{
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
{
in {
config = mkIf (elem "battery" features) {
boot = {
kernelModules = ["acpi_call"];

View file

@ -1,22 +1,24 @@
{ config, lib, pkgs, self, ... }:
let
{
config,
lib,
pkgs,
self,
...
}: let
features = config.ooknet.host.hardware.features;
inherit (lib) mkIf;
inherit (builtins) elem;
in
{
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
];
bluetuith
];
# https://github.com/NixOS/nixpkgs/issues/114222
systemd.user.services.telephony_client.enable = false;

View file

@ -1,12 +1,12 @@
{ lib, config, ... }:
let
{
lib,
config,
...
}: let
features = config.ooknet.host.hardware.features;
inherit (lib) mkIf;
inherit (builtins) elem;
in
{
in {
config = mkIf (elem "ssd" features) {
services.fstrim = {
enable = true;
@ -18,6 +18,6 @@ in
Nice = 19;
IOSchedulingClass = "idle";
};
};
};
};
}

View file

@ -1,13 +1,15 @@
{ lib, inputs, config, pkgs, ... }:
let
{
lib,
inputs,
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
{
in {
config = mkIf (elem "video" features) {
hardware = {
opengl = {

View file

@ -1,12 +1,13 @@
{ config, lib, pkgs, ... }:
let
{
config,
lib,
pkgs,
...
}: let
gpu = config.ooknet.host.hardware.gpu;
inherit (lib) mkIf mkDefault;
inherit (builtins) elem;
in
{
in {
config = mkIf (elem gpu.type ["amd"]) {
hardware.opengl = {
extraPackages = with pkgs; [
@ -17,13 +18,13 @@ in
# amdvlk
mesa
];
extraPackages32 = [ pkgs.driversi686Linux.amdvlk ];
extraPackages32 = [pkgs.driversi686Linux.amdvlk];
};
boot = {
initrd.kernelModules = ["amdgpu"];
kernelModules = ["amdgpu"];
};
environment.systemPackages = [ pkgs.nvtopPackages.amd ];
environment.systemPackages = [pkgs.nvtopPackages.amd];
services.xserver.videoDrivers = mkDefault ["modesetting" "amdgpu"];
};
}

View file

@ -1,16 +1,15 @@
{ config, lib, pkgs, ... }:
let
{
config,
lib,
pkgs,
...
}: let
gpu = config.ooknet.host.hardware.gpu;
inherit (lib) mkIf;
inherit (builtins) elem;
# vaapiIntel = pkgs.vaapiIntel.override {enableHybridCodec = true;};
in
{
in {
config = mkIf (elem gpu.type ["intel"]) {
services.xserver.videoDrivers = ["modesetting"];
hardware.opengl = {
extraPackages = with pkgs; [
@ -29,7 +28,7 @@ in
intel-media-driver
];
};
boot.initrd.kernelModules = ["i915"];
boot.initrd.kernelModules = ["i915"];
environment.variables = mkIf config.hardware.opengl.enable {
VDPAU_DRIVER = "va_gl";
};

View file

@ -1,15 +1,16 @@
{ config, lib, pkgs, ... }:
let
{
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
in {
# TODO: make option to choose nvidia package
config = mkIf (elem gpu.type ["nvidia"]) {
hardware = {
nvidia = {
@ -25,12 +26,11 @@ in
};
};
opengl = {
extraPackages = with pkgs; [ nvidia-vaapi-driver ];
extraPackages32 = with pkgs.pkgsi686Linux; [ nvidia-vaapi-driver ];
extraPackages = with pkgs; [nvidia-vaapi-driver];
extraPackages32 = with pkgs.pkgsi686Linux; [nvidia-vaapi-driver];
};
};
environment.systemPackages = with pkgs; [
libva
libva-utils

View file

@ -1,10 +1,6 @@
{ config, ... }:
let
{config, ...}: let
cfg = config.ooknet.host;
in
{
in {
config = {
networking.hostName = cfg.name;
environment.sessionVariables.HN = cfg.name;