finally system boots with new config
need to add all my stuff btw
This commit is contained in:
@@ -27,11 +27,6 @@
|
|||||||
../../desktops/hyprland
|
../../desktops/hyprland
|
||||||
];
|
];
|
||||||
|
|
||||||
boot.loader.systemd-boot.enable = true;
|
|
||||||
boot.loader.efi.canTouchEfiVariables = true;
|
|
||||||
|
|
||||||
networking.hostName = "nixos";
|
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
libsecret
|
libsecret
|
||||||
tree
|
tree
|
||||||
@@ -63,6 +58,7 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
programs.kdeconnect.enable = true;
|
programs.kdeconnect.enable = true;
|
||||||
|
|
||||||
services.keyd = {
|
services.keyd = {
|
||||||
enable = false;
|
enable = false;
|
||||||
keyboards.default = {
|
keyboards.default = {
|
||||||
@@ -74,6 +70,68 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
workstation = {
|
||||||
|
core = {
|
||||||
|
kernel = "latest";
|
||||||
|
allowUnfree = true;
|
||||||
|
ssh.permitRootLogin = true;
|
||||||
|
|
||||||
|
user = {
|
||||||
|
name = "river";
|
||||||
|
fullName = "Maaz Khokhar";
|
||||||
|
shell = "fish";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
networking = {
|
||||||
|
core = {
|
||||||
|
firewall = {
|
||||||
|
allowPing = true;
|
||||||
|
ports.tcp = [
|
||||||
|
22
|
||||||
|
80
|
||||||
|
5900
|
||||||
|
16570
|
||||||
|
18789
|
||||||
|
];
|
||||||
|
};
|
||||||
|
extraHosts = [
|
||||||
|
{
|
||||||
|
ip_address = "192.168.1.60";
|
||||||
|
hostname = "laptop";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
nameservers = [
|
||||||
|
"192.168.1.193"
|
||||||
|
"1.1.1.1"
|
||||||
|
"1.0.0.1"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
tailscale.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtualization = {
|
||||||
|
user = "river";
|
||||||
|
|
||||||
|
qemu = {
|
||||||
|
enable = true;
|
||||||
|
containers = true;
|
||||||
|
spiceUSBRedirection = true;
|
||||||
|
virtManager = true;
|
||||||
|
bootModules = [
|
||||||
|
"kvm-amd"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
podman = {
|
||||||
|
enable = true;
|
||||||
|
packages.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
lima.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
programs.nix-ld.libraries = with pkgs; [
|
programs.nix-ld.libraries = with pkgs; [
|
||||||
brotli
|
brotli
|
||||||
stdenv.cc.cc.lib
|
stdenv.cc.cc.lib
|
||||||
@@ -93,6 +151,4 @@
|
|||||||
enableAllFirmware = true;
|
enableAllFirmware = true;
|
||||||
enableRedistributableFirmware = true;
|
enableRedistributableFirmware = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
system.stateVersion = "25.11";
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/boot" =
|
fileSystems."/boot" =
|
||||||
{ device = "/dev/disk/by-uuid/7082-DAFE";
|
{ device = "/dev/disk/by-uuid/8750-9317";
|
||||||
fsType = "vfat";
|
fsType = "vfat";
|
||||||
options = [ "fmask=0077" "dmask=0077" ];
|
options = [ "fmask=0077" "dmask=0077" ];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
shared,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.workstation.core;
|
||||||
|
allowRootSSH = if cfg.ssh.permitRootLogin then "yes" else "no";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
networking.hostName = cfg.hostname;
|
||||||
|
|
||||||
|
boot = {
|
||||||
|
kernelPackages = shared.kernelOptions.${cfg.kernel};
|
||||||
|
loader = {
|
||||||
|
systemd-boot = {
|
||||||
|
enable = true;
|
||||||
|
editor = true;
|
||||||
|
};
|
||||||
|
efi.canTouchEfiVariables = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
time.timeZone = "America/Chicago";
|
||||||
|
|
||||||
|
programs.${cfg.user.shell}.enable = true;
|
||||||
|
|
||||||
|
users.users.${cfg.user.name} = with cfg.user; {
|
||||||
|
isNormalUser = true;
|
||||||
|
description = fullName;
|
||||||
|
extraGroups = [
|
||||||
|
"wheel"
|
||||||
|
"networkmanager"
|
||||||
|
"input"
|
||||||
|
];
|
||||||
|
|
||||||
|
shell = pkgs.${shell};
|
||||||
|
};
|
||||||
|
|
||||||
|
nixpkgs.config.allowUnfree = true;
|
||||||
|
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
gitFull
|
||||||
|
neovim
|
||||||
|
git-credential-manager
|
||||||
|
gnupg
|
||||||
|
];
|
||||||
|
|
||||||
|
nix = {
|
||||||
|
gc = {
|
||||||
|
automatic = true;
|
||||||
|
dates = "weekly";
|
||||||
|
options = "--delete-older-than 7d";
|
||||||
|
};
|
||||||
|
settings = {
|
||||||
|
trusted-users = [
|
||||||
|
"root"
|
||||||
|
cfg.user.name
|
||||||
|
];
|
||||||
|
experimental-features = [
|
||||||
|
"nix-command"
|
||||||
|
"flakes"
|
||||||
|
];
|
||||||
|
auto-optimise-store = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
programs.nix-ld.enable = true;
|
||||||
|
|
||||||
|
i18n = {
|
||||||
|
defaultLocale = "en_US.UTF-8";
|
||||||
|
|
||||||
|
extraLocaleSettings = {
|
||||||
|
LC_ADDRESS = "en_US.UTF-8";
|
||||||
|
LC_IDENTIFICATION = "en_US.UTF-8";
|
||||||
|
LC_MEASUREMENT = "en_US.UTF-8";
|
||||||
|
LC_MONETARY = "en_US.UTF-8";
|
||||||
|
LC_NAME = "en_US.UTF-8";
|
||||||
|
LC_NUMERIC = "en_US.UTF-8";
|
||||||
|
LC_PAPER = "en_US.UTF-8";
|
||||||
|
LC_TELEPHONE = "en_US.UTF-8";
|
||||||
|
LC_TIME = "en_US.UTF-8";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
security.rtkit.enable = true;
|
||||||
|
|
||||||
|
services = {
|
||||||
|
xserver.xkb = {
|
||||||
|
layout = "us";
|
||||||
|
variant = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
openssh = {
|
||||||
|
enable = true;
|
||||||
|
settings.PermitRootLogin = allowRootSSH;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
system.stateVersion = "26.11";
|
||||||
|
};
|
||||||
|
}
|
||||||
+7
-101
@@ -1,107 +1,13 @@
|
|||||||
{ pkgs, inputs, ... }:
|
{ pkgs, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
system = pkgs.stdenv.hostPlatform.system;
|
shared = import ./shared.nix { inherit pkgs; };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
boot.kernelPackages = pkgs.linuxPackages_latest;
|
imports = [
|
||||||
|
./options.nix
|
||||||
time.timeZone = "America/Chicago";
|
./config.nix
|
||||||
|
|
||||||
programs.fish.enable = true;
|
|
||||||
|
|
||||||
users.users.river = {
|
|
||||||
isNormalUser = true;
|
|
||||||
description = "Maaz Khokhar";
|
|
||||||
extraGroups = [
|
|
||||||
"wheel"
|
|
||||||
"networkmanager"
|
|
||||||
"input"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
shell = pkgs.fish;
|
_module.args.shared = shared;
|
||||||
};
|
|
||||||
|
|
||||||
nixpkgs.config.allowUnfree = true;
|
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
|
||||||
gitFull
|
|
||||||
neovim
|
|
||||||
btop
|
|
||||||
unzip
|
|
||||||
mpv
|
|
||||||
wl-clipboard
|
|
||||||
wireplumber
|
|
||||||
brightnessctl
|
|
||||||
pulseaudio
|
|
||||||
pavucontrol
|
|
||||||
ghostty
|
|
||||||
git-credential-manager
|
|
||||||
gnupg
|
|
||||||
yazi
|
|
||||||
jujutsu
|
|
||||||
glow
|
|
||||||
|
|
||||||
inputs.silicate.packages.${system}.default
|
|
||||||
inputs.herdr.packages.${system}.default
|
|
||||||
];
|
|
||||||
|
|
||||||
nix = {
|
|
||||||
gc = {
|
|
||||||
automatic = true;
|
|
||||||
dates = "weekly";
|
|
||||||
options = "--delete-older-than 7d";
|
|
||||||
};
|
|
||||||
settings = {
|
|
||||||
trusted-users = [
|
|
||||||
"root"
|
|
||||||
"river"
|
|
||||||
];
|
|
||||||
experimental-features = [
|
|
||||||
"nix-command"
|
|
||||||
"flakes"
|
|
||||||
];
|
|
||||||
auto-optimise-store = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
programs.nix-ld.enable = true;
|
|
||||||
|
|
||||||
i18n = {
|
|
||||||
defaultLocale = "en_US.UTF-8";
|
|
||||||
|
|
||||||
extraLocaleSettings = {
|
|
||||||
LC_ADDRESS = "en_US.UTF-8";
|
|
||||||
LC_IDENTIFICATION = "en_US.UTF-8";
|
|
||||||
LC_MEASUREMENT = "en_US.UTF-8";
|
|
||||||
LC_MONETARY = "en_US.UTF-8";
|
|
||||||
LC_NAME = "en_US.UTF-8";
|
|
||||||
LC_NUMERIC = "en_US.UTF-8";
|
|
||||||
LC_PAPER = "en_US.UTF-8";
|
|
||||||
LC_TELEPHONE = "en_US.UTF-8";
|
|
||||||
LC_TIME = "en_US.UTF-8";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
security.rtkit.enable = true;
|
|
||||||
|
|
||||||
services = {
|
|
||||||
xserver.xkb = {
|
|
||||||
layout = "us";
|
|
||||||
variant = "";
|
|
||||||
};
|
|
||||||
|
|
||||||
pipewire = {
|
|
||||||
enable = true;
|
|
||||||
alsa.enable = true;
|
|
||||||
alsa.support32Bit = true;
|
|
||||||
pulse.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
openssh = {
|
|
||||||
enable = true;
|
|
||||||
settings.PermitRootLogin = "no";
|
|
||||||
};
|
|
||||||
|
|
||||||
printing.enable = true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
shared,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
options.workstation.core = {
|
||||||
|
hostname = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "nixos";
|
||||||
|
description = "Hostname of the machine";
|
||||||
|
};
|
||||||
|
|
||||||
|
kernel = lib.mkOption {
|
||||||
|
type = with lib.types; enum (builtins.attrNames shared.kernelOptions);
|
||||||
|
default = "lts";
|
||||||
|
description = "The kernel of the machine";
|
||||||
|
};
|
||||||
|
|
||||||
|
user = {
|
||||||
|
name = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "river";
|
||||||
|
description = "The username of the primary user";
|
||||||
|
};
|
||||||
|
|
||||||
|
fullName = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "Maaz Khokhar";
|
||||||
|
description = "The full name of the user";
|
||||||
|
};
|
||||||
|
|
||||||
|
shell = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "fish";
|
||||||
|
description = "The shell the primary user uses";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
allowUnfree = lib.mkEnableOption "unfree packages" // {
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
ssh = {
|
||||||
|
permitRootLogin = lib.mkEnableOption "root SSH login";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
kernelOptions = {
|
||||||
|
stable = pkgs.linuxPackages;
|
||||||
|
lts = pkgs.linuxPackages_6_12;
|
||||||
|
latest = pkgs.linuxPackages_latest;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,23 +1,26 @@
|
|||||||
{ ... }:
|
{ config, lib, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.workstation.networking.core;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./firewall.nix
|
./firewall.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
networking = {
|
networking = {
|
||||||
networkmanager = {
|
networkmanager = {
|
||||||
enable = true;
|
enable = true;
|
||||||
dns = "systemd-resolved";
|
dns = "systemd-resolved";
|
||||||
};
|
};
|
||||||
extraHosts = "192.168.1.60 laptop";
|
|
||||||
|
extraHosts = lib.concatMapStringsSep "\n" (
|
||||||
|
host: "${host.ip_address} ${host.hostname}"
|
||||||
|
) cfg.extraHosts;
|
||||||
|
|
||||||
nftables.enable = true;
|
nftables.enable = true;
|
||||||
|
|
||||||
nameservers = [
|
nameservers = cfg.nameservers;
|
||||||
"192.168.1.193" # Pi-hole
|
|
||||||
"1.1.1.1" # Cloudflare
|
|
||||||
"1.0.0.1" # Cloudflare (Secondary)
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
services.resolved = {
|
services.resolved = {
|
||||||
@@ -27,12 +30,9 @@
|
|||||||
dnssec = "true";
|
dnssec = "true";
|
||||||
DNSOverTLS = "true";
|
DNSOverTLS = "true";
|
||||||
domains = [ "~." ];
|
domains = [ "~." ];
|
||||||
fallbackDns = [
|
fallbackDns = cfg.nameservers;
|
||||||
"192.168.1.193" # Pi-hole
|
|
||||||
"1.1.1.1" # Cloudflare
|
|
||||||
"1.0.0.1" # Cloudflare (Secondary)
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,14 @@
|
|||||||
{ ... }:
|
{ config, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.workstation.networking.core.firewall;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
networking.firewall = {
|
networking.firewall = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
allowPing = true;
|
allowPing = cfg.allowPing;
|
||||||
|
|
||||||
allowedTCPPorts = [
|
allowedTCPPorts = cfg.ports.tcp;
|
||||||
22
|
allowedUDPPorts = cfg.ports.udp;
|
||||||
80
|
|
||||||
];
|
|
||||||
allowedUDPPorts = [
|
|
||||||
53
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{ ... }:
|
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
./options.nix
|
||||||
./core
|
./core
|
||||||
|
./wireguard.nix
|
||||||
./tailscale.nix
|
./tailscale.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
options.workstation.networking = {
|
||||||
|
user = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "river";
|
||||||
|
description = "The user to run tailscale's services as.";
|
||||||
|
};
|
||||||
|
|
||||||
|
# core
|
||||||
|
core = {
|
||||||
|
firewall = {
|
||||||
|
allowPing = lib.mkEnableOption "ICMP pinging" // {
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
ports = {
|
||||||
|
tcp = lib.mkOption {
|
||||||
|
type = with lib.types; listOf number;
|
||||||
|
default = [
|
||||||
|
22
|
||||||
|
80
|
||||||
|
];
|
||||||
|
};
|
||||||
|
udp = lib.mkOption {
|
||||||
|
type = with lib.types; listOf number;
|
||||||
|
default = [ 53 ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
extraHosts = lib.mkOption {
|
||||||
|
type =
|
||||||
|
with lib.types;
|
||||||
|
listOf (
|
||||||
|
submodule (
|
||||||
|
{ ... }: {
|
||||||
|
options = {
|
||||||
|
ip_address = lib.mkOption {
|
||||||
|
type = str;
|
||||||
|
};
|
||||||
|
|
||||||
|
hostname = lib.mkOption {
|
||||||
|
type = str;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
default = [ ];
|
||||||
|
description = "Additional hosts to add.";
|
||||||
|
};
|
||||||
|
|
||||||
|
nameservers = lib.mkOption {
|
||||||
|
type = with lib.types; listOf str;
|
||||||
|
|
||||||
|
default = [
|
||||||
|
"192.168.1.193"
|
||||||
|
"1.1.1.1"
|
||||||
|
"1.0.0.1"
|
||||||
|
];
|
||||||
|
description = "DNS Resolvers for System";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# wireguard
|
||||||
|
wireguard = {
|
||||||
|
enable = lib.mkEnableOption "Wireguard support";
|
||||||
|
|
||||||
|
interfaces = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf (
|
||||||
|
lib.types.submodule {
|
||||||
|
options = {
|
||||||
|
enable = lib.mkEnableOption "Enable this WG interface";
|
||||||
|
|
||||||
|
address = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ ];
|
||||||
|
};
|
||||||
|
|
||||||
|
privateKeyFile = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
};
|
||||||
|
|
||||||
|
peers = lib.mkOption {
|
||||||
|
type = lib.types.listOf (
|
||||||
|
lib.types.submodule {
|
||||||
|
options = {
|
||||||
|
publicKey = lib.mkOption { type = lib.types.str; };
|
||||||
|
allowedIPs = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ ];
|
||||||
|
};
|
||||||
|
endpoint = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "";
|
||||||
|
};
|
||||||
|
persistentKeepalive = lib.mkOption {
|
||||||
|
type = lib.types.nullOr lib.types.int;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
default = [ ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# tailscale
|
||||||
|
tailscale = {
|
||||||
|
enable = lib.mkEnableOption "Tailscale mesh VPN";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,10 +1,14 @@
|
|||||||
{ config, ... }:
|
{ config, lib, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.workstation.networking.tailscale;
|
||||||
|
user = config.workstation.networking.user;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
services.tailscale = {
|
services.tailscale = {
|
||||||
enable = true;
|
enable = true;
|
||||||
openFirewall = true;
|
openFirewall = true;
|
||||||
extraSetFlags = [ "--operator=river" ];
|
extraSetFlags = [ "--operator=${user}" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.firewall = {
|
networking.firewall = {
|
||||||
@@ -19,7 +23,8 @@
|
|||||||
systemd.network.wait-online.enable = false;
|
systemd.network.wait-online.enable = false;
|
||||||
boot.initrd.systemd.network.wait-online.enable = false;
|
boot.initrd.systemd.network.wait-online.enable = false;
|
||||||
|
|
||||||
users.users.river.extraGroups = [
|
users.users.${user}.extraGroups = [
|
||||||
"tailscale"
|
"tailscale"
|
||||||
];
|
];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,21 @@
|
|||||||
{ ... }:
|
{ config, lib, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.workstation.networking.wireguard;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
networking.wireguard.interfaces = {
|
config = lib.mkIf cfg.enable {
|
||||||
wg0 = {
|
networking.wg-quick.interfaces = lib.mapAttrs (name: iface: {
|
||||||
ips = [ "10.0.0.2/24" ];
|
address = iface.address;
|
||||||
privateKeyFile = "/etc/wireguard/private.key"; # Keep secrets out of the nix store!
|
privateKeyFile = iface.privateKeyFile;
|
||||||
|
peers = map (p: {
|
||||||
|
publicKey = p.publicKey;
|
||||||
|
allowedIPs = p.allowedIPs;
|
||||||
|
endpoint = p.endpoint;
|
||||||
|
|
||||||
peers = [
|
persistentKeepalive = if p.persistentKeepalive != null then p.persistentKeepalive else null;
|
||||||
{
|
}) iface.peers;
|
||||||
publicKey = "vUUL4CD+1Sa2U2SZYa2P9IoFC2HxEr+PYNmYfRE8wwY=";
|
}) (lib.filterAttrs (_: v: v.enable) cfg.interfaces);
|
||||||
allowedIPs = [ "0.0.0.0/0" ];
|
|
||||||
endpoint = "server.maariz.org:51820";
|
|
||||||
persistentKeepalive = 25;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# Ensure the Wireguard UDP port is open if you are hosting the server
|
|
||||||
networking.firewall.allowedUDPPorts = [ 51820 ];
|
networking.firewall.allowedUDPPorts = [ 51820 ];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
imports = [
|
imports = [
|
||||||
./podman.nix
|
./podman.nix
|
||||||
./qemu.nix
|
./qemu.nix
|
||||||
./lima.nix
|
./options.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,15 @@
|
|||||||
{ pkgs, ... }:
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.workstation.virtualization.lima;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
lima
|
lima
|
||||||
];
|
];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
options.workstation.virtualization = {
|
||||||
|
user = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "river";
|
||||||
|
description = "The user to run virtualization services as.";
|
||||||
|
};
|
||||||
|
|
||||||
|
# podman
|
||||||
|
podman = {
|
||||||
|
enable = lib.mkEnableOption "Podman support";
|
||||||
|
|
||||||
|
packages = {
|
||||||
|
enable = lib.mkEnableOption "relevant Podman packages";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# qemu
|
||||||
|
qemu = {
|
||||||
|
enable = lib.mkEnableOption "QEMU support";
|
||||||
|
|
||||||
|
containers = lib.mkEnableOption "container support for QEMU";
|
||||||
|
|
||||||
|
spiceUSBRedirection = lib.mkEnableOption "spice USB redirection support for QEMU";
|
||||||
|
|
||||||
|
virtManager = lib.mkEnableOption "virt-manager support for QEMU";
|
||||||
|
|
||||||
|
bootModules = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [
|
||||||
|
"kvm-intel"
|
||||||
|
"kvm-amd"
|
||||||
|
];
|
||||||
|
description = "The kernel modules to load for QEMU support.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
lima = {
|
||||||
|
enable = lib.mkEnableOption "Lima lite VM";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,10 +1,19 @@
|
|||||||
{ pkgs, ... }:
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.workstation.virtualization;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = lib.mkMerge [
|
||||||
|
(lib.mkIf cfg.podman.enable {
|
||||||
virtualisation = {
|
virtualisation = {
|
||||||
oci-containers.backend = "podman";
|
oci-containers.backend = "podman";
|
||||||
containers.registries.search = [ "docker.io" ];
|
|
||||||
podman = {
|
podman = {
|
||||||
|
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
dockerCompat = true;
|
dockerCompat = true;
|
||||||
@@ -15,7 +24,7 @@
|
|||||||
# For rootless containers
|
# For rootless containers
|
||||||
security.unprivilegedUsernsClone = true;
|
security.unprivilegedUsernsClone = true;
|
||||||
|
|
||||||
users.users.river = {
|
users.users.${cfg.user} = {
|
||||||
subUidRanges = [
|
subUidRanges = [
|
||||||
{
|
{
|
||||||
startUid = 100000;
|
startUid = 100000;
|
||||||
@@ -33,10 +42,14 @@
|
|||||||
"podman"
|
"podman"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
})
|
||||||
|
|
||||||
|
(lib.mkIf cfg.podman.packages.enable {
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
podman
|
podman
|
||||||
podman-compose
|
podman-compose
|
||||||
podman-desktop
|
podman-desktop
|
||||||
];
|
];
|
||||||
|
})
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
{ pkgs, ... }:
|
|
||||||
|
|
||||||
{
|
{
|
||||||
virtualisation.spiceUSBRedirection.enable = true;
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.workstation.virtualization;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = lib.mkMerge [
|
||||||
|
(lib.mkIf cfg.qemu.enable {
|
||||||
virtualisation = {
|
virtualisation = {
|
||||||
containers.enable = true;
|
|
||||||
libvirtd = {
|
libvirtd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
qemu = {
|
qemu = {
|
||||||
@@ -13,18 +19,26 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
users.users.${cfg.user}.extraGroups = [
|
||||||
networking.firewall.trustedInterfaces = [ "virbr0" ];
|
|
||||||
|
|
||||||
programs.virt-manager.enable = true;
|
|
||||||
|
|
||||||
users.users.river.extraGroups = [
|
|
||||||
"libvirtd"
|
"libvirtd"
|
||||||
"kvm"
|
"kvm"
|
||||||
];
|
];
|
||||||
|
})
|
||||||
|
|
||||||
boot.kernelModules = [
|
(lib.mkIf cfg.qemu.spiceUSBRedirection {
|
||||||
"kvm-intel"
|
virtualisation.spiceUSBRedirection.enable = true;
|
||||||
"kvm-amd"
|
})
|
||||||
|
|
||||||
|
(lib.mkIf cfg.qemu.virtManager {
|
||||||
|
programs.virt-manager.enable = true;
|
||||||
|
})
|
||||||
|
|
||||||
|
(lib.mkIf (cfg.qemu.enable && cfg.qemu.containers) {
|
||||||
|
virtualisation.containers.enable = true;
|
||||||
|
})
|
||||||
|
|
||||||
|
(lib.mkIf cfg.qemu.enable {
|
||||||
|
boot.kernelModules = cfg.qemu.bootModules;
|
||||||
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user