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, ... }:
{ config, inputs, pkgs, ... }:
# Imports
# -------------------------------------------------------------------------------------------------
let
inherit (lib) mkDefault;
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBn3ff3HaZHIyH4K13k8Mwqu/o7jIABJ8rANK+r2PfJk";
in
{
imports = [
inputs.hardware.nixosModules.common-pc-ssd
inputs.hardware.nixosModules.common-cpu-intel
inputs.hardware.nixosModules.common-gpu-intel
./hardware-configuration.nix
../common/user/ooks
../common/base
../common/features/bluetooth.nix
../common/features/greetd.nix
];
];
# Hostname and networking
# -------------------------------------------------------------------------------------------------
networking = {
hostName = "ooksx1";
networkmanager.enable = true;
ooknet.host = {
name = "ooksx1";
type = "laptop";
role = "workstation";
profiles = [ "console-tools" ];
admin = {
name = "ooks";
shell = "fish";
sshKey = key;
homeManager = true;
};
# Printing
# -------------------------------------------------------------------------------------------------
services.printing.enable = true;
# Kernel
# ------------------------------------------------------------------------------------------------
hardware = {
cpu.type = "intel";
gpu.type = "intel";
features = [
"bluetooth"
"backlight"
"battery"
"ssd"
"audio"
"video"
];
battery = {
powersave = {
minFreq = 800;
maxFreq = 1800;
};
performance = {
minFreq = 1800;
maxFreq = 3600;
};
};
};
};
boot = {
kernelPackages = pkgs.linuxKernel.packages.linux_zen;
};
# 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";
};
system.stateVersion = mkDefault "23.11";
}

View file

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

View file

@ -12,17 +12,20 @@ in
ooknet.host = {
name = "ooksmedia";
type = "desktop";
function = [
"workstation"
"gaming"
"media-server"
];
role = "workstation";
profiles = [ "media-server" "console-tools" ];
admin = {
name = "ooks";
shell = "fish";
sshKey = key;
homeManager = true;
};
networking = {
tailscale = {
enable = true;
server = true;
};
};
hardware = {
cpu.type = "intel";
cpu.amd.pstate.enable = true;
@ -34,12 +37,6 @@ in
];
};
};
ooknet.networking.tailscale = {
enable = true;
server = true;
};
boot = {
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 = [
./hardware-configuration.nix
../../profiles
];
];
activeProfiles = ["base" "laptop"];
ooknet.user = {
ooks.enable = true;
shell.fish.enable = true;
ooknet.host = {
name = "ooksmicro";
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 = {
hostName = "ooksmicro";
tailscale = {
enable = true;
client = true;
};
};
boot = {
kernelPackages = pkgs.linuxKernel.packages.linux_zen;
# need this due to
kernelParams = [ "fbcon=rotate:1" ];
# required for keyboard to work during boot
initrd.availableKernelModules = [ "battery" ];
};
hardware = {
cpu.type = "intel";
gpu.type = "intel";
features = [
"bluetooth"
"backlight"
"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 = {
name = "ookst480s";
type = "laptop";
function = [ "workstation" ];
admin = {
name = "ooks";
shell = "fish";
sshKey = key;
homeManager = true;
ooknet.host = {
name = "ookst480s";
type = "laptop";
role = "workstation";
profiles = [ "console-tools" ];
admin = {
name = "ooks";
shell = "fish";
sshKey = key;
homeManager = true;
};
networking = {
tailscale = {
enable = true;
client = true;
};
hardware = {
cpu.type = "intel";
gpu.type = "intel";
features = [
"bluetooth"
"backlight"
"battery"
"ssd"
"audio"
"video"
];
battery = {
powersave = {
minFreq = 800;
maxFreq = 1800;
};
performance = {
minFreq = 1800;
maxFreq = 3600;
};
};
hardware = {
cpu.type = "intel";
gpu.type = "intel";
features = [
"bluetooth"
"backlight"
"battery"
"ssd"
"audio"
"video"
];
monitors = [{
name = "eDP-1";
width = 1920;
height = 1080;
workspace = "1";
primary = true;
}];
battery = {
powersave = {
minFreq = 800;
maxFreq = 1800;
};
performance = {
minFreq = 1800;
maxFreq = 3600;
};
};
};
};
boot = {
kernelPackages = pkgs.linuxKernel.packages.linux_zen;
};
boot = {
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, ... }:
let
cfg = config.ooknet.networking.tailscale;
cfg = config.ooknet.host.networking.tailscale;
inherit (config.services) tailscale;
inherit (lib.lists) optionals;
inherit (lib.types) bool listOf str;
inherit (lib.strings) concatStringsSep;
inherit (lib) mkIf mkEnableOption mkOption mkDefault;
inherit (lib) mkIf mkDefault;
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 {
services.tailscale = {

View file

@ -3,7 +3,9 @@
let
inherit (lib) mkOption mkEnableOption;
inherit (lib.types) bool enum listOf int submodule nullOr str;
admin = config.ooknet.host.admin;
hardware = config.ooknet.host.hardware;
tailscale = config.ooknet.host.networking.tailscale;
in
{
@ -24,7 +26,7 @@ in
};
profiles = mkOption {
type = listOf (enum ["gaming" "creative" "productivity" "media-server"]);
type = listOf (enum ["gaming" "creative" "productivity" "console-tools" "media-server"]);
default = [];
};
@ -52,6 +54,35 @@ in
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 = {
gpu = {
type = mkOption {