Modularize hardware config and remove specific nix folder
This commit is contained in:
parent
a5042bb645
commit
9ac5b25036
72 changed files with 322 additions and 100 deletions
212
modules/conf.nix
Normal file
212
modules/conf.nix
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
{ lib, config, pkgs, options, ... }: {
|
||||
options.conf = {
|
||||
|
||||
system = lib.mkOption {
|
||||
default = "x86_64-linux";
|
||||
# no fisherprice unix support
|
||||
type = with lib.types; (enum [ "x86_64-linux" "aarch64-linux" "aarch64-linux-android" ]);
|
||||
example = "aarch64-linux";
|
||||
description = ''
|
||||
System architecture.
|
||||
'';
|
||||
};
|
||||
|
||||
cpu = lib.mkOption {
|
||||
# TODO: how to enable arm?
|
||||
default = "amd";
|
||||
type = with lib.types; (enum [ "amd" "intel" ]);
|
||||
example = "intel";
|
||||
description = ''
|
||||
cpu microcode.
|
||||
'';
|
||||
};
|
||||
|
||||
monitor = lib.mkOption {
|
||||
default = "";
|
||||
example = "eDP-1";
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
main monitor
|
||||
'';
|
||||
};
|
||||
|
||||
scale = lib.mkOption {
|
||||
default = "1.0";
|
||||
example = "1.0";
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
Scale for the monitor
|
||||
'';
|
||||
};
|
||||
|
||||
ironbar = {
|
||||
modules = lib.mkOption {
|
||||
default = [ ];
|
||||
example = [
|
||||
{ type = "upower"; class = "memory-usage"; }
|
||||
];
|
||||
type = with lib.types; listOf attrs;
|
||||
description = ''
|
||||
Adds modules to ironbar.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
boot_params = lib.mkOption {
|
||||
default = [ ];
|
||||
example = [ "resume=something" ];
|
||||
type = with lib.types; listOf str;
|
||||
description = ''
|
||||
Boot params
|
||||
'';
|
||||
};
|
||||
|
||||
gaming = {
|
||||
enable = lib.mkOption {
|
||||
default = false;
|
||||
example = true;
|
||||
type = lib.types.bool;
|
||||
description = ''
|
||||
Install gaming related programs such as steam, gamemode, and more
|
||||
'';
|
||||
};
|
||||
|
||||
device = lib.mkOption {
|
||||
default = 0;
|
||||
example = 0;
|
||||
type = lib.types.int;
|
||||
description = ''
|
||||
GPU device number
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
streamdeck = {
|
||||
enable = lib.mkOption {
|
||||
default = false;
|
||||
example = true;
|
||||
type = lib.types.bool;
|
||||
description = ''
|
||||
Install streamdeck configuration program.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
kernel = lib.mkOption {
|
||||
default = pkgs.linuxPackages_latest;
|
||||
example = pkgs.linuxPackages_xanmod_latest;
|
||||
type = with lib.types; nullOr attrs;
|
||||
description = ''
|
||||
kernel to be used
|
||||
'';
|
||||
};
|
||||
|
||||
hostname = lib.mkOption {
|
||||
default = "nixos";
|
||||
example = "spaceship";
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
The name of the system
|
||||
'';
|
||||
};
|
||||
|
||||
username = lib.mkOption {
|
||||
default = "dashie";
|
||||
example = "pingpang";
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
The username.
|
||||
'';
|
||||
};
|
||||
|
||||
hyprland = {
|
||||
monitor = lib.mkOption {
|
||||
default = [ ];
|
||||
example = [
|
||||
"DP-1,3440x1440@180,2560x0,1,vrr,1"
|
||||
];
|
||||
type = with lib.types; listOf str;
|
||||
description = ''
|
||||
The monitor configuration for hyprland.
|
||||
'';
|
||||
};
|
||||
workspace = lib.mkOption {
|
||||
default = [ ];
|
||||
example = [
|
||||
"2,monitor:DP-1, default:true"
|
||||
];
|
||||
type = with lib.types; listOf str;
|
||||
description = ''
|
||||
The workspace configuration for hyprland.
|
||||
'';
|
||||
};
|
||||
hyprpaper = lib.mkOption {
|
||||
default = '''';
|
||||
example = ''
|
||||
hyprpaper stuff
|
||||
'';
|
||||
type = lib.types.lines;
|
||||
description = ''
|
||||
hyprpaper
|
||||
'';
|
||||
};
|
||||
extra_autostart = lib.mkOption {
|
||||
default = [ ];
|
||||
example = [ "your application" ];
|
||||
type = lib.types.listOf lib.types.str;
|
||||
description = ''
|
||||
Extra exec_once.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
nvim-colorscheme = lib.mkOption {
|
||||
default = { tokyonight = { enable = true; }; };
|
||||
example = { catppuccin = { enable = true; }; };
|
||||
type = lib.types.attrs;
|
||||
description = ''
|
||||
nixvim colorscheme.
|
||||
'';
|
||||
};
|
||||
|
||||
colorscheme = lib.mkOption {
|
||||
default = {
|
||||
# custom tokyo night
|
||||
base00 = "1A1B26";
|
||||
# base01 = "16161E";
|
||||
# base01 = "15161e";
|
||||
base01 = "191a25";
|
||||
base02 = "2F3549";
|
||||
base03 = "444B6A";
|
||||
base04 = "787C99";
|
||||
base05 = "A9B1D6";
|
||||
base06 = "CBCCD1";
|
||||
base07 = "D5D6DB";
|
||||
base08 = "C0CAF5";
|
||||
base09 = "A9B1D6";
|
||||
base0A = "0DB9D7";
|
||||
base0B = "9ECE6A";
|
||||
base0C = "B4F9F8";
|
||||
# base0D = "2AC3DE";
|
||||
# base0D = "A9B1D6";
|
||||
# base0D = "62A0EA";
|
||||
# base0D = "779EF1";
|
||||
base0D = "366fea";
|
||||
base0E = "BB9AF7";
|
||||
base0F = "F7768E";
|
||||
};
|
||||
example = "catppuccin-mocha";
|
||||
type = with lib.types; oneOf [ str attrs path ];
|
||||
description = ''
|
||||
Base16 colorscheme.
|
||||
Can be an attribute set with base00 to base0F,
|
||||
a string that leads to a yaml file in base16-schemes path,
|
||||
or a path to a custom yaml file.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
conf.kernel = lib.mkIf config.conf.gaming.enable pkgs.linuxPackages_xanmod_latest;
|
||||
};
|
||||
}
|
||||
6
modules/default.nix
Normal file
6
modules/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./programs
|
||||
./conf.nix
|
||||
];
|
||||
}
|
||||
18
modules/programs/acpid.nix
Normal file
18
modules/programs/acpid.nix
Normal 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;
|
||||
});
|
||||
}
|
||||
|
||||
20
modules/programs/bluetooth.nix
Normal file
20
modules/programs/bluetooth.nix
Normal 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;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
11
modules/programs/default.nix
Normal file
11
modules/programs/default.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
imports = [
|
||||
./virtualbox.nix
|
||||
./kde_connect.nix
|
||||
./gpu.nix
|
||||
./xone.nix
|
||||
./drives.nix
|
||||
./bluetooth.nix
|
||||
./acpid.nix
|
||||
];
|
||||
}
|
||||
69
modules/programs/drives.nix
Normal file
69
modules/programs/drives.nix
Normal 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
63
modules/programs/gpu.nix
Normal 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);
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
30
modules/programs/kde_connect.nix
Normal file
30
modules/programs/kde_connect.nix
Normal 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
|
||||
];
|
||||
});
|
||||
}
|
||||
17
modules/programs/virtualbox.nix
Normal file
17
modules/programs/virtualbox.nix
Normal 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
17
modules/programs/xone.nix
Normal 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;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue