Skip to content

Commit bab2868

Browse files
authored
Hosts/thor (#153)
* hosts/thor: initial thor server * secrets: add root_thor publicKeys * services/audiobookshelf: add audiobookshelf services
1 parent 8599ac1 commit bab2868

File tree

13 files changed

+275
-17
lines changed

13 files changed

+275
-17
lines changed

.github/workflows/build-nixos.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ jobs:
4343
name: edeneast
4444
- name: Build rize
4545
run: nix build --accept-flake-config --print-out-paths --show-trace .#nixosConfigurations.rize.config.system.build.toplevel
46+
build-thor:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Free Disk Space (Ubuntu)
50+
uses: jlumbroso/free-disk-space@main
51+
- name: Checkout
52+
uses: actions/checkout@v6
53+
with:
54+
fetch-depth: 1
55+
- name: Install Nix
56+
uses: DeterminateSystems/nix-installer-action@main
57+
- name: Cachix
58+
uses: cachix/cachix-action@master
59+
with:
60+
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
61+
name: edeneast
62+
- name: Build thor
63+
run: nix build --accept-flake-config --print-out-paths --show-trace .#nixosConfigurations.thor.config.system.build.toplevel
4664
build-wrath:
4765
runs-on: ubuntu-latest
4866
steps:

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hosts/thor/configuration.nix

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
inputs,
3+
pkgs,
4+
...
5+
}: {
6+
imports = [
7+
./hardware.nix
8+
./secrets.nix
9+
];
10+
11+
# Base system definitions
12+
networking.hostName = "thor";
13+
system.stateVersion = "25.11";
14+
15+
time.timeZone = "America/Toronto";
16+
i18n.defaultLocale = "en_US.UTF-8";
17+
18+
my = {
19+
nixos = {
20+
base = {
21+
enable = true;
22+
editor = inputs.nvim-config.packages.${pkgs.stdenv.hostPlatform.system}.stable;
23+
};
24+
25+
profiles = {
26+
keymap.enable = true;
27+
};
28+
29+
services = {
30+
audiobookshelf = {
31+
enable = true;
32+
tailscale.enable = true;
33+
};
34+
tailscale.enable = true;
35+
};
36+
};
37+
38+
users.eden = {
39+
password = "$6$nF.UDyrpHmh6M$yKCw56auQ7Dm1FfvmQg6y3Y59mWsoiHJyAYhqF9e8nKjfeKwUoFocwHhogKUTq.A3hVe9S.smv7u1NLV/yPTd0";
40+
enable = true;
41+
};
42+
};
43+
}

hosts/thor/disko.nix

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
disko.devices = {
3+
disk = {
4+
main = {
5+
type = "disk";
6+
device = "/dev/disk/by-id/ata-M4-CT128M4SSD2_000000001224090D56BE";
7+
content = {
8+
type = "gpt";
9+
partitions = {
10+
boot = {
11+
size = "1M";
12+
type = "EF02"; # for grub MBR
13+
priority = 1;
14+
};
15+
ESP = {
16+
size = "512M";
17+
type = "EF00";
18+
content = {
19+
type = "filesystem";
20+
format = "vfat";
21+
mountpoint = "/boot";
22+
mountOptions = ["umask=0077"];
23+
};
24+
};
25+
root = {
26+
size = "100%";
27+
content = {
28+
type = "filesystem";
29+
format = "ext4";
30+
mountpoint = "/";
31+
};
32+
};
33+
};
34+
};
35+
};
36+
};
37+
};
38+
}

hosts/thor/hardware.nix

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
modulesPath,
6+
...
7+
}: {
8+
imports = [
9+
(modulesPath + "/installer/scan/not-detected.nix")
10+
./disko.nix
11+
];
12+
13+
boot = {
14+
supportedFilesystems = ["btrfs"];
15+
initrd = {
16+
availableKernelModules = ["nvme" "xhci_pci" "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod"];
17+
kernelModules = [];
18+
};
19+
kernelModules = [];
20+
extraModulePackages = [];
21+
22+
# Bootloader. As this computer is an OLD computer we need to use grub
23+
loader.grub = {
24+
enable = true;
25+
devices = lib.mkForce ["/dev/disk/by-id/ata-M4-CT128M4SSD2_000000001224090D56BE"];
26+
};
27+
};
28+
29+
environment.systemPackages = [pkgs.btrfs-progs];
30+
fileSystems."/data" = {
31+
device = "/dev/disk/by-label/data";
32+
fsType = "btrfs";
33+
};
34+
35+
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
36+
37+
networking.useDHCP = lib.mkDefault true;
38+
39+
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
40+
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
41+
}

hosts/thor/readme.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Wrath
2+
3+
## Overview
4+
5+
Old desktop server
6+
7+
---
8+
9+
## Specs
10+
11+
| Component | Details |
12+
| ----------- | ------------------------------ |
13+
| **Model** | Custom ATX Desktop |
14+
| **CPU** | Intel i7-3770s @ 3.10GHz |
15+
| **RAM** | 16GB |
16+
| **Storage** | 128GB SSD, 2x 1TB HDD |
17+
18+
---
19+
20+
## Filesystems
21+
22+
### `/` (Root)
23+
24+
- **Format**: Ext4.
25+
26+
---

hosts/thor/secrets.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
_: {
2+
age.secrets = {
3+
tailscaleAuthKey.file = ../../secrets/tailscale-auth.age;
4+
};
5+
}

modules/disko/btrfs-subvolumes/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
assertions = [
1414
{
1515
assertion = config.my.disko.installDrive != "";
16-
message = "config.myDisko.installDrive cannot be empty.";
16+
message = "config.my.disko.installDrive cannot be empty.";
1717
}
1818
];
1919

modules/nixos/base/default.nix

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
}: {
88
options.my.nixos.base = {
99
enable = lib.mkEnableOption "base system configuration";
10+
editor = lib.mkOption {
11+
type = lib.types.package;
12+
description = "Default editor package";
13+
default = pkgs.neovim;
14+
};
1015
};
1116

1217
config = lib.mkIf config.my.nixos.base.enable {
@@ -26,7 +31,7 @@
2631
libnotify
2732
lm_sensors
2833
vim
29-
neovim
34+
config.my.nixos.base.editor
3035
];
3136

3237
variables = {
@@ -54,6 +59,13 @@
5459
git.enable = true;
5560
nh.enable = true;
5661
ssh.knownHosts = config.my.snippets.ssh.knownHosts;
62+
63+
nix-index-database.comma.enable = true;
64+
nix-index = {
65+
enable = true;
66+
enableFishIntegration = true;
67+
enableZshIntegration = true;
68+
};
5769
};
5870

5971
networking.networkmanager.enable = true;
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}: let
7+
cfg = config.my.nixos.services.audiobookshelf;
8+
in {
9+
options.my.nixos.services.audiobookshelf = {
10+
enable = lib.mkEnableOption "Enable the audiobookshelf service";
11+
12+
port = lib.mkOption {
13+
description = "The TCP port Audiobookshelf will listen on.";
14+
default = 8000;
15+
type = lib.types.port;
16+
};
17+
18+
tailscale = {
19+
enable = lib.mkOption {
20+
description = "Enable tailscale service";
21+
default = false;
22+
type = lib.types.bool;
23+
};
24+
25+
name = lib.mkOption {
26+
description = "Name of the audiobookshelf service";
27+
default = "audiobookshelf";
28+
type = lib.types.str;
29+
};
30+
};
31+
};
32+
33+
config = lib.mkIf config.my.nixos.services.audiobookshelf.enable {
34+
services = {
35+
audiobookshelf = {
36+
enable = true;
37+
port = 8555;
38+
openFirewall = true;
39+
};
40+
41+
# TODO: https://github.com/tailscale/tailscale/issues/18381
42+
# tailscale.serve.services.${cfg.tailscale.name}.https."443" = "https://localhost:${toString cfg.port}";
43+
};
44+
45+
systemd.services.audiobookshelf-tailscale-serve = lib.mkIf cfg.tailscale.enable {
46+
description = "Tailscale Service proxy for Audiobookshelf";
47+
wantedBy = ["multi-user.target"];
48+
after = [
49+
"audiobookshelf.service"
50+
"tailscaled.service"
51+
];
52+
53+
serviceConfig = {
54+
Type = "oneshot";
55+
RemainAfterExit = true;
56+
57+
ExecStart = "${pkgs.tailscale}/bin/tailscale serve \
58+
--service=svc:${cfg.tailscale.name} \
59+
--https=443 \
60+
http://localhost:${toString cfg.port}";
61+
ExecStop = "${pkgs.tailscale}/bin/tailscale serve clear \
62+
svc:${cfg.tailscale.name}";
63+
};
64+
};
65+
};
66+
}

0 commit comments

Comments
 (0)