Modularize hardware config and remove specific nix folder

This commit is contained in:
DashieTM 2024-07-20 01:56:54 +02:00
parent a5042bb645
commit 9ac5b25036
72 changed files with 322 additions and 100 deletions

View file

Before

Width:  |  Height:  |  Size: 127 KiB

After

Width:  |  Height:  |  Size: 127 KiB

Before After
Before After

1
base/extra.nix Normal file
View file

@ -0,0 +1 @@
{ options, ... }: options.extra.extraHardwareConfig

View file

@ -185,11 +185,11 @@
"nixvim": "nixvim"
},
"locked": {
"lastModified": 1721250623,
"narHash": "sha256-w80Q5dvELC7W5rGx0gu9Jp+B2qxUA7irGIN3zAZcbiI=",
"lastModified": 1721432745,
"narHash": "sha256-99fI3sZg/jojY42Z4VsdjdGuGgLsA6i4PiNSBQ7M+pg=",
"owner": "DashieTM",
"repo": "DashVim",
"rev": "f4da99286b729a4300697c53c3a4b9ab9f8979aa",
"rev": "a179c152e322084426d21a7e9152e1d679184b1a",
"type": "github"
},
"original": {
@ -851,11 +851,11 @@
"xdph": "xdph"
},
"locked": {
"lastModified": 1721248202,
"narHash": "sha256-VAhuQQ4EKbw/6z7K2IoR83+gXUdMksLWFQOhJNhSvQE=",
"lastModified": 1721428662,
"narHash": "sha256-fs5PV+LjzNizY/8fURUHOFHs/92JhzMPM7QQr4XsPtg=",
"ref": "refs/heads/main",
"rev": "300228b503b36e5977b0d58713c5b4cf1f07b8a9",
"revCount": 4930,
"rev": "9b0993cc49b7285a2724a87fdb72bfc90cc75cc5",
"revCount": 4933,
"submodules": true,
"type": "git",
"url": "https://github.com/hyprwm/Hyprland"
@ -980,11 +980,11 @@
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1720904669,
"narHash": "sha256-Se+Pg81W8R+SFGFlhF1dU+NnMWSdLo3nC9TdPHa2IL4=",
"lastModified": 1721405746,
"narHash": "sha256-ug0GSFb0/CIRZ3RE18wCvrNHXhUm8qiJ+W+mHnooQ+U=",
"owner": "JakeStanger",
"repo": "ironbar",
"rev": "58190ab079d00dd53babb72346f1da6e1cc9ac72",
"rev": "73bdff656f09ebedf767c33bd28c5551b3423c44",
"type": "github"
},
"original": {
@ -1380,11 +1380,11 @@
},
"nixpkgs_7": {
"locked": {
"lastModified": 1720957393,
"narHash": "sha256-oedh2RwpjEa+TNxhg5Je9Ch6d3W1NKi7DbRO1ziHemA=",
"lastModified": 1721379653,
"narHash": "sha256-8MUgifkJ7lkZs3u99UDZMB4kbOxvMEXQZ31FO3SopZ0=",
"owner": "NixOs",
"repo": "nixpkgs",
"rev": "693bc46d169f5af9c992095736e82c3488bf7dbb",
"rev": "1d9c2c9b3e71b9ee663d11c5d298727dace8d374",
"type": "github"
},
"original": {
@ -1453,11 +1453,11 @@
},
"nur": {
"locked": {
"lastModified": 1721241063,
"narHash": "sha256-jBAuwmtJmSNT6xwjtGINslFK0m3R3+Ydw+xrd+a3tSE=",
"lastModified": 1721420802,
"narHash": "sha256-8kmavDJgzkEwUujFAJCkoLk79r5DRuyVfu5TlLap624=",
"owner": "nix-community",
"repo": "nur",
"rev": "f33f46c1e38b07b20a978ac39208058ab9ddedb1",
"rev": "3a24dfcc6b7bc383112e5a9e13d7c04cb659eff8",
"type": "github"
},
"original": {
@ -1798,11 +1798,11 @@
"nixpkgs": "nixpkgs_22"
},
"locked": {
"lastModified": 1720818679,
"narHash": "sha256-u9PqY7O6TN42SLeb0e6mnYAgQOoQmclaVSHfLKMpmu0=",
"lastModified": 1721429336,
"narHash": "sha256-DTJUvI4Xkj4KC5tdq15OEUkPpk7Ebvqcz356dIT6jtY=",
"owner": "danth",
"repo": "stylix",
"rev": "29148118cc33f08b71058e1cda7ca017f5300b51",
"rev": "6bbae4f85b891df2e6e48b649919420434088507",
"type": "github"
},
"original": {

View file

@ -16,6 +16,11 @@
# all others
",highrr,auto,1"
];
colorscheme="catppuccin-mocha";
colorscheme = "catppuccin-mocha";
};
mods = {
amdgpu.enable = true;
kde_connect.enable = true;
xone.enable = true;
};
}

View file

@ -22,4 +22,10 @@
};
colorscheme = "catppuccin-mocha";
};
mods = {
amdgpu.enable = true;
kde_connect.enable = true;
bluetooth.enable = true;
acpid.enable = true;
};
}

View file

@ -0,0 +1,9 @@
{
# special hardware modules
# mostly to fix firmare and dsts
imports =
[
./dsdt.nix
./firmware.nix
];
}

View file

@ -4,7 +4,7 @@ let
in
{
imports = [
../../modules/conf.nix
../../modules
];
# config variables
@ -26,6 +26,7 @@ in
# all others
",highrr,auto,1"
];
workspace = [
# workspaces
# monitor middle
@ -60,4 +61,29 @@ in
};
colorscheme = "catppuccin-mocha";
};
mods = {
extraDrives = [
{
name = "drive2";
drive =
{
device = "/dev/disk/by-label/DRIVE2";
fsType = "ext4";
options = [
"noatime"
"nodiratime"
"discard"
];
};
}
];
virtualbox.enable = true;
kde_connect.enable = true;
xone.enable = true;
amdgpu.enable = true;
vapi = {
enable = true;
rocm.enable = true;
};
};
}

View file

@ -1,4 +1,4 @@
{ lib, config, pkgs, ... }: {
{ lib, config, pkgs, options, ... }: {
options.conf = {
system = lib.mkOption {
@ -52,15 +52,6 @@
};
};
amdGpu = lib.mkOption {
default = false;
example = true;
type = lib.types.bool;
description = ''
Enables drivers, optimizations and kernel parameters for AMD gpus.
'';
};
boot_params = lib.mkOption {
default = [ ];
example = [ "resume=something" ];
@ -216,10 +207,6 @@
};
config = {
conf.boot_params = lib.mkIf config.conf.amdGpu [
"amdgpu.ppfeaturemask=0xffffffff"
];
conf.kernel = lib.mkIf config.conf.gaming.enable pkgs.linuxPackages_xanmod_latest;
};
}

6
modules/default.nix Normal file
View file

@ -0,0 +1,6 @@
{
imports = [
./programs
./conf.nix
];
}

View file

@ -0,0 +1,18 @@
{ lib, config, options, ... }: {
options.mods = {
acpid.enable = lib.mkOption {
default = false;
type = lib.types.bool;
example = true;
description = ''
Enables acpid.
'';
};
};
config = lib.mkIf config.mods.acpid.enable (lib.optionalAttrs (options?virtualisation.virtualbox.host) {
services.acpid.enable = true;
});
}

View file

@ -0,0 +1,20 @@
{ lib, config, options, ... }: {
options.mods = {
bluetooth.enable = lib.mkOption {
default = false;
type = lib.types.bool;
example = true;
description = ''
Enables bluetooth.
'';
};
};
config = lib.mkIf config.mods.bluetooth.enable (lib.optionalAttrs (options?hardware.bluetooth) {
hardware.bluetooth = {
enable = true;
powerOnBoot = true;
};
});
}

View file

@ -0,0 +1,11 @@
{
imports = [
./virtualbox.nix
./kde_connect.nix
./gpu.nix
./xone.nix
./drives.nix
./bluetooth.nix
./acpid.nix
];
}

View file

@ -0,0 +1,69 @@
{ lib, config, options, ... }:
let
driveModule = lib.types.submodule {
options = {
name = lib.mkOption {
type = lib.types.str;
description = ''
The path of the drive.
Note that a / is already added at the beginning.
'';
default = "";
example = "drive2";
};
drive = lib.mkOption {
type = lib.types.attrsOf lib.types.anything;
description = "The attrs of the drive";
default = { };
example = {
device = "/dev/disk/by-label/DRIVE2";
fsType = "ext4";
options = [
"noatime"
"nodiratime"
"discard"
];
};
};
};
};
in
{
options.mods = {
extraDrives =
lib.mkOption {
default = [ ];
example = [
{
name = "drive2";
drive = {
device = "/dev/disk/by-label/DRIVE2";
fsType = "ext4";
options = [
"noatime"
"nodiratime"
"discard"
];
};
}
];
# TODO: how to make this work
# type = with lib.types; listOf (attrsOf driveModule);
type = with lib.types; listOf (attrsOf anything);
description = ''
Extra drives to add.
'';
};
};
config = (lib.optionalAttrs (options?fileSystems) {
fileSystems = builtins.listToAttrs
(map
({ name, drive }: {
name = "/" + name;
value = drive;
})
config.mods.extraDrives);
});
}

63
modules/programs/gpu.nix Normal file
View file

@ -0,0 +1,63 @@
{ lib, config, options, pkgs, ... }: {
options.mods = {
amdgpu.enable = lib.mkOption {
default = false;
type = lib.types.bool;
example = true;
description = ''
Enables amdgpu support.
'';
};
vapi = {
enable = lib.mkOption {
default = false;
type = lib.types.bool;
example = true;
description = ''
Enables vapi.
'';
};
rocm.enable = lib.mkOption {
default = false;
type = lib.types.bool;
example = true;
description = ''
Enables rocm support.
'';
};
};
};
config = lib.mkIf config.mods.vapi.enable
(lib.optionalAttrs
(options?hardware.graphics)
{
boot = lib.mkIf config.mods.amdgpu.enable {
kernelModules = [ "kvm-amd" ];
initrd.kernelModules = [ "amdgpu" ];
kernelParams = [
"amdgpu.ppfeaturemask=0xffffffff"
];
};
hardware = {
graphics =
let
base_packages = [
pkgs.libvdpau-va-gl
pkgs.vaapiVdpau
];
rocm_packages = [
pkgs.rocmPackages.clr.icd
pkgs.rocm-opencl-runtime
];
in
{
enable = true;
enable32Bit = lib.mkDefault true;
extraPackages = base_packages ++
(lib.lists.optionals config.mods.vapi.rocm.enable rocm_packages);
};
};
});
}

View file

@ -0,0 +1,30 @@
{ lib, config, options, pkgs, ... }: {
options.mods = {
kde_connect.enable = lib.mkOption {
default = false;
type = lib.types.bool;
example = true;
description = ''
Enables kde_connect.
'';
};
};
config = lib.mkIf config.mods.kde_connect.enable
(lib.optionalAttrs (options?networking.firewall)
{
networking.firewall = {
allowedTCPPortRanges = [
{ from = 1714; to = 1764; } # KDE Connect
];
allowedUDPPortRanges = [
{ from = 1714; to = 1764; } # KDE Connect
];
};
} // lib.optionalAttrs (options?home.packages) {
home.packages = with pkgs; [
kdeconnect
];
});
}

View file

@ -0,0 +1,17 @@
{ lib, config, options, ... }: {
options.mods = {
virtualbox.enable = lib.mkOption {
default = false;
type = lib.types.bool;
example = true;
description = ''
Enables virtualbox.
'';
};
};
config = lib.optionalAttrs (options?virtualisation.virtualbox.host) {
virtualisation.virtualbox.host.enable = lib.mkIf config.mods.virtualbox.enable true;
};
}

17
modules/programs/xone.nix Normal file
View file

@ -0,0 +1,17 @@
{ lib, config, options, ... }: {
options.mods = {
xone.enable = lib.mkOption {
default = false;
type = lib.types.bool;
example = true;
description = ''
Enables the xone driver for xbox controllers.
'';
};
};
config = lib.optionalAttrs (options?hardware) {
hardware.xone.enable = true;
};
}

View file

@ -1,7 +0,0 @@
keys:
- &dashie 92D29D420B5D95FCA46A12FE778CFA7A623614F3
creation_rules:
- path_regex: secrets/[^/]+\.(yaml|json|env|ini)$
key_groups:
- pgp:
- *dashie

View file

@ -1,15 +0,0 @@
{
imports =
[
./dsdt.nix
./firmware.nix
];
# special hardware modules
# TODO: needed?
boot.kernelModules = [ "kvm-amd" ];
hardware.bluetooth.enable = true;
hardware.bluetooth.powerOnBoot = true;
# for hyprdock
services.acpid.enable = true;
}

View file

@ -1,40 +0,0 @@
{ pkgs, lib, ... }:
{
# TODO: needed?
boot.kernelModules = [ "kvm-amd" ];
boot.initrd.kernelModules = [ "amdgpu" ];
fileSystems."/drive2" =
{
device = "/dev/disk/by-label/DRIVE2";
fsType = "ext4";
options = [
"noatime"
"nodiratime"
"discard"
];
};
virtualisation.virtualbox.host.enable = true;
# enable hardware acceleration and rocm
hardware.xone.enable = true;
hardware.graphics.extraPackages = with pkgs; [
libvdpau-va-gl
vaapiVdpau
rocmPackages.clr.icd
rocm-opencl-runtime
];
hardware.graphics = {
enable = true;
enable32Bit = lib.mkDefault true;
};
networking.firewall = {
allowedTCPPortRanges = [
{ from = 1714; to = 1764; } # KDE Connect
];
allowedUDPPortRanges = [
{ from = 1714; to = 1764; } # KDE Connect
];
};
}

View file

@ -11,11 +11,11 @@
# Utility functions for zoxide.
#
export NIX_PATH="$NIX_PATH:$HOME/gits/dotFiles/nix/."
export NIX_PATH="$NIX_PATH:$HOME/gits/dotFiles/."
set EDITOR "neovide --no-fork"
alias rebuild='sudo nixos-rebuild switch --flake /home/${config.conf.username}/gits/dotFiles/nix/.'
alias rebuild='sudo nixos-rebuild switch --flake /home/${config.conf.username}/gits/dotFiles/.'
abbr --add ls 'lsd'
abbr --add :q 'exit'
abbr --add gh 'git push origin'

View file

@ -5,7 +5,6 @@
home.packages = with pkgs; [
keepassxc
nheko
kdeconnect
nextcloud-client
xournalpp
];