refactor(nixos:tailcale): move options --> ooknet.host.networking.tailscale

This commit is contained in:
ooks-io 2024-06-12 22:32:58 +12:00
parent fa926b9453
commit dd6271f7d6
7 changed files with 195 additions and 224 deletions

View file

@ -1,128 +1,54 @@
{ pkgs, lib, ... }:
let
inherit (lib) mkDefault;
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBn3ff3HaZHIyH4K13k8Mwqu/o7jIABJ8rANK+r2PfJk";
{ config, inputs, pkgs, ... }: in
# Imports
# -------------------------------------------------------------------------------------------------
{ {
imports = [ imports = [
inputs.hardware.nixosModules.common-pc-ssd
inputs.hardware.nixosModules.common-cpu-intel
inputs.hardware.nixosModules.common-gpu-intel
./hardware-configuration.nix ./hardware-configuration.nix
];
../common/user/ooks
../common/base
../common/features/bluetooth.nix
../common/features/greetd.nix
];
# Hostname and networking ooknet.host = {
# ------------------------------------------------------------------------------------------------- name = "ooksx1";
type = "laptop";
networking = { role = "workstation";
hostName = "ooksx1"; profiles = [ "console-tools" ];
networkmanager.enable = true; admin = {
name = "ooks";
shell = "fish";
sshKey = key;
homeManager = true;
}; };
hardware = {
cpu.type = "intel";
# Printing gpu.type = "intel";
# ------------------------------------------------------------------------------------------------- features = [
"bluetooth"
services.printing.enable = true; "backlight"
"battery"
# Kernel "ssd"
# ------------------------------------------------------------------------------------------------ "audio"
"video"
];
battery = {
powersave = {
minFreq = 800;
maxFreq = 1800;
};
performance = {
minFreq = 1800;
maxFreq = 3600;
};
};
};
};
boot = { boot = {
kernelPackages = pkgs.linuxKernel.packages.linux_zen; kernelPackages = pkgs.linuxKernel.packages.linux_zen;
}; };
system.stateVersion = mkDefault "23.11";
# Laptop Programs
# -------------------------------------------------------------------------------------------------
powerManagement.powertop.enable = true;
programs = {
light.enable = true;
dconf.enable = true;
kdeconnect.enable = true;
};
hardware = {
opengl = {
enable = true;
};
};
# gnupg
# -------------------------------------------------------------------------------------------------
programs.gnupg.agent = {
enable = true;
enableSSHSupport = true;
};
# Services
# -------------------------------------------------------------------------------------------------
services = {
logind = {
lidSwitch = "suspend";
};
dbus = {
enable = true;
packages = [ pkgs.gcr ];
};
auto-cpufreq = {
enable = true;
settings = {
battery = {
governor = "powersave";
turbo = "never";
};
charger = {
governor = "performance";
turbo = "auto";
};
};
};
};
systemd = {
user.services.polkit-gnome-authentication-agent-1 = {
description = "polkit-gnome-authentication-agent-1";
wantedBy = [ "graphical-session.target" ];
wants = [ "graphical-session.target" ];
after = [ "graphical-session.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1";
Restart = "on-failure";
RestartSec = 1;
TimeoutStopSec = 10;
};
};
};
# Firewall
# -------------------------------------------------------------------------------------------------
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# System Version
# -------------------------------------------------------------------------------------------------
system = {
stateVersion = "22.05";
};
} }

View file

@ -1,4 +1,4 @@
{ lib, config, inputs, pkgs, ... }: { lib, pkgs, ... }:
let let
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBn3ff3HaZHIyH4K13k8Mwqu/o7jIABJ8rANK+r2PfJk"; key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBn3ff3HaZHIyH4K13k8Mwqu/o7jIABJ8rANK+r2PfJk";
@ -13,13 +13,19 @@ in
name = "ooksdesk"; name = "ooksdesk";
type = "desktop"; type = "desktop";
role = "workstation"; role = "workstation";
profiles = [ "gaming" "creative" ]; profiles = [ "gaming" "creative" "console-tools" ];
admin = { admin = {
name = "ooks"; name = "ooks";
shell = "fish"; shell = "fish";
sshKey = key; sshKey = key;
homeManager = true; homeManager = true;
}; };
networking = {
tailscale = {
enable = true;
client = true;
};
};
hardware = { hardware = {
cpu.type = "amd"; cpu.type = "amd";
cpu.amd.pstate.enable = true; cpu.amd.pstate.enable = true;
@ -35,11 +41,6 @@ in
}]; }];
}; };
}; };
ooknet.networking.tailscale = {
enable = true;
client = true;
};
boot = { boot = {
kernelPackages = pkgs.linuxPackages_xanmod_latest; kernelPackages = pkgs.linuxPackages_xanmod_latest;

View file

@ -12,17 +12,20 @@ in
ooknet.host = { ooknet.host = {
name = "ooksmedia"; name = "ooksmedia";
type = "desktop"; type = "desktop";
function = [ role = "workstation";
"workstation" profiles = [ "media-server" "console-tools" ];
"gaming"
"media-server"
];
admin = { admin = {
name = "ooks"; name = "ooks";
shell = "fish"; shell = "fish";
sshKey = key; sshKey = key;
homeManager = true; homeManager = true;
}; };
networking = {
tailscale = {
enable = true;
server = true;
};
};
hardware = { hardware = {
cpu.type = "intel"; cpu.type = "intel";
cpu.amd.pstate.enable = true; cpu.amd.pstate.enable = true;
@ -34,12 +37,6 @@ in
]; ];
}; };
}; };
ooknet.networking.tailscale = {
enable = true;
server = true;
};
boot = { boot = {
kernelPackages = pkgs.linuxPackages_xanmod_latest; kernelPackages = pkgs.linuxPackages_xanmod_latest;
}; };

View file

@ -1,38 +1,68 @@
{ pkgs, ... }: { pkgs, lib, ... }:
let
inherit (lib) mkDefault;
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBn3ff3HaZHIyH4K13k8Mwqu/o7jIABJ8rANK+r2PfJk";
in
{ {
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
../../profiles ];
];
activeProfiles = ["base" "laptop"];
ooknet.user = { ooknet.host = {
ooks.enable = true; name = "ooksmicro";
shell.fish.enable = true; type = "micro";
role = "workstation";
profiles = [ "console-tools" ];
admin = {
name = "ooks";
shell = "fish";
sshKey = key;
homeManager = true;
}; };
ooknet.laptop.power = {
powersave = {
minFreq = 800;
maxFreq = 1600;
};
performance = {
minFreq = 1100;
maxFreq = 2600;
};
};
networking = { networking = {
hostName = "ooksmicro"; tailscale = {
enable = true;
client = true;
};
}; };
hardware = {
boot = { cpu.type = "intel";
kernelPackages = pkgs.linuxKernel.packages.linux_zen; gpu.type = "intel";
# need this due to features = [
kernelParams = [ "fbcon=rotate:1" ]; "bluetooth"
# required for keyboard to work during boot "backlight"
initrd.availableKernelModules = [ "battery" ]; "battery"
}; "ssd"
"audio"
"video"
];
battery = {
powersave = {
minFreq = 500;
maxFreq = 800;
};
performance = {
minFreq = 1200;
maxFreq = 2400;
};
};
};
monitors = [{
name = "DSI-1";
width = 720;
height = 1280;
workspace = "1";
primary = true;
transform = 3;
}];
};
boot = {
kernelPackages = pkgs.linuxKernel.packages.linux_zen;
};
system.stateVersion = mkDefault "23.11";
} }

View file

@ -11,43 +11,57 @@ in
]; ];
ooknet.host = { ooknet.host = {
name = "ookst480s"; name = "ookst480s";
type = "laptop"; type = "laptop";
function = [ "workstation" ]; role = "workstation";
admin = { profiles = [ "console-tools" ];
name = "ooks"; admin = {
shell = "fish"; name = "ooks";
sshKey = key; shell = "fish";
homeManager = true; sshKey = key;
homeManager = true;
};
networking = {
tailscale = {
enable = true;
client = true;
}; };
hardware = { };
cpu.type = "intel"; hardware = {
gpu.type = "intel"; cpu.type = "intel";
features = [ gpu.type = "intel";
"bluetooth" features = [
"backlight" "bluetooth"
"battery" "backlight"
"ssd" "battery"
"audio" "ssd"
"video" "audio"
]; "video"
battery = { ];
powersave = { monitors = [{
minFreq = 800; name = "eDP-1";
maxFreq = 1800; width = 1920;
}; height = 1080;
performance = { workspace = "1";
minFreq = 1800; primary = true;
maxFreq = 3600; }];
}; battery = {
powersave = {
minFreq = 800;
maxFreq = 1800;
};
performance = {
minFreq = 1800;
maxFreq = 3600;
}; };
}; };
}; };
};
boot = { boot = {
kernelPackages = pkgs.linuxKernel.packages.linux_zen; kernelPackages = pkgs.linuxKernel.packages.linux_zen;
}; };
system.stateVersion = mkDefault "23.11"; system.stateVersion = mkDefault "23.11";
} }

View file

@ -1,42 +1,14 @@
{ lib, config, pkgs, ... }: { lib, config, pkgs, ... }:
let let
cfg = config.ooknet.networking.tailscale; cfg = config.ooknet.host.networking.tailscale;
inherit (config.services) tailscale; inherit (config.services) tailscale;
inherit (lib.lists) optionals; inherit (lib.lists) optionals;
inherit (lib.types) bool listOf str;
inherit (lib.strings) concatStringsSep; inherit (lib.strings) concatStringsSep;
inherit (lib) mkIf mkEnableOption mkOption mkDefault; inherit (lib) mkIf mkDefault;
in in
{ {
options.ooknet.networking.tailscale = {
enable = mkEnableOption "Enable tailscale system module";
server = mkOption {
type = bool;
default = false;
description = "Define if the host is a server";
};
client = mkOption {
type = bool;
default = cfg.enable;
description = "Define if the host is a client";
};
tag = mkOption {
type = listOf str;
default =
if cfg.client then ["tag:client"]
else if cfg.server then ["tag:server"]
else [];
description = "Sets host tag depending on if server/client";
};
operator = mkOption {
type = str;
default = "ooks";
description = "Name of the tailscale operator";
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
services.tailscale = { services.tailscale = {

View file

@ -3,7 +3,9 @@
let let
inherit (lib) mkOption mkEnableOption; inherit (lib) mkOption mkEnableOption;
inherit (lib.types) bool enum listOf int submodule nullOr str; inherit (lib.types) bool enum listOf int submodule nullOr str;
admin = config.ooknet.host.admin;
hardware = config.ooknet.host.hardware; hardware = config.ooknet.host.hardware;
tailscale = config.ooknet.host.networking.tailscale;
in in
{ {
@ -24,7 +26,7 @@ in
}; };
profiles = mkOption { profiles = mkOption {
type = listOf (enum ["gaming" "creative" "productivity" "media-server"]); type = listOf (enum ["gaming" "creative" "productivity" "console-tools" "media-server"]);
default = []; default = [];
}; };
@ -52,6 +54,35 @@ in
homeManager = mkEnableOption ""; homeManager = mkEnableOption "";
}; };
networking = {
tailscale = {
enable = mkEnableOption "Enable tailscale system module";
server = mkOption {
type = bool;
default = false;
description = "Define if the host is a server";
};
client = mkOption {
type = bool;
default = tailscale.enable;
description = "Define if the host is a client";
};
tag = mkOption {
type = listOf str;
default =
if tailscale.client then ["tag:client"]
else if tailscale.server then ["tag:server"]
else [];
description = "Sets host tag depending on if server/client";
};
operator = mkOption {
type = str;
default = "${admin.name}";
description = "Name of the tailscale operator";
};
};
};
hardware = { hardware = {
gpu = { gpu = {
type = mkOption { type = mkOption {