13 Commits

Author SHA1 Message Date
6957d062c5 creating kubnet-accuse
Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
2024-08-06 20:03:52 -04:00
30c8441848 move mkDefault down into the enable level
Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
2024-08-06 20:03:52 -04:00
ea8c5ca025 move vm net config to separate module
Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
2024-08-06 20:03:52 -04:00
d29b2ecbab add guest network (now with custom mac address generators!)
Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
2024-08-06 20:03:52 -04:00
cc702cb5fe open firewall for ssh
Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
2024-08-06 20:03:52 -04:00
327895435b test disabling k3s server
Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
2024-08-06 20:03:52 -04:00
23fc7d2667 add journal merging and ssh
Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
2024-08-06 20:03:52 -04:00
eba9d9c4cd idek what i did to fix this
Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
2024-08-06 20:03:52 -04:00
1c596593ca try to fix attrset generation
Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
2024-08-06 20:03:52 -04:00
9985fc8778 initialize k3s templates
Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
2024-08-06 20:03:52 -04:00
3a61c7522d add basic guest config (warning CI is definitely failing lol)
Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
2024-08-06 20:03:51 -04:00
45610cb886 microvm host is stable (for now)
- per-system default.nix now inherits the source tree via `src` (this
allows modules to be optionally imported from `modules/opt/`)
- adds a default config for microvm hosts
  - enables systemd-networkd by default
  - allows passing in vms
  - binds vm nix-store to host nix-store
  - allows merging systemd jounals
- adds microvms to palatine-hill

Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
2024-08-06 20:03:51 -04:00
f9d31cba65 add microvms, and try to set up basics
Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
2024-08-06 20:03:51 -04:00
39 changed files with 701 additions and 267 deletions

12
.vscode/settings.json vendored
View File

@ -8,7 +8,6 @@
"acpid",
"adbusers",
"ahci",
"aioesphomeapi",
"alicehuston",
"alsa",
"amdgpu",
@ -67,7 +66,6 @@
"enableemail",
"errorlens",
"esbenp",
"esphome",
"extest",
"fastforwardteam",
"FASTFOX",
@ -92,7 +90,6 @@
"gamescope",
"globalprivacycontrol",
"gparted",
"gtts",
"healthreport",
"hexeditor",
"hicolor",
@ -107,9 +104,7 @@
"hyprland",
"hyprwm",
"INITDB",
"ioit",
"iperf",
"isal",
"jmgilman",
"jnoortheen",
"jobset",
@ -120,6 +115,7 @@
"keyserver",
"keyservers",
"KRNL",
"kubnet",
"kuma",
"libexec",
"libglvnd",
@ -137,6 +133,7 @@
"markdownlint",
"mechatroner",
"mediainfo",
"microvm",
"modesetting",
"mousewheel",
"mpris",
@ -170,7 +167,6 @@
"optimumwifi",
"optoutstudies",
"overscroll",
"overseerr",
"oxalica",
"pavucontrol",
"pbmode",
@ -188,13 +184,11 @@
"PRIVOXY",
"prowlarr",
"proxychains",
"prusa",
"psycopg",
"PUID",
"pulseaudio",
"punycode",
"pylance",
"pymetno",
"qbit",
"qbittorrent",
"qbittorrentvpn",
@ -232,7 +226,6 @@
"sponsorblock",
"spotifyd",
"sqltools",
"ssdp",
"sshconfig",
"stdenv",
"subresource",
@ -279,7 +272,6 @@
"xhci",
"xwayland",
"yzhang",
"zeroconf",
"zerotier",
"zerotierone",
"zhaofengli",

367
flake.lock generated
View File

@ -1,5 +1,27 @@
{
"nodes": {
"arch_mirror": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
],
"poetry2nix": "poetry2nix"
},
"locked": {
"lastModified": 1722708775,
"narHash": "sha256-z+8+fB0/8G9ScnDmgHKzR6BMxuTiK8mu0HDdp2y0dqQ=",
"owner": "RichieCahill",
"repo": "arch_mirror",
"rev": "ce97f5f7e7382f6cb36e464c0f18a3177396990d",
"type": "github"
},
"original": {
"owner": "RichieCahill",
"repo": "arch_mirror",
"type": "github"
}
},
"attic": {
"inputs": {
"crane": "crane",
@ -51,6 +73,27 @@
"type": "github"
}
},
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1722925878,
"narHash": "sha256-/wuVEbsqQnaNAYKqe/7CXm8cQXMAfsQYg9Mtkm2Aetg=",
"owner": "nix-community",
"repo": "fenix",
"rev": "aefb786b6a2924f684ba9ecd8fcad4628b214ffe",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"firefox-addons": {
"inputs": {
"flake-utils": [
@ -109,6 +152,24 @@
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": [
"systems"
@ -189,10 +250,106 @@
"type": "github"
}
},
"libgit2": {
"flake": false,
"locked": {
"lastModified": 1715853528,
"narHash": "sha256-J2rCxTecyLbbDdsyBWn9w7r3pbKRMkI9E7RvRgAqBdY=",
"owner": "libgit2",
"repo": "libgit2",
"rev": "36f7e21ad757a3dacc58cf7944329da6bc1d6e96",
"type": "github"
},
"original": {
"owner": "libgit2",
"ref": "v1.8.1",
"repo": "libgit2",
"type": "github"
}
},
"microvm": {
"inputs": {
"flake-utils": [
"flake-utils"
],
"nixpkgs": [
"nixpkgs"
],
"spectrum": "spectrum"
},
"locked": {
"lastModified": 1716382614,
"narHash": "sha256-dwUYl8jyMNKidPEM9gTafcRe+3pUh2rH3ZlBrUpsvnw=",
"owner": "astro",
"repo": "microvm.nix",
"rev": "a59c3167f673ce29b65c674deb2bee73d151a96c",
"type": "github"
},
"original": {
"owner": "astro",
"repo": "microvm.nix",
"type": "github"
}
},
"nix": {
"inputs": {
"flake-compat": [
"flake-compat"
],
"flake-parts": [
"flake-parts"
],
"git-hooks-nix": [
"pre-commit-hooks"
],
"libgit2": "libgit2",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-23-11": "nixpkgs-23-11",
"nixpkgs-regression": "nixpkgs-regression"
},
"locked": {
"lastModified": 1722501671,
"narHash": "sha256-3yFEvUDPB7GlCMI9I5VV+HXMVOT38h3lnw01nIXU2F4=",
"owner": "NixOS",
"repo": "nix",
"rev": "0a167ffd1f57864ce042d83f9d1f17ef5126c442",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "latest-release",
"repo": "nix",
"type": "github"
}
},
"nix-github-actions": {
"inputs": {
"nixpkgs": [
"system_tools",
"arch_mirror",
"poetry2nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1703863825,
"narHash": "sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y=",
"owner": "nix-community",
"repo": "nix-github-actions",
"rev": "5163432afc817cf8bd1f031418d1869e4c9d5547",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nix-github-actions",
"type": "github"
}
},
"nix-github-actions_2": {
"inputs": {
"nixpkgs": [
"server_tools",
"poetry2nix",
"nixpkgs"
]
@ -322,6 +479,22 @@
"type": "github"
}
},
"nixpkgs-23-11": {
"locked": {
"lastModified": 1717159533,
"narHash": "sha256-oamiKNfr2MS6yH64rUn99mIZjc45nGJlj9eGth/3Xuw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1722555339,
@ -334,6 +507,22 @@
"url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz"
}
},
"nixpkgs-regression": {
"locked": {
"lastModified": 1643052045,
"narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1722869614,
@ -353,23 +542,51 @@
"poetry2nix": {
"inputs": {
"flake-utils": [
"system_tools",
"arch_mirror",
"flake-utils"
],
"nix-github-actions": "nix-github-actions",
"nixpkgs": [
"system_tools",
"arch_mirror",
"nixpkgs"
],
"systems": "systems",
"systems": "systems_2",
"treefmt-nix": "treefmt-nix"
},
"locked": {
"lastModified": 1723343306,
"narHash": "sha256-/6sRkPq7/5weX2y0V8sQ29Sz35nt8kyj+BsFtkhgbJE=",
"lastModified": 1722515463,
"narHash": "sha256-6FVPz1WzHak65xJQg8tRjVyFEWMesGxfskKaCxDUnRk=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "4a1c112ff0c67f496573dc345bd0b2247818fc29",
"rev": "8c25e871bba3f472e1569bbf6c0f52dcc34bf2a4",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "poetry2nix",
"type": "github"
}
},
"poetry2nix_2": {
"inputs": {
"flake-utils": [
"server_tools",
"flake-utils"
],
"nix-github-actions": "nix-github-actions_2",
"nixpkgs": [
"server_tools",
"nixpkgs"
],
"systems": "systems_3",
"treefmt-nix": "treefmt-nix_2"
},
"locked": {
"lastModified": 1721039874,
"narHash": "sha256-XANsG9GYHip8pxZpbqKf/YGv8tIa0xTh289Y+WNBNfw=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "d11c01e58587e5f21037ed6477465a7f26a32e27",
"type": "github"
},
"original": {
@ -407,13 +624,17 @@
},
"root": {
"inputs": {
"arch_mirror": "arch_mirror",
"attic": "attic",
"fenix": "fenix",
"firefox-addons": "firefox-addons",
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
"flake-utils": "flake-utils",
"flake-utils": "flake-utils_2",
"home-manager": "home-manager",
"hyprland-contrib": "hyprland-contrib",
"microvm": "microvm",
"nix": "nix",
"nix-index-database": "nix-index-database",
"nixos-generators": "nixos-generators",
"nixos-hardware": "nixos-hardware",
@ -422,12 +643,29 @@
"nixpkgs-stable": "nixpkgs-stable",
"pre-commit-hooks": "pre-commit-hooks",
"rust-overlay": "rust-overlay",
"server_tools": "server_tools",
"sops-nix": "sops-nix",
"system_tools": "system_tools",
"systems": "systems_2",
"systems": "systems_4",
"wired-notify": "wired-notify"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1722868550,
"narHash": "sha256-Z708uZsfcP6IprVtw1AwjN0zjUX5+6lbneYiin58umc=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "4a99d795d06970accb46bd594f473999818b2fa8",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
@ -473,6 +711,30 @@
"type": "github"
}
},
"server_tools": {
"inputs": {
"flake-utils": [
"flake-utils"
],
"nixpkgs": [
"nixpkgs"
],
"poetry2nix": "poetry2nix_2"
},
"locked": {
"lastModified": 1722726877,
"narHash": "sha256-VEfypyflLdxL3hjtURbpfRv9dyc3Z/CvvZ76bAad8l8=",
"owner": "RAD-Development",
"repo": "server_tools",
"rev": "16f24eddcb117c5560582c42c120ba84360c7f1f",
"type": "github"
},
"original": {
"owner": "RAD-Development",
"repo": "server_tools",
"type": "github"
}
},
"sops-nix": {
"inputs": {
"nixpkgs": [
@ -496,31 +758,38 @@
"type": "github"
}
},
"system_tools": {
"inputs": {
"flake-utils": [
"flake-utils"
],
"nixpkgs": [
"nixpkgs"
],
"poetry2nix": "poetry2nix"
},
"spectrum": {
"flake": false,
"locked": {
"lastModified": 1723392261,
"narHash": "sha256-Csa4yuYWcB3aLf7VP14v+Mp0lRzOOCCt9BdmAeeQcYU=",
"owner": "RAD-Development",
"repo": "system_tools",
"rev": "51bcc923b2b3cfb832b05687a01805c5a905b0c9",
"type": "github"
"lastModified": 1708358594,
"narHash": "sha256-e71YOotu2FYA67HoC/voJDTFsiPpZNRwmiQb4f94OxQ=",
"ref": "refs/heads/main",
"rev": "6d0e73864d28794cdbd26ab7b37259ab0e1e044c",
"revCount": 614,
"type": "git",
"url": "https://spectrum-os.org/git/spectrum"
},
"original": {
"owner": "RAD-Development",
"repo": "system_tools",
"type": "github"
"type": "git",
"url": "https://spectrum-os.org/git/spectrum"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
@ -534,7 +803,21 @@
"type": "indirect"
}
},
"systems_2": {
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"id": "systems",
"type": "indirect"
}
},
"systems_4": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
@ -552,7 +835,29 @@
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"system_tools",
"arch_mirror",
"poetry2nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1719749022,
"narHash": "sha256-ddPKHcqaKCIFSFc/cvxS14goUhCOAwsM1PbMr0ZtHMg=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "8df5ff62195d4e67e2264df0b7f5e8c9995fd0bd",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
},
"treefmt-nix_2": {
"inputs": {
"nixpkgs": [
"server_tools",
"poetry2nix",
"nixpkgs"
]

View File

@ -29,6 +29,11 @@
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.05";
systems.url = "github:nix-systems/default";
arch_mirror = {
url = "github:RichieCahill/arch_mirror";
inputs.nixpkgs.follows = "nixpkgs";
};
attic = {
url = "github:zhaofengli/attic";
inputs = {
@ -39,6 +44,11 @@
};
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
firefox-addons = {
url = "gitlab:rycee/nur-expressions?dir=pkgs/firefox-addons";
inputs = {
@ -62,11 +72,28 @@
inputs.nixpkgs.follows = "nixpkgs";
};
microvm = {
url = "github:astro/microvm.nix";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
nix = {
url = "github:NixOS/nix/latest-release";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-compat.follows = "flake-compat";
flake-parts.follows = "flake-parts";
git-hooks-nix.follows = "pre-commit-hooks";
};
};
nix-index-database = {
url = "github:Mic92/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
@ -104,8 +131,8 @@
};
};
system_tools = {
url = "github:RAD-Development/system_tools";
server_tools = {
url = "github:RAD-Development/server_tools";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";

View File

@ -3,6 +3,7 @@
# create rad-dev namespace for lib
rad-dev = rec {
systems = import ./systems.nix { inherit lib; };
microvm = import ./microvms.nix { inherit lib; };
# any(), but checks if any value in the list is true
#
@ -56,5 +57,30 @@
# type:
# fileList :: Path -> String -> [Path]
fileList = dir: map (file: dir + "/${file}") (ls dir);
# constructs a mac address from a string's hash
#
# args:
# hashable: the string to hash
#
# type:
# strToMac :: String -> String
strToMac =
hashable:
let
# computes sha512 hash of input
hashStr = builtins.hashString "sha512" hashable;
# grabs first 12 letters of hash
hashSub = start: builtins.substring start 2 (builtins.substring 0 12 hashStr);
# joins list of strings with a delimiter between
joiner =
delim: arr:
builtins.foldl' (
a: b: lib.concatStrings ([ a ] ++ (lib.optionals (a != "") [ delim ]) ++ [ b ])
) "" arr;
# generates a list of indexes for the hash
starts = builtins.genList (x: x * 2) 6;
in
joiner ":" (map hashSub starts);
};
}

116
lib/microvms.nix Normal file
View File

@ -0,0 +1,116 @@
{ lib, ... }:
rec {
genK3SVM =
server-config: agent-config: vms:
lib.mapAttrs (
host:
{
address,
gateway,
machine-id,
server ? false,
}:
genMicroVM host address gateway "x86_64-linux" machine-id (
if server then server-config else agent-config
)
) vms;
genMicroVM =
hostName: address: gateway: _system: machine-id: vm-config:
# microvm refers to microvm.nixosModules
# {
# config,
# pkgs,
# lib,
# ...
# }:
{
# The package set to use for the microvm. This also determines the microvm's architecture.
# Defaults to the host system's package set if not given.
# pkgs = import pkgs { inherit system; };
# (Optional) A set of special arguments to be passed to the MicroVM's NixOS modules.
#specialArgs = {};
# The configuration for the MicroVM.
# Multiple definitions will be merged as expected.
config = {
imports = [ vm-config ];
# It is highly recommended to share the host's nix-store
# with the VMs to prevent building huge images.
system.stateVersion = "24.05";
environment.etc."machine-id" = {
mode = "0644";
text = machine-id + "\n";
};
networking.hostName = hostName;
microvm = {
interfaces = [
{
type = "tap";
# bridge = "ztkubnet";
id = "vm-${hostName}";
mac = lib.rad-dev.strToMac hostName;
}
];
shares = [
{
source = "/nix/store";
mountPoint = "/nix/.ro-store";
tag = "ro-store";
proto = "virtiofs";
}
{
# On the host
source = "/var/lib/microvms/${hostName}/journal";
# In the MicroVM
mountPoint = "/var/log/journal";
tag = "journal";
proto = "virtiofs";
socket = "journal.sock";
}
];
};
systemd.network.enable = true;
systemd.network.networks."20-lan" = {
matchConfig.Type = "ether";
networkConfig = {
Address = address;
Gateway = gateway;
DNS = [ "9.9.9.9" ];
IPv6AcceptRA = true;
DHCP = "no";
};
};
services.openssh = {
enable = true;
openFirewall = true;
};
users.users.alice = {
openssh.authorizedKeys.keys = [
# photon
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOGcqhLaKsjwAnb6plDavAhEyQHNvFS9Uh5lMTuwMhGF alice@parthenon-7588"
# gh
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGoaEmzaS9vANckvBmqrYSHdFR0sPL4Xgeonbh9KcgFe gitlab keypair"
# janus
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAfcO9p5opG8Tym6tcLkat6YGCcE6vwg0+V4MTC5WKop alice@parthenon-7588"
# palatine
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP59pDsx34k2ikrKa0eVacj0APSGivaij3lP9L0Zd9au alice@parthenon-7588"
# jeeves
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJDgkUndkfns6f779T5ckHOVhyOKP8GttQ9RfaO9uJdx alice@parthenon-7588"
];
isNormalUser = true;
};
# Any other configuration for your MicroVM
# [...]
};
};
}

View File

@ -160,7 +160,12 @@ rec {
lib.nixosSystem {
inherit system;
specialArgs = {
inherit inputs server system;
inherit
inputs
server
system
src
;
};
modules =
[
@ -208,7 +213,7 @@ rec {
inherit inputs src configPath;
hostname = name;
}
// import configPath { inherit inputs; }
// import configPath { inherit inputs src; }
);
}
) (lib.rad-dev.lsdir path)

View File

@ -20,13 +20,13 @@ in
echo "ebe7fbd44565ba9d=ztkubnet" > /var/lib/zerotier-one/devicemap
'';
services.zerotierone = lib.mkDefault {
enable = true;
services.zerotierone = {
enable = lib.mkDefault true;
joinNetworks = [ "ebe7fbd44565ba9d" ];
};
systemd.network = lib.mkDefault {
enable = true;
systemd.network = {
enable = lib.mkDefault true;
wait-online.anyInterface = true;
netdevs = {
"20-brkubnet" = {
@ -38,15 +38,27 @@ in
};
networks = {
"30-ztkubnet" = {
matchConfig.Name = "ztkubnet";
matchConfig.Name = [ "ztkubnet" ];
networkConfig.Bridge = "brkubnet";
linkConfig.RequiredForOnline = "enslaved";
};
"40-brkubnet" = {
matchConfig.Name = "brkubnet";
bridgeConfig = { };
networkConfig.LinkLocalAddressing = "no";
linkConfig.RequiredForOnline = "no";
};
"41-vms" = {
matchConfig.Name = [ "vm-*" ];
networkConfig.Bridge = "brkubnet";
linkConfig.RequiredForOnline = "enslaved";
};
"42-kubnet-accuse" = {
matchConfig.Name = "kubnet-accuse";
networkConfig.Bridge = "brkubnet";
linkConfig.RequiredForOnline = "enslaved";
address = [ "192.168.69.20/24" ];
};
};
};

5
modules/opt/default.nix Normal file
View File

@ -0,0 +1,5 @@
{ ... }:
{
}

View File

@ -0,0 +1,5 @@
{ ... }:
{
imports = [ ./k3s-common.nix ];
services.k3s.role = "agent";
}

View File

@ -0,0 +1,15 @@
{
config,
lib,
pkgs,
...
}:
{
services.k3s = {
enable = true;
extraFlags = "--cluster-cidr 192.168.69.0/24";
# tokenFile = #TODO: set this up after building the first node lol
# serverAddr =
};
}

View File

@ -0,0 +1,6 @@
{ ... }:
{
# imports = [ ./k3s-common.nix ];
services.k3s.role = "server";
}

View File

@ -0,0 +1,34 @@
{
config,
lib,
inputs,
...
}:
let
cfg = config.rad-dev.microvm-host;
microvm = inputs.microvm.nixosModules;
in
{
imports = [ microvm.host ];
options.rad-dev.microvm-host = {
vms = lib.mkOption {
type = lib.types.attrs;
default = { };
description = "A list of VMs to construct on the host";
};
};
config = {
networking.useNetworkd = true;
microvm.vms = cfg.vms;
# TODO: deprecate this once we have syslog forwarders
systemd.tmpfiles.rules = map (
vmHost:
let
machineId = cfg.vms.${vmHost}.config.environment.etc."machine-id".text;
in
# creates a symlink of each MicroVM's journal under the host's /var/log/journal
"L+ /var/log/journal/${machineId} - - - - /var/lib/microvms/${vmHost}/journal/${machineId}"
) (builtins.attrNames cfg.vms);
};
}

View File

@ -1,24 +0,0 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.rad-dev.yubikey;
in
{
options = {
services.rad-dev.yubikey = {
enable = lib.mkEnableOption "enable yubikey defaults";
enable-desktop-app = lib.mkEnableOption "installs desktop application";
};
};
config = lib.mkIf cfg.enable {
# enable the smart card daemon for certain yubikey operations
services.pcscd.enable = true;
environment.systemPackages = lib.optionals cfg.enable-desktop-app [ pkgs.yubioath-flutter ];
};
}

View File

@ -1,4 +1,4 @@
disabled = ["empty_pattern"]
nix_version = '2.23'
nix_version = '2.4'
ignore = ['.direnv']

View File

@ -84,10 +84,6 @@
};
#systemd.services.spotifyd.serviceConfig = systemd.services.spotifyd.
};
rad-dev.yubikey = {
enable = true;
enable-desktop-app = true;
};
};
users.users.alice.extraGroups = [ "calibre-web" ];

View File

@ -12,7 +12,7 @@
calibre
# calibre dedrm?
candy-icons
nemo-with-extensions
cinnamon.nemo-with-extensions
croc
deadnix
direnv
@ -93,6 +93,7 @@
wget
wl-clipboard
xboxdrv
yubioath-flutter
zoom-us
zoxide
zoom

View File

@ -9,6 +9,7 @@ in
"${../../users/richie/global/docker_templates}/file_server/sites/:/etc/apache2/sites-enabled/"
"${vars.main_mirror}:/data"
];
ports = [ "800:80" ];
extraOptions = [ "--network=web" ];
autoStart = true;
};
@ -22,7 +23,7 @@ in
serviceConfig = {
Environment = "MIRROR_DIR=${vars.main_mirror}/archlinux/";
Type = "simple";
ExecStart = "${inputs.system_tools.packages.x86_64-linux.default}/bin/sync_mirror";
ExecStart = "${inputs.arch_mirror.packages.x86_64-linux.default}/bin/sync_mirror";
};
};
}

View File

@ -2,29 +2,50 @@
{
imports = [
../../users/richie/global/ssh.nix
../../users/richie/global/zerotier.nix
./arch_mirror.nix
./docker
./home_assistant.nix
./networking.nix
./services.nix
];
networking = {
hostId = "1beb3026";
firewall.enable = false;
};
boot = {
zfs.extraPools = [ "Main" ];
filesystem = "zfs";
useSystemdBoot = true;
};
environment.systemPackages = with pkgs; [ docker-compose ];
environment = {
systemPackages = with pkgs; [ docker-compose ];
etc = {
# Creates /etc/lynis/custom.prf
"lynis/custom.prf" = {
text = ''
skip-test=BANN-7126
skip-test=BANN-7130
skip-test=DEB-0520
skip-test=DEB-0810
skip-test=FIRE-4513
skip-test=HRDN-7222
skip-test=KRNL-5820
skip-test=LOGG-2190
skip-test=LYNIS
skip-test=TOOL-5002
'';
mode = "0440";
};
};
};
services = {
openssh = {
ports = [ 352 ];
listenAddresses = [
{ addr = "192.168.95.35"; }
{ addr = "192.168.90.35"; }
];
};
nfs.server.enable = true;
openssh.ports = [ 352 ];
smartd.enable = true;

View File

@ -26,11 +26,9 @@ frontend ContentSwitching
# tmmworkshop.com
acl host_mirror hdr(host) -i mirror.tmmworkshop.com jeeves
acl host_uptime_kuma hdr(host) -i uptimekuma-jeevesjr.tmmworkshop.com
acl host_homeassistant hdr(host) -i homeassistant.tmmworkshop.com
use_backend mirror_nodes if host_mirror
use_backend uptime_kuma_nodes if host_uptime_kuma
use_backend home_asistant_nodes if host_homeassistant
# tmmworkshop.com
backend mirror_nodes
@ -40,7 +38,3 @@ backend mirror_nodes
backend uptime_kuma_nodes
mode http
server server uptime_kuma:3001
backend home_asistant_nodes
mode http
server server 192.168.95.35:8123

View File

@ -8,6 +8,7 @@
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
networking.useDHCP = lib.mkDefault true;
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
swapDevices = [ { device = "/dev/disk/by-uuid/9d4ef549-d426-489d-8332-0a49589c6aed"; } ];
boot = {

View File

@ -3,47 +3,15 @@
enable = true;
openFirewall = true;
config = {
http = {
server_port = 8123;
server_host = [
"192.168.95.35"
"192.168.90.35"
"192.168.98.4"
];
use_x_forwarded_for = true;
trusted_proxies = "172.100.0.4";
};
server_port = 8123;
homeassistant = {
time_zone = "America/New_York";
unit_system = "imperial";
temperature_unit = "F";
longitude = 40.74;
latitude = 74.03;
};
assist_pipeline = { };
backup = { };
bluetooth = { };
config = { };
dhcp = { };
energy = { };
history = { };
homeassistant_alerts = { };
image_upload = { };
logbook = { };
media_source = { };
mobile_app = { };
ssdp = { };
sun = { };
webhook = { };
zeroconf = { };
};
extraPackages =
python3Packages: with python3Packages; [
psycopg2
gtts
aioesphomeapi
esphome-dashboard-api
bleak-esphome
pymetno
];
extraComponents = [ "isal" ];
extraPackages = python3Packages: with python3Packages; [ psycopg2 ];
};
}

View File

@ -1,43 +0,0 @@
{
networking = {
hostId = "1beb3026";
firewall.enable = false;
};
systemd.network = {
enable = true;
netdevs = {
"20-ioit-vlan" = {
netdevConfig = {
Kind = "vlan";
Name = "ioit-vlan";
};
vlanConfig.Id = 20;
};
};
networks = {
"10-lan" = {
matchConfig.Name = "enp4s0";
DHCP = "yes";
vlan = [ "ioit-vlan" ];
linkConfig.RequiredForOnline = "routable";
};
"40-ioit-vlan" = {
matchConfig.Name = "ioit-vlan";
DHCP = "yes";
};
};
};
services.zerotierone = {
enable = true;
joinNetworks = [ "e4da7455b2ae64ca" ];
};
}
# 22/tcp open ssh
# 800/tcp open mdbs_daemon
# 5355/tcp open llmnr
# 8123/tcp open polipo
# 9993/tcp open palace-2

View File

@ -15,7 +15,7 @@
serviceConfig = {
Type = "oneshot";
EnvironmentFile = config.sops.secrets."server-validation/webhook".path;
ExecStart = "${inputs.system_tools.packages.x86_64-linux.default}/bin/validate_jeevesjr";
ExecStart = "${inputs.server_tools.packages.x86_64-linux.default}/bin/validate_jeevesjr";
};
};
timers.startup_validation = {

View File

@ -23,7 +23,7 @@ in
serviceConfig = {
Environment = "MIRROR_DIR=${vars.media_mirror}/archlinux/";
Type = "simple";
ExecStart = "${inputs.system_tools.packages.x86_64-linux.default}/bin/sync_mirror";
ExecStart = "${inputs.arch_mirror.packages.x86_64-linux.default}/bin/sync_mirror";
};
};
}

View File

@ -6,13 +6,18 @@ in
imports = [
../../users/richie/global/ssh.nix
../../users/richie/global/syncthing_base.nix
../../users/richie/global/zerotier.nix
./arch_mirror.nix
./docker
./networking.nix
./programs.nix
./services.nix
];
networking = {
hostId = "1beb3027";
firewall.enable = false;
};
boot = {
zfs.extraPools = [
"media"

View File

@ -30,14 +30,12 @@ frontend ContentSwitching
acl host_grafana hdr(host) -i grafana.tmmworkshop.com
acl host_filebrowser hdr(host) -i filebrowser.tmmworkshop.com
acl host_uptime_kuma hdr(host) -i uptimekuma-jeeves.tmmworkshop.com
acl host_overseerr hdr(host) -i overseerr.tmmworkshop.com
use_backend mirror_nodes if host_mirror
use_backend dndrules_nodes if host_dndrules
use_backend grafana_nodes if host_grafana
use_backend filebrowser_nodes if host_filebrowser
use_backend uptime_kuma_nodes if host_uptime_kuma
use_backend overseerr_nodes if host_overseerr
backend mirror_nodes
mode http
@ -62,7 +60,3 @@ backend filebrowser_nodes
backend uptime_kuma_nodes
mode http
server server uptime_kuma:3001
backend overseerr_nodes
mode http
server server overseerr:5055

View File

@ -112,33 +112,6 @@ in
];
autoStart = true;
};
overseerr = {
image = "ghcr.io/linuxserver/overseerr:latest";
environment = {
PUID = "600";
PGID = "100";
TZ = "America/New_York";
};
volumes = [ "${vars.media_docker_configs}/overseerr:/config" ];
dependsOn = [
"radarr"
"sonarr"
];
extraOptions = [ "--network=web" ];
autoStart = true;
};
unpackerr = {
image = "golift/unpackerr:latest";
user = "600:100";
environment = {
TZ = "America/New_York";
};
volumes = [
"${vars.torrenting_qbit}:/data"
"${config.sops.secrets.unpackerr_conf}:/etc/unpackerr/unpackerr.conf"
];
autoStart = true;
};
whisper = {
image = "ghcr.io/linuxserver/faster-whisper:latest";
ports = [ "10300:10300" ];

View File

@ -35,7 +35,6 @@ in
"dnd_file_server"
"filebrowser"
"grafana"
"overseerr"
"uptime_kuma"
];
extraOptions = [ "--network=web" ];

View File

@ -40,6 +40,17 @@
swapDevices = [ { device = "/dev/disk/by-uuid/4c797a94-be32-43d3-89ac-7f02912c7cf5"; } ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp38s0f3u2u2c2.useDHCP = lib.mkDefault true;
# networking.interfaces.enp97s0f0np0.useDHCP = lib.mkDefault true;
# networking.interfaces.enp97s0f1np1.useDHCP = lib.mkDefault true;
# networking.interfaces.enp98s0f0.useDHCP = lib.mkDefault true;
# networking.interfaces.enp98s0f1.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View File

@ -1,40 +0,0 @@
{
networking = {
hostId = "1beb3027";
firewall.enable = false;
};
systemd.network = {
enable = true;
networks = {
"10-1GB_Primary" = {
matchConfig.Name = "enp98s0f0";
DHCP = "yes";
};
};
networks = {
"10-1GB_Secondary" = {
matchConfig.Name = "enp98s0f1";
DHCP = "yes";
};
};
networks = {
"10-10GB_Primary" = {
matchConfig.Name = "enp97s0f0np0";
DHCP = "yes";
linkConfig.RequiredForOnline = "routable";
};
};
networks = {
"10-10GB_Secondary" = {
matchConfig.Name = "enp97s0f1np1";
DHCP = "yes";
};
};
};
services.zerotierone = {
enable = true;
joinNetworks = [ "e4da7455b2ae64ca" ];
};
}

View File

@ -23,7 +23,7 @@
serviceConfig = {
EnvironmentFile = config.sops.secrets."server-validation/webhook".path;
Type = "oneshot";
ExecStart = "${inputs.system_tools.packages.x86_64-linux.default}/bin/validate_jeeves";
ExecStart = "${inputs.server_tools.packages.x86_64-linux.default}/bin/validate_jeeves";
};
};
};

View File

@ -9,11 +9,13 @@
./attic.nix
./docker.nix
./hydra.nix
./microvms.nix
./minio.nix
./networking.nix
./nextcloud.nix
./services.nix
./zfs.nix
./networking.nix
];
programs.git.lfs.enable = false;

View File

@ -1,8 +1,11 @@
{ inputs, ... }:
{ inputs, src, ... }:
{
users = [
"alice"
"richie"
];
modules = [ inputs.attic.nixosModules.atticd ];
modules = [
inputs.attic.nixosModules.atticd
(src + "/modules/opt/microvm-host.nix")
];
}

View File

@ -0,0 +1,27 @@
{
config,
lib,
pkgs,
src,
...
}:
let
inherit (lib.rad-dev.microvm) genK3SVM;
in
{
# rad-dev.microvm-host.enable = true;
rad-dev.microvm-host.vms =
genK3SVM (src + "/modules/opt/k3s-server.nix") (src + "/modules/opt/k3s-agent.nix")
{
"ph-server-1" = {
address = [ "192.168.69.10/24" ];
gateway = "192.168.69.1";
machine-id = "d694ad1e88b356887bb204ac665263f7";
server = true;
};
# "ph-agent-1" = {
# ipv4 = "192.168.69.30";
# };
};
}

View File

@ -15,7 +15,7 @@
serviceConfig = {
Type = "oneshot";
EnvironmentFile = config.sops.secrets."server-validation/webhook".path;
ExecStart = "${inputs.system_tools.packages.x86_64-linux.default}/bin/validate_palatine_hill";
ExecStart = "${inputs.server_tools.packages.x86_64-linux.default}/bin/validate_palatine_hill";
};
};
timers.startup_validation = {

View File

@ -8,8 +8,8 @@
home.packages = with pkgs; [
beeper
candy-icons
nemo
nemo-fileroller
cinnamon.nemo
cinnamon.nemo-fileroller
discord-canary
gimp
gparted
@ -21,6 +21,5 @@
util-linux
vlc
zoom-us
prusa-slicer
];
}

View File

@ -50,6 +50,9 @@
// force the use of rust-analyzer from dev shell
"rust-analyzer.server.path": "rust-analyzer",
// other
"python.analysis.typeCheckingMode": "basic",
"redhat.telemetry.enabled": true,
"gitlens.plusFeatures.enabled": false,
// new

View File

@ -43,6 +43,7 @@
nix-prefetch
nix-tree
nixpkgs-fmt
inputs.system_tools.packages.x86_64-linux.default
inputs.server_tools.packages.x86_64-linux.default
inputs.arch_mirror.packages.x86_64-linux.default
];
}

View File

@ -30,12 +30,6 @@
identityFile = "~/.ssh/id_ed25519";
port = 922;
};
palatine-hill = {
hostname = "192.168.76.2";
user = "richie";
identityFile = "~/.ssh/id_ed25519";
port = 666;
};
};
};
}