refactor(treewide)

This commit is contained in:
ooks-io 2024-06-11 22:37:17 +12:00
parent 25d48ac2ac
commit c4fc882042
99 changed files with 634 additions and 477 deletions

8
nixos/default.nix Normal file
View file

@ -0,0 +1,8 @@
{
imports = [
./modules
./options
./profiles
./roles
];
}

View file

@ -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";
};
};
}

View file

@ -1,8 +0,0 @@
{
imports = [
./system76Scheduler.nix
./dbus.nix
./gnome.nix
./gvfs.nix
];
}

View file

@ -0,0 +1,9 @@
{
imports = [
./base
./gaming
./host
./programs
./services
];
}

View file

@ -0,0 +1,8 @@
{
imports = [
./steam.nix
./gamemode.nix
./gamescope.nix
./openPorts.nix
];
}

View file

@ -0,0 +1,24 @@
{ lib, config, pkgs, ... }:
let
inherit (lib) mkIf;
cfg = config.ooknet.gaming.gamemode;
in
{
config = mkIf cfg.enable {
programs.gamemode = {
enable = true;
settings = {
general = {
renice = 15;
softrealtime = "auto";
};
custom = {
start = "${pkgs.libnotify}/bin/notify-send 'GameMode started'";
end = "${pkgs.libnotify}/bin/notify-send 'GameMode ended'";
};
};
};
};
}

View file

@ -0,0 +1,16 @@
{ lib, config, pkgs, ... }:
let
inherit (lib) mkIf;
cfg = config.ooknet.gaming.gamescope;
in
{
config = mkIf cfg.enable {
hardware.opengl.extraPackages = [ pkgs.gamescope ];
programs.gamescope = {
enable = true;
capSysNice = true;
};
};
}

View file

@ -0,0 +1,22 @@
{ lib, config, ... }:
let
inherit (lib) mkIf;
cfg = config.ooknet.gaming.openPorts;
in
{
config = mkIf cfg.enable {
networking.firewall = {
allowedTCPPorts = [ 3074 ];
allowedUDPPorts = [
88
500
3074
2075
3544
4500
];
};
};
}

View file

@ -0,0 +1,35 @@
{ lib, config, pkgs, ... }:
let
inherit (lib) mkIf;
cfg = config.ooknet.gaming.steam;
steamFix = pkgs.steam.override {
extraPkgs = pkgs: with pkgs; [
xorg.libXcursor
xorg.libXi
xorg.libXinerama
xorg.libXScrnSaver
libpng
libpulseaudio
libvorbis
stdenv.cc.cc.lib
libkrb5
keyutils
mangohud
winetricks
protontricks
gtk3
gtk3-x11
];
};
in
{
config = mkIf cfg.enable {
programs.steam = {
enable = true;
package = steamFix;
extraCompatPackages = [ pkgs.proton-ge-bin.steamcompattool ];
};
};
}

View file

@ -2,8 +2,6 @@
imports = [
./admin.nix
./name.nix
./type.nix
./role.nix
./hardware
];
}

View file

@ -4,6 +4,5 @@
./gpu
./features
./common.nix
./monitors.nix
];
}

View file

@ -2,16 +2,17 @@
let
inherit (lib) mkIf;
host = config.ooknet.host;
admin = config.ooknet.host.admin;
cfg = config.ooknet.programs._1password;
in
{
config = mkIf (host.type != "phone") {
config = mkIf cfg.enable {
programs = {
_1password.enable = true;
_1password-gui = {
enable = true;
polkitPolicyOwners = [ "${host.admin.name}" ];
polkitPolicyOwners = [ "${admin.name}" ];
};
};
};

View file

@ -0,0 +1,12 @@
{ lib, config, ... }:
let
inherit (lib) mkIf;
cfg = config.ooknet.programs.dconf;
in
{
config = mkIf cfg.enable {
programs.dconf.enable = true;
};
}

View file

@ -0,0 +1,14 @@
{ lib, config, ... }:
let
inherit (lib) mkIf;
cfg = config.ooknet.programs.kdeconnect;
in
{
config = mkIf cfg.enable {
programs.kdeconnect = {
enable = true;
};
};
}

View file

@ -1,69 +0,0 @@
{ lib, config, pkgs, ... }:
let
inherit (lib) mkIf;
inherit (builtins) elem;
steamFix = pkgs.steam.override {
extraPkgs = pkgs: with pkgs; [
xorg.libXcursor
xorg.libXi
xorg.libXinerama
xorg.libXScrnSaver
libpng
libpulseaudio
libvorbis
stdenv.cc.cc.lib
libkrb5
keyutils
mangohud
winetricks
protontricks
gtk3
gtk3-x11
];
};
host = config.ooknet.host;
in
{
config = mkIf (elem "gaming" host.function) {
hardware.opengl.extraPackages = [ pkgs.gamescope ];
services.flatpak.enable = true;
programs = {
steam = {
enable = true;
package = steamFix;
extraCompatPackages = [ pkgs.proton-ge-bin.steamcompattool ];
};
gamescope = {
enable = true;
capSysNice = true;
};
gamemode = {
enable = true;
settings = {
general = {
renice = 15;
softrealtime = "auto";
};
custom = {
start = "${pkgs.libnotify}/bin/notify-send 'GameMode started'";
end = "${pkgs.libnotify}/bin/notify-send 'GameMode ended'";
};
};
};
};
networking.firewall = {
allowedTCPPorts = [ 3074 ];
allowedUDPPorts = [
88
500
3074
2075
3544
4500
];
};
};
}

View file

@ -1,5 +0,0 @@
{
imports = [
./services
];
}

View file

@ -1,5 +0,0 @@
{
imports = [
./nixarr.nix
];
}

View file

@ -1,25 +0,0 @@
{ config, inputs, ... }:
let
admin = config.ooknet.host.admin;
in
{
imports = [ inputs.nixarr.nixosModules.default ];
nixarr = {
enable = true;
mediaDir = "/jellyfin";
stateDir = "/var/lib/nixarr";
mediaUsers = ["${admin.name}"];
jellyfin.enable = true;
sonarr.enable = true;
radarr.enable = true;
prowlarr.enable = true;
transmission.enable = true;
};
fileSystems."/jellyfin" = {
device = "/dev/disk/by-label/jellyfin";
fsType = "btrfs";
};
}

View file

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

View file

@ -1,13 +0,0 @@
{ lib, config, ... }:
let
inherit (lib) mkIf;
inherit (builtins) elem;
host = config.ooknet.host;
in
{
config = mkIf (elem "workstation" host.function){
programs.dconf.enable = true;
};
}

View file

@ -1,7 +0,0 @@
{ ... }:
{
programs.kdeconnect = {
enable = true;
};
}

View file

@ -2,12 +2,11 @@
let
inherit (lib) mkIf;
inherit (lib.lists) any elem;
hasFunction = f: elem f config.ooknet.host.function;
cfg = config.ooknet.services.dbus;
in
{
config = mkIf (any hasFunction ["workstation" "gaming"]) {
config = mkIf cfg.enable {
services.dbus = {
enable = true;
packages = with pkgs; [ dconf gcr udisks2 ];

View file

@ -0,0 +1,10 @@
{
imports = [
./system76Scheduler.nix
./dbus.nix
./gnome.nix
./gvfs.nix
# ./nixarr.nix
./flatpak.nix
];
}

View file

@ -0,0 +1,12 @@
{ lib, config, ... }:
let
inherit (lib) mkIf;
cfg = config.ooknet.services.flatpak;
in
{
config = mkIf cfg.enable {
services.flatpak.enable = true;
};
}

View file

@ -2,11 +2,11 @@
let
inherit (lib) mkIf;
host = config.ooknet.host;
cfg = config.ooknet.services.gnomeServices;
in
{
config = mkIf (host.type != "phone" && host.type != "server") {
config = mkIf cfg.enable {
services = {
gnome = {
glib-networking.enable = true;

View file

@ -2,11 +2,11 @@
let
inherit (lib) mkIf;
host = config.ooknet.host;
cfg = config.ooknet.services.gvfs;
in
{
config = mkIf ( host.type != "phone") {
config = mkIf cfg.enable {
services.gvfs.enable = true;
};
}

View file

@ -0,0 +1,29 @@
{ config, inputs, lib, ... }:
let
inherit (lib) mkIf;
admin = config.ooknet.host.admin;
cfg = config.ooknet.services.nixarr;
in
{
imports = [ inputs.nixarr.nixosModules.default ];
config = mkIf cfg.enable {
nixarr = {
enable = true;
mediaDir = "/jellyfin";
stateDir = "/var/lib/nixarr";
mediaUsers = ["${admin.name}"];
jellyfin.enable = true;
sonarr.enable = true;
radarr.enable = true;
prowlarr.enable = true;
transmission.enable = true;
};
fileSystems."/jellyfin" = {
device = "/dev/disk/by-label/jellyfin";
fsType = "btrfs";
};
};
}

View file

@ -2,12 +2,11 @@
let
inherit (lib) mkIf;
host = config.ooknet.host;
cfg = config.ooknet.services.system76Scheduler;
in
{
config = mkIf (host.type != "phone") {
config = mkIf cfg.enable {
services.system76-scheduler = {
enable = true;
};

View file

@ -0,0 +1,8 @@
{
imports = [
./gaming.nix
./host.nix
./programs.nix
./services.nix
];
}

14
nixos/options/gaming.nix Normal file
View file

@ -0,0 +1,14 @@
{ lib, ... }:
let
inherit (lib) mkEnableOption;
in
{
options.ooknet.gaming = {
steam.enable = mkEnableOption "";
gamescope.enable = mkEnableOption "";
gamemode.enable = mkEnableOption "";
openPorts.enable = mkEnableOption "";
};
}

View file

@ -24,7 +24,7 @@ in
};
profiles = mkOption {
type = listOf (enum ["gaming" "creativity" "media-server"]);
type = listOf (enum ["gaming" "creative" "productivity" "media-server"]);
default = [];
};

View file

@ -0,0 +1,13 @@
{ lib, ... }:
let
inherit (lib) mkEnableOption;
in
{
options.ooknet.programs = {
_1password.enable = mkEnableOption "";
dconf.enable = mkEnableOption "";
kdeconnect.enable = mkEnableOption "";
};
}

View file

@ -0,0 +1,16 @@
{ lib, ... }:
let
inherit (lib) mkEnableOption;
in
{
options.ooknet.services = {
nixarr.enable = mkEnableOption "";
gnomeServices.enable = mkEnableOption "";
gvfs.enable = mkEnableOption "";
dbus.enable = mkEnableOption "";
system76Scheduler.enable = mkEnableOption "";
flatpak.enable = mkEnableOption "";
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./gaming.nix
./media-server.nix
];
}

18
nixos/profiles/gaming.nix Normal file
View file

@ -0,0 +1,18 @@
{ lib, config, ... }:
let
inherit (lib) mkIf;
inherit (builtins) elem;
profiles = config.ooknet.host.profiles;
in
{
config = mkIf (elem "gaming" profiles) {
ooknet.gaming = {
steam.enable = true;
gamescope.enable = true;
gamemode.enable = true;
};
ooknet.services.flatpak.enable = true;
};
}

View file

@ -0,0 +1,13 @@
{ lib, config, ... }:
let
inherit (lib) mkIf;
inherit (builtins) elem;
profiles = config.ooknet.host.profiles;
in
{
config = mkIf (elem "media-server" profiles) {
ooknet.services.nixarr.enable = true;
};
}

5
nixos/roles/default.nix Normal file
View file

@ -0,0 +1,5 @@
{
imports = [
./desktop-workstation.nix
];
}

View file

@ -0,0 +1,24 @@
{ lib, config, ... }:
let
inherit (lib) mkIf;
host = config.ooknet.host;
in
{
config = mkIf (host.type == "desktop" && host.role == "workstation") {
ooknet = {
services = {
gnomeServices.enable = true;
gvfs.enable = true;
dbus.enable = true;
system76Scheduler.enable = true;
};
programs = {
_1password.enable = true;
dconf.enable = true;
kdeconnect.enable = true;
};
};
};
}