refactor(treewide): cleanup

This commit is contained in:
ooks-io 2024-04-30 20:20:35 +12:00
parent 2fe6c44941
commit 2d93503bbc
30 changed files with 76 additions and 273 deletions

View file

@ -1,21 +1,30 @@
{ config, inputs, pkgs, ... }: { lib, config, inputs, pkgs, ... }:
let
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBn3ff3HaZHIyH4K13k8Mwqu/o7jIABJ8rANK+r2PfJk";
in
{ {
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
../../profiles ../../modules
]; ];
activeProfiles = ["base" "gaming"]; systemModules.host = {
name = "ooksdesk";
systemModules.user = { type = "desktop";
ooks.enable = true; function = [ "workstation" "gaming" ];
admin = {
name = "ooks";
shell = "fish"; shell = "fish";
sshKey = key;
}; };
hardware = {
systemModules.hardware = {
cpu.type = "amd"; cpu.type = "amd";
cpu.amd.pstate.enable = true;
gpu.type = "amd"; gpu.type = "amd";
features = [ "ssd" ];
};
}; };
systemModules.networking.tailscale = { systemModules.networking.tailscale = {
@ -23,11 +32,9 @@
client = true; client = true;
}; };
networking = {
hostName = "ooksdesk";
# useDHCP = true;
};
boot = { boot = {
kernelPackages = pkgs.linuxPackages_xanmod_latest; kernelPackages = pkgs.linuxPackages_xanmod_latest;
}; };
system.stateVersion = lib.mkDefault "23.11";
} }

View file

@ -2,36 +2,26 @@
{ {
imports = [ imports = [
./hardware ./gaming
./shell
./bootloader ./bootloader
./nix ./nix
./programs ./programs
./user
./displayManager ./displayManager
./networking ./networking
./locale ./locale
./virtualisation ./virtualization
./security ./security
./services ./services
./audio ./audio
./meta
./host ./host
./video ./video
]; ];
options.systemModules = { options.systemModules = {
pipewire = {
enable = lib.mkEnableOption "Enable pipewire module";
};
networking = {
enable = lib.mkEnableOption "Enable networking module";
};
virtualisation = { virtualisation = {
enable = lib.mkEnableOption "Enable virtualisation module"; enable = lib.mkEnableOption "Enable virtualisation module";
}; };
locale = {
enable = lib.mkEnableOption "Enable locale module";
};
}; };
} }

View file

@ -1,7 +1,8 @@
{ lib, config, pkgs, inputs, ... }: { lib, config, pkgs, ... }:
let let
cfg = config.systemProfile.gaming; inherit (lib) mkIf;
inherit (builtins) elem;
steamFix = pkgs.steam.override { steamFix = pkgs.steam.override {
extraPkgs = pkgs: with pkgs; [ extraPkgs = pkgs: with pkgs; [
xorg.libXcursor xorg.libXcursor
@ -21,10 +22,11 @@ let
gtk3-x11 gtk3-x11
]; ];
}; };
host = config.systemModules.host;
in in
{ {
config = lib.mkIf cfg.enable { config = mkIf (elem "gamiing" host.function) {
hardware.opengl.extraPackages = [ pkgs.gamescope ]; hardware.opengl.extraPackages = [ pkgs.gamescope ];
programs = { programs = {
steam = { steam = {
@ -63,3 +65,4 @@ in
}; };
}; };
} }

View file

@ -36,7 +36,7 @@ in
isNormalUser = true; isNormalUser = true;
shell = pkgs.${cfg.shell}; shell = pkgs.${cfg.shell};
initialPassword = "password"; initialPassword = "password";
openssh.authorizedKeys = "${cfg.sshKey}"; openssh.authorizedKeys.keys = [ "${cfg.sshKey}" ];
extraGroups = [ extraGroups = [
"wheel" "wheel"
"video" "video"

View file

@ -4,5 +4,6 @@
./name ./name
./type ./type
./function ./function
./hardware
]; ];
} }

View file

@ -5,12 +5,6 @@ let
in in
{ {
imports = [
./gaming
./workstation
./media-server
];
options.systemModules.host.function = mkOption { options.systemModules.host.function = mkOption {
type = with types; listOf (enum ["gaming" "workstation" "media-server"]); type = with types; listOf (enum ["gaming" "workstation" "media-server"]);
default = []; default = [];

View file

@ -2,19 +2,18 @@
let let
inherit (lib) mkMerge mkEnableOption mkIf versionAtLeast versionOlder; inherit (lib) mkMerge mkEnableOption mkIf versionAtLeast versionOlder;
hardware = config.systemModules.host.hardware.cpu; inherit (builtins) elem;
cfg = hardware.amd; cpu = config.systemModules.host.hardware.cpu;
kernelVersion = config.kernelPackages.kernel.version; cfg = cpu.amd;
kernelVersion = config.boot.kernelPackages.kernel.version;
kernelVersionAtLeast = versionAtLeast kernelVersion; kernelVersionAtLeast = versionAtLeast kernelVersion;
kernelVersionOlder= versionOlder kernelVersion; kernelVersionOlder= versionOlder kernelVersion;
in in
{ {
options.systemModules.host.hardware.cpu.amd = { options.systemModules.host.hardware.cpu.amd.pstate.enable = mkEnableOption "Enable amd pstate module";
pstate.enable = mkEnableOption "Enable pstate amd module";
};
config = mkIf (builtins.elem hardware.type ["amd"]) { config = mkIf (elem cpu.type ["amd"]) {
environment.systemPackages = [pkgs.amdctl]; environment.systemPackages = [pkgs.amdctl];
hardware.cpu.amd.updateMicrocode = true; hardware.cpu.amd.updateMicrocode = true;
boot = mkMerge [ boot = mkMerge [

View file

@ -3,6 +3,6 @@
./cpu ./cpu
./gpu ./gpu
./features ./features
./ssd ./common
]; ];
} }

View file

@ -1,7 +1,7 @@
{ lib, config, ... }: { lib, config, ... }:
let let
features = config.systemModules.host.hardware.ssd; features = config.systemModules.host.hardware.features;
inherit (lib) mkIf; inherit (lib) mkIf;
inherit (builtins) elem; inherit (builtins) elem;
in in

View file

@ -15,7 +15,7 @@ in
}; };
config = { config = {
networking.hostname = cfg.name; networking.hostName = cfg.name;
environment.sessionVariables.HN = cfg.name; environment.sessionVariables.HN = cfg.name;
}; };
} }

View file

@ -2,7 +2,7 @@
let let
inherit (lib) mkIf; inherit (lib) mkIf;
host = config.systemModules.type; host = config.systemModules.host;
in in
{ {

View file

@ -1,7 +1,7 @@
{ config, lib, inputs, ... }: { config, lib, inputs, ... }:
let let
inherit (lib) mkIf; inherit (lib) mkIf mapAttrs mkDefault;
host = config.systemModules.host; host = config.systemModules.host;
in in
@ -10,13 +10,13 @@ in
nix = { nix = {
settings = { settings = {
trusted-users = [ "root" "@wheel" ]; trusted-users = [ "root" "@wheel" ];
auto-optimise-store = lib.mkDefault true; auto-optimise-store = mkDefault true;
experimental-features = [ "nix-command" "flakes" "repl-flake" ]; experimental-features = [ "nix-command" "flakes" "repl-flake" ];
warn-dirty = false; warn-dirty = false;
system-features = [ "kvm" "big-parallel" "nixos-test" ]; system-features = [ "kvm" "big-parallel" "nixos-test" ];
flake-registry = ""; flake-registry = "";
}; };
registry = lib.mapAttrs (_: value: { flake = value; }) inputs; registry = mapAttrs (_: value: { flake = value; }) inputs;
nixPath = [ "nixpkgs=${inputs.nixpkgs.outPath}" ]; nixPath = [ "nixpkgs=${inputs.nixpkgs.outPath}" ];
}; };
}; };

View file

@ -6,7 +6,7 @@ let
in in
{ {
config = mkIf host.type != "phone" { config = mkIf (host.type != "phone") {
nixpkgs = { nixpkgs = {
overlays = builtins.attrValues outputs.overlays; overlays = builtins.attrValues outputs.overlays;
config = { config = {

View file

@ -1,14 +1,13 @@
{ lib, config, ... }: { lib, config, ... }:
let let
inherit (lib) mkIf mkEnableOption; inherit (lib) mkIf;
cfg = config.systemModules.programs.bandwhich; inherit (builtins) elem;
host = config.systemModules.host;
in in
{ {
options.systemModules.programs.bandwhich.enable = mkEnableOption "Enable bandwhich system module"; config = mkIf (elem "workstation" host.function) {
config = mkIf cfg.enable {
programs.bandwhich.enable = true; programs.bandwhich.enable = true;
}; };
} }

View file

@ -1,14 +1,13 @@
{ lib, config, ... }: { lib, config, ... }:
let let
inherit (lib) mkIf mkEnableOption; inherit (lib) mkIf;
cfg = config.systemModules.programs.dconf; inherit (builtins) elem;
host = config.systemModules.host;
in in
{ {
options.systemModules.programs.dconf.enable = mkEnableOption "Enable dconf system module"; config = mkIf (elem "workstation" host.function){
config = mkIf cfg.enable {
programs.dconf.enable = true; programs.dconf.enable = true;
}; };
} }

View file

@ -1,14 +1,9 @@
{ lib, ... }:
{ {
imports = [ imports = [
./gnomeServices.nix
./dconf ./dconf
./kdeconnect
./seahorse
./wireshark
./bandwhich
]; ];
options.systemModules.programs = {
gnomeServices = {
enable = lib.mkEnableOption "Enable gnome services module";
};
};
} }

View file

@ -1,18 +0,0 @@
{ config, lib, pkgs, ... }:
let
cfg = config.systemModules.programs.gnomeServices;
in
{
config = lib.mkIf cfg.enable {
services = {
dbus.packages = with pkgs; [
gcr
gnome.gnome-settings-daemon
];
gnome.gnome-keyring.enable = true;
gvfs.enable = true;
};
};
}

View file

@ -9,9 +9,8 @@ in
options.systemModules.services.kdeconnect.enable = mkEnableOption "Enable kdeconnect system module"; options.systemModules.services.kdeconnect.enable = mkEnableOption "Enable kdeconnect system module";
config = mkIf cfg.enable { config = mkIf cfg.enable {
services.kdeconnect = { programs.kdeconnect = {
enable = true; enable = true;
indicator = true;
}; };
}; };
} }

View file

@ -1,14 +1,13 @@
{ lib, config, ... }: { lib, config, ... }:
let let
inherit (lib) mkIf mkEnableOption; inherit (lib) mkIf;
cfg = config.systemModules.programs.seahorse; inherit (builtins) elem;
host = config.systemModules.host;
in in
{ {
options.systemModules.programs.seahorse.enable = mkEnableOption "Enable seahorse system module"; config = mkIf (elem "workstation" host.function) {
config = mkIf cfg.enable {
programs.seahorse.enable = true; programs.seahorse.enable = true;
}; };
} }

View file

@ -1,14 +1,13 @@
{ lib, config, ... }: { lib, config, ... }:
let let
inherit (lib) mkIf mkEnableOption; inherit (lib) mkIf;
cfg = config.systemModules.programs.wireshark; inherit (builtins) elem;
host = config.systemModules.host;
in in
{ {
options.systemModules.programs.wireshark.enable = mkEnableOption "Enable wireshark system module"; config = mkIf (elem "workstation" host.function) {
config = mkIf cfg.enable {
programs.wireshark.enable = true; programs.wireshark.enable = true;
}; };
} }

View file

@ -1,5 +1,5 @@
{ {
import = [ imports = [
./1password ./1password
./kernel ./kernel
./pam ./pam

View file

@ -5,7 +5,6 @@
./mediaServer ./mediaServer
./system76Scheduler ./system76Scheduler
./dbus ./dbus
./kdeconnect
./gnome ./gnome
./gvfs ./gvfs
]; ];

View file

@ -7,6 +7,6 @@ in
{ {
config = mkIf ( host.type != "phone") { config = mkIf ( host.type != "phone") {
services.gvfs = true; services.gvfs.enable = true;
}; };
} }

View file

@ -8,7 +8,7 @@ in
{ {
options.systemModules.zsh.enable = mkEnableOption "Enable zsh module"; options.systemModules.shell.zsh.enable = mkEnableOption "Enable zsh module";
config = mkIf (adminShell == "zsh" || cfg.enable) { config = mkIf (adminShell == "zsh" || cfg.enable) {
programs.zsh = { programs.zsh = {

View file

@ -1,14 +0,0 @@
{ lib, ... }:
{
imports = [
./shell
./ooks.nix
];
options.systemModules.user = {
ooks = {
enable = lib.mkEnableOption "Enable the user ooks";
};
};
}

View file

@ -1,30 +0,0 @@
{ lib, pkgs, config, ... }:
let
ifTheyExist = groups: builtins.filter (group: builtins.hasAttr group config.users.groups) groups;
cfg = config.systemModules.user.ooks;
in
{
config = lib.mkIf cfg.enable {
users.users.ooks = {
isNormalUser = true;
extraGroups = [
"wheel"
"video"
"audio"
] ++ ifTheyExist [
"git"
"media"
"network"
"libvirtd"
"deluge"
"streamer"
"torrenter"
];
packages = [ pkgs.home-manager ];
};
home-manager.users.ooks = import ../../../home/user/ooks/${config.networking.hostName};
};
}

View file

@ -1,69 +0,0 @@
{ inputs, outputs, lib, config, pkgs, ... }:
let
isx86Linux = pkgs: with pkgs.stdenv; hostPlatform.isLinux && hostPlatform.isx86;
cfg = config.systemProfile.base;
in
{
imports = [
../../modules
inputs.home-manager.nixosModules.home-manager
];
config = lib.mkIf cfg.enable {
systemModules = {
security.enable = true;
nixOptions.enable = true;
pipewire.enable = true;
networking = {
enable = true;
firewall = true;
resolved = true;
ssh = true;
tools = true;
hardenTcp = true;
};
locale.enable = true;
bootloader.systemd.enable = true;
programs.gnomeServices.enable = true;
displayManager.tuigreet.enable = true;
hardware.ssd.enable = true;
services.system76Scheduler.enable = true;
};
environment.systemPackages = [pkgs.git];
environment.enableAllTerminfo = true;
services = {
dbus.enable = true; # Need this for gtk
printing.enable = true; # Do I even print?
udisks2 = { # Used to manage mount of temp storage
enable = true;
mountOnMedia = true; # Auto mounts device to /media
};
};
boot.supportedFilesystems = ["ntfs"]; # For when someone hands me a usb
programs = {
dconf.enable = true;
kdeconnect.enable = true;
};
home-manager.extraSpecialArgs = { inherit inputs outputs; };
hardware = {
enableAllFirmware = true;
enableRedistributableFirmware = true;
opengl = {
enable = true;
driSupport = true;
driSupport32Bit = isx86Linux pkgs;
};
};
system.stateVersion = lib.mkDefault "23.11";
};
}

View file

@ -1,32 +0,0 @@
{ lib, config, ... }:
let
profileEnabler = let
reducer = l: r: {"${r}".enable = true;} // l;
in
builtins.foldl' reducer {} config.activeProfiles;
in
{
imports = [
./base
./gaming
];
options = {
activeProfiles = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
};
systemProfile = {
base = {
enable = lib.mkEnableOption "Enable the base profile";
};
gaming = {
enable = lib.mkEnableOption "Enable the gaming profile";
};
};
};
config.systemProfile = profileEnabler;
}

View file

@ -1,17 +0,0 @@
{ config, lib, ... }:
let
cfg = config.systemProfile.mediaServer;
in
{
imports = [
../../modules
];
config = lib.mkIf cfg.enable {
systemModules = {
services = {
nixarr.enable = true;
};
};
};
}