Compare commits

..

1 Commits

Author SHA1 Message Date
1dcd3fe1a4 Update well-known delegation settings for Matrix 2022-10-23 10:54:47 +02:00
38 changed files with 644 additions and 1241 deletions

1
.dir-locals.el Normal file
View File

@@ -0,0 +1 @@
((nil . ((ssh-deploy-root-remote . "/ssh:zion:/home/coolneng/system"))))

View File

@@ -1,7 +0,0 @@
DIR=$(HOME)/Projects/zion
switch:
nixos-rebuild switch --no-reexec --target-host root@zion \
--build-host root@zion --flake path://$(DIR)#zion
.DEFAULT_GOAL := switch

View File

@@ -20,34 +20,39 @@
** Installation ** Installation
1. Download the sdcard image 1. Download the sdcard image
2. Use initial config file 2. Connect a keyboard to the Raspberry Pi and set the password
#+begin_src shell #+begin_src shell
cp install.nix configuration.nix passwd
sudo su
passwd
#+end_src #+end_src
The default user is nixos
3. Move the repo to the server and the agenix key 3. Move the repo to the server and the agenix key
#+begin_src shell #+begin_src shell
scp -r Projects/zion zion:/home/nixos/system scp -R Projects/zion zion:/home/nixos/system
scp .ssh/zion root@zion:/etc/ssh/id_ed25519 scp .ssh/zion root@zion:/etc/ssh/id_ed25519
#+end_src #+end_src
4. Mount the firmware partition 4. Increase the size of tmpfs
#+begin_src shell #+begin_src shell
mount /dev/mmcblk1p1 /boot sudo mount -o remount,size=4G /run/user/0
sudo mount -o remount,size=2G /run/user/1000
#+end_src #+end_src
5. Rebuild the system using Flakes 5. Rebuild the system using Flakes
#+begin_src shell #+begin_src shell
nix-shell -p git nix-shell -p git
sudo nixos-rebuild switch --flake /home/nixos/system#zion sudo nixos-rebuild switch --flake /home/nixos/system#zion --impure
#+end_src #+end_src
6. Restore the SQL databases 6. Restore the SQL databases
#+begin_src shell #+begin_src shell
gunzip -c /vault/backups/zion/databases/all.sql.gz | psql -U postgres psql -U postgres -f /vault/backups/zion/databases/all.sql
#+end_src #+end_src

View File

@@ -1,76 +1,39 @@
{ { config, inputs, pkgs, lib, ... }:
config,
inputs,
pkgs,
lib,
...
}:
with pkgs; with pkgs;
{ {
# Kernel configuration
boot = {
blacklistedKernelModules = [
"btusb"
"bluetooth"
];
kernelParams = [
"zfs.zfs_arc_max=8589934592"
"zfs.zfs_arc_min=1073741824"
];
supportedFilesystems = [ "zfs" ];
zfs = {
requestEncryptionCredentials = false;
extraPools = [ "vault" ];
};
};
# Secure boot using lanzaboote
boot.loader = {
efi.canTouchEfiVariables = true;
systemd-boot = {
enable = true;
configurationLimit = 50;
editor = false;
};
timeout = 3;
};
# Declare system packages # Declare system packages
environment.systemPackages = [ environment.systemPackages = [
libraspberrypi libraspberrypi
htop htop
neovim neovim
git git
inputs.agenix.packages.${config.nixpkgs.localSystem.system}.default inputs.agenix.defaultPackage.aarch64-linux
]; ];
# Add a swap file
swapDevices = [{
device = "/swapfile";
size = 4096;
}];
# Configure basic SSH access # Configure basic SSH access
services.openssh = { services.openssh = {
enable = true; enable = true;
settings = { permitRootLogin = "yes";
PermitRootLogin = "yes";
PasswordAuthentication = false;
};
}; };
# Cleanup tmp on startup # Cleanup tmp on startup
boot.tmp.cleanOnBoot = true; boot.cleanTmpDir = true;
# Create coolneng user # Create coolneng user
users.users.coolneng = { users.users.coolneng = {
isNormalUser = true; isNormalUser = true;
home = "/home/coolneng"; home = "/home/coolneng";
extraGroups = [ extraGroups = [ "wheel" "docker" ];
"wheel"
"docker"
];
openssh.authorizedKeys.keys = [ openssh.authorizedKeys.keys = [
# panacea
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFRqINHR7/zc+c3/PuR+NeSsBHXXzBiEtFWSK6QaxQTW coolneng@panacea" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFRqINHR7/zc+c3/PuR+NeSsBHXXzBiEtFWSK6QaxQTW coolneng@panacea"
# caravanserai
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIX0poiPhFLFh88fhpLFX7n1oCevVRyTxe9ZvGmjPq8n zion"
]; ];
shell = "${fish}/bin/fish"; shell = "${fish}/bin/fish";
}; };
@@ -85,6 +48,12 @@ with pkgs;
time.timeZone = "Europe/Brussels"; time.timeZone = "Europe/Brussels";
services.timesyncd.enable = true; services.timesyncd.enable = true;
# Enable ZFS support
boot.supportedFilesystems = [ "zfs" ];
# Don't import encrypted datasets
boot.zfs.requestEncryptionCredentials = false;
# Scrub zpool monthly # Scrub zpool monthly
services.zfs.autoScrub = { services.zfs.autoScrub = {
enable = true; enable = true;
@@ -95,12 +64,7 @@ with pkgs;
nix = { nix = {
settings = { settings = {
auto-optimise-store = true; auto-optimise-store = true;
trusted-users = [ experimental-features = [ "nix-command" "flakes" ];
"root"
"coolneng"
];
lazy-trees = true;
eval-cores = 2;
}; };
gc = { gc = {
automatic = true; automatic = true;
@@ -111,50 +75,37 @@ with pkgs;
keep-outputs = true keep-outputs = true
keep-derivations = true keep-derivations = true
gc-keep-outputs = true gc-keep-outputs = true
experimental-features = nix-command flakes
''; '';
}; };
# Use same version of nixpkgs for nix-shell # Use same version of nixpkgs for nix-shell
nix.nixPath = nix.nixPath = let path = toString ./.;
let in [ "nixpkgs=${inputs.nixpkgs}" "nixos-config=${path}/configuration.nix" ];
path = toString ./.;
in
[
"nixpkgs=${inputs.nixpkgs}"
"nixos-config=${path}/configuration.nix"
];
# Configure fish shell # Configure fish shell
programs.fish.enable = true; programs.fish.enable = true;
users.users.root = { users.users.root = {
shell = "${fish}/bin/fish"; shell = "${fish}/bin/fish";
openssh.authorizedKeys.keys = config.users.users.coolneng.openssh.authorizedKeys.keys; openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFRqINHR7/zc+c3/PuR+NeSsBHXXzBiEtFWSK6QaxQTW coolneng@panacea"
];
}; };
# Keep logs for a month # Keep logs for a week
services.journald.extraConfig = "MaxRetentionSec=4week"; services.journald.extraConfig = "MaxRetentionSec=1week";
# Increase inotify limits and maximum buffer size # Increase inotify limits
boot.kernel.sysctl = { boot.kernel.sysctl = { "fs.inotify.max_user_watches" = 204800; };
"fs.inotify.max_user_watches" = 204800;
"net.core.rmem_max" = 2500000;
"net.core.wmem_max" = 2500000;
};
# MOTD message # MOTD message
programs.fish.interactiveShellInit = "${./scripts/motd.sh}"; programs.fish.interactiveShellInit = "${./scripts/motd.sh}";
# NixOS version # NixOS version
system.stateVersion = "24.11"; system.stateVersion = "22.05";
# Specify secrets # Specify secrets
age = { age = {
secrets.wireguard = { secrets.wireguard.file = secrets/wireguard.age;
file = secrets/wireguard.age;
owner = "systemd-network";
group = "systemd-network";
};
secrets.syncthing.file = secrets/syncthing.age; secrets.syncthing.file = secrets/syncthing.age;
secrets.msmtp.file = secrets/msmtp.age; secrets.msmtp.file = secrets/msmtp.age;
secrets.gitea = { secrets.gitea = {
@@ -162,6 +113,7 @@ with pkgs;
owner = "gitea"; owner = "gitea";
group = "gitea"; group = "gitea";
}; };
secrets.ddclient.file = secrets/ddclient.age;
secrets.miniflux = { secrets.miniflux = {
file = secrets/miniflux.age; file = secrets/miniflux.age;
owner = "miniflux"; owner = "miniflux";
@@ -185,67 +137,19 @@ with pkgs;
}; };
secrets.telegram = { secrets.telegram = {
file = secrets/telegram.age; file = secrets/telegram.age;
owner = "matrix-as-telegram";
group = "matrix-as-telegram";
}; };
secrets.mqtt-sender = { identityPaths = [ "/home/coolneng/.ssh/id_ed25519" ];
file = secrets/mqtt-sender.age;
owner = "mosquitto";
group = "mosquitto";
};
secrets.mqtt-receiver = {
file = secrets/mqtt-receiver.age;
owner = "mosquitto";
group = "mosquitto";
};
secrets.facebook = {
file = secrets/facebook.age;
};
secrets.signal = {
file = secrets/signal.age;
};
secrets.inadyn-duckdns = {
file = secrets/inadyn-duckdns.age;
owner = "inadyn";
group = "inadyn";
};
secrets.inadyn-porkbun = {
file = secrets/inadyn-porkbun.age;
owner = "inadyn";
group = "inadyn";
};
secrets.inadyn-porkbun-secret = {
file = secrets/inadyn-porkbun-secret.age;
owner = "inadyn";
group = "inadyn";
};
secrets.acme-duckdns = {
file = secrets/acme-duckdns.age;
owner = "acme";
group = "nginx";
};
secrets.acme-porkbun = {
file = secrets/acme-porkbun.age;
owner = "acme";
group = "nginx";
};
secrets.microbin = {
file = secrets/microbin.age;
owner = "63026";
group = "63026";
};
secrets.readeck = {
file = secrets/readeck.age;
owner = "63026";
group = "63026";
};
identityPaths = [ "/etc/ssh/id_ed25519" ];
}; };
# Auto-upgrade the system # Auto-upgrade the system
system.autoUpgrade = { system.autoUpgrade = {
enable = true; enable = true;
allowReboot = true;
flake = "/home/coolneng/system"; flake = "/home/coolneng/system";
flags = [ flags = [
"--update-input"
"agenix"
"--update-input" "--update-input"
"nixpkgs" "nixpkgs"
"--commit-lock-file" "--commit-lock-file"
@@ -263,9 +167,6 @@ with pkgs;
}; };
}; };
# Disable man pages
documentation.man.enable = false;
# Import other configuration modules # Import other configuration modules
imports = [ imports = [
./modules/hardware-configuration.nix ./modules/hardware-configuration.nix
@@ -277,7 +178,7 @@ with pkgs;
./modules/periodic.nix ./modules/periodic.nix
./modules/communication.nix ./modules/communication.nix
./modules/information.nix ./modules/information.nix
./modules/containers.nix ./modules/device.nix
]; ];
} }

307
flake.lock generated
View File

@@ -2,106 +2,24 @@
"nodes": { "nodes": {
"agenix": { "agenix": {
"inputs": { "inputs": {
"darwin": "darwin",
"home-manager": "home-manager",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
],
"systems": "systems"
},
"locked": {
"lastModified": 1762618334,
"narHash": "sha256-wyT7Pl6tMFbFrs8Lk/TlEs81N6L+VSybPfiIgzU8lbQ=",
"owner": "ryantm",
"repo": "agenix",
"rev": "fcdea223397448d35d9b31f798479227e80183f6",
"type": "github"
},
"original": {
"owner": "ryantm",
"repo": "agenix",
"type": "github"
}
},
"darwin": {
"inputs": {
"nixpkgs": [
"agenix",
"nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1744478979, "lastModified": 1665870395,
"narHash": "sha256-dyN+teG9G82G+m+PX/aSAagkC+vUv0SgUw3XkPhQodQ=", "narHash": "sha256-Tsbqb27LDNxOoPLh0gw2hIb6L/6Ow/6lIBvqcHzEKBI=",
"owner": "lnl7", "owner": "ryantm",
"repo": "nix-darwin", "repo": "agenix",
"rev": "43975d782b418ebf4969e9ccba82466728c2851b", "rev": "a630400067c6d03c9b3e0455347dc8559db14288",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "lnl7", "owner": "ryantm",
"ref": "master", "repo": "agenix",
"repo": "nix-darwin",
"type": "github" "type": "github"
} }
}, },
"determinate": {
"inputs": {
"determinate-nixd-aarch64-darwin": "determinate-nixd-aarch64-darwin",
"determinate-nixd-aarch64-linux": "determinate-nixd-aarch64-linux",
"determinate-nixd-x86_64-linux": "determinate-nixd-x86_64-linux",
"nix": "nix",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1766177528,
"narHash": "sha256-Bl+p766mM7qNCZtMqmTz13RuUbOMKsFa+/vnGYoxgPk=",
"rev": "b159c082f0f9bdefa6c386189a13c5fa0734d8d8",
"revCount": 317,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/DeterminateSystems/determinate/3.15.0/019b3865-57a1-7d80-98c5-962fac29c404/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/DeterminateSystems/determinate/%2A"
}
},
"determinate-nixd-aarch64-darwin": {
"flake": false,
"locked": {
"narHash": "sha256-vDaEQ5T4eA7kEPREmm68IVWGR6zT0aDL5slZxA6dkSc=",
"type": "file",
"url": "https://install.determinate.systems/determinate-nixd/tag/v3.15.0/macOS"
},
"original": {
"type": "file",
"url": "https://install.determinate.systems/determinate-nixd/tag/v3.15.0/macOS"
}
},
"determinate-nixd-aarch64-linux": {
"flake": false,
"locked": {
"narHash": "sha256-Hf4JsIv5G3IR0Q0RHGLSNdmDzFv97sVQQKwzY6A0vV4=",
"type": "file",
"url": "https://install.determinate.systems/determinate-nixd/tag/v3.15.0/aarch64-linux"
},
"original": {
"type": "file",
"url": "https://install.determinate.systems/determinate-nixd/tag/v3.15.0/aarch64-linux"
}
},
"determinate-nixd-x86_64-linux": {
"flake": false,
"locked": {
"narHash": "sha256-J+J4E02XpEl0ZkpzMbUmGCf6S4yk0gYCYmiGzZ058ik=",
"type": "file",
"url": "https://install.determinate.systems/determinate-nixd/tag/v3.15.0/x86_64-linux"
},
"original": {
"type": "file",
"url": "https://install.determinate.systems/determinate-nixd/tag/v3.15.0/x86_64-linux"
}
},
"devshell": { "devshell": {
"locked": { "locked": {
"lastModified": 1642188268, "lastModified": 1642188268,
@@ -118,22 +36,6 @@
} }
}, },
"flake-compat": { "flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_2": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1641205782, "lastModified": 1641205782,
@@ -149,110 +51,21 @@
"type": "github" "type": "github"
} }
}, },
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"determinate",
"nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1748821116,
"narHash": "sha256-F82+gS044J1APL0n4hH50GYdPRv/5JWm34oCJYmVKdE=",
"rev": "49f0870db23e8c1ca0b5259734a02cd9e1e371a1",
"revCount": 377,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/hercules-ci/flake-parts/0.1.377%2Brev-49f0870db23e8c1ca0b5259734a02cd9e1e371a1/01972f28-554a-73f8-91f4-d488cc502f08/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/hercules-ci/flake-parts/0.1"
}
},
"git-hooks-nix": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": [
"determinate",
"nix"
],
"nixpkgs": [
"determinate",
"nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1747372754,
"narHash": "sha256-2Y53NGIX2vxfie1rOW0Qb86vjRZ7ngizoo+bnXU9D9k=",
"rev": "80479b6ec16fefd9c1db3ea13aeb038c60530f46",
"revCount": 1026,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/cachix/git-hooks.nix/0.1.1026%2Brev-80479b6ec16fefd9c1db3ea13aeb038c60530f46/0196d79a-1b35-7b8e-a021-c894fb62163d/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/cachix/git-hooks.nix/0.1.941"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"agenix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1745494811,
"narHash": "sha256-YZCh2o9Ua1n9uCvrvi5pRxtuVNml8X2a03qIFfRKpFs=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "abfad3d2958c9e6300a883bd443512c55dfeb1be",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nix": {
"inputs": {
"flake-parts": "flake-parts",
"git-hooks-nix": "git-hooks-nix",
"nixpkgs": "nixpkgs",
"nixpkgs-23-11": "nixpkgs-23-11",
"nixpkgs-regression": "nixpkgs-regression"
},
"locked": {
"lastModified": 1766174426,
"narHash": "sha256-0ZofAQZNgg5nfIKsVb7g4It6ufmIyLtfFRPOf+6WRkk=",
"rev": "15d6091194b5b90d292e8d6283db77f09c303b1e",
"revCount": 24285,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/DeterminateSystems/nix-src/3.15.0/019b3854-cca6-7298-a91c-0fd8551a7270/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/DeterminateSystems/nix-src/%2A"
}
},
"nix-matrix-appservices": { "nix-matrix-appservices": {
"inputs": { "inputs": {
"devshell": "devshell", "devshell": "devshell",
"flake-compat": "flake-compat_2", "flake-compat": "flake-compat",
"nixlib": "nixlib", "nixlib": "nixlib",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1683490239, "lastModified": 1650783069,
"narHash": "sha256-QKzpvl2XrqbobWq/I/smDa9hEniwctjJybXPVILHP0w=", "narHash": "sha256-mcjuOAXVC9zZ6f5Uh67uEpiZzaTMFP6ZvW8pqanesLM=",
"owner": "coffeetables", "owner": "coffeetables",
"repo": "nix-matrix-appservices", "repo": "nix-matrix-appservices",
"rev": "e795d2fbc61da45d49802bb3e8f8d0c70ddc1e68", "rev": "5483c1b3f73c81a4533a1d7a8cc80486ca9b5c14",
"type": "gitlab" "type": "gitlab"
}, },
"original": { "original": {
@@ -278,118 +91,40 @@
}, },
"nixos-hardware": { "nixos-hardware": {
"locked": { "locked": {
"lastModified": 1764440730, "lastModified": 1656933710,
"narHash": "sha256-ZlJTNLUKQRANlLDomuRWLBCH5792x+6XUJ4YdFRjtO4=", "narHash": "sha256-SVG8EqY1OTJWBRY4hpct2ZR2Rk0L8hCFkug3m0ABoZE=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixos-hardware", "repo": "nixos-hardware",
"rev": "9154f4569b6cdfd3c595851a6ba51bfaa472d9f3", "rev": "3bf48d3587d3f34f745a19ebc968b002ef5b5c5a",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "master",
"repo": "nixos-hardware", "repo": "nixos-hardware",
"type": "github" "type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1761597516, "lastModified": 1666377499,
"narHash": "sha256-wxX7u6D2rpkJLWkZ2E932SIvDJW8+ON/0Yy8+a5vsDU=", "narHash": "sha256-dZZCGvWcxc7oGnUgFVf0UeNHsJ4VhkTM0v5JRe8EwR8=",
"rev": "daf6dc47aa4b44791372d6139ab7b25269184d55",
"revCount": 811874,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2505.811874%2Brev-daf6dc47aa4b44791372d6139ab7b25269184d55/019a3494-3498-707e-9086-1fb81badc7fe/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/NixOS/nixpkgs/0.2505"
}
},
"nixpkgs-23-11": {
"locked": {
"lastModified": 1717159533,
"narHash": "sha256-oamiKNfr2MS6yH64rUn99mIZjc45nGJlj9eGth/3Xuw=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446", "rev": "301aada7a64812853f2e2634a530ef5d34505048",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "id": "nixpkgs",
"repo": "nixpkgs", "ref": "nixos-unstable",
"rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446", "type": "indirect"
"type": "github"
}
},
"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_2": {
"locked": {
"lastModified": 1765772535,
"narHash": "sha256-aq+dQoaPONOSjtFIBnAXseDm9TUhIbe215TPmkfMYww=",
"rev": "09b8fda8959d761445f12b55f380d90375a1d6bb",
"revCount": 911985,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/DeterminateSystems/nixpkgs-weekly/0.1.911985%2Brev-09b8fda8959d761445f12b55f380d90375a1d6bb/019b25ab-7c11-79e0-a0b0-c94d455b7190/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/DeterminateSystems/nixpkgs-weekly/0.1"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1766201043,
"narHash": "sha256-eplAP+rorKKd0gNjV3rA6+0WMzb1X1i16F5m5pASnjA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b3aad468604d3e488d627c0b43984eb60e75e782",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-25.11",
"repo": "nixpkgs",
"type": "github"
} }
}, },
"root": { "root": {
"inputs": { "inputs": {
"agenix": "agenix", "agenix": "agenix",
"determinate": "determinate",
"nix-matrix-appservices": "nix-matrix-appservices", "nix-matrix-appservices": "nix-matrix-appservices",
"nixos-hardware": "nixos-hardware", "nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs_3" "nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
} }
} }
}, },

View File

@@ -1,49 +1,41 @@
{ {
description = "System configuration for zion"; description = "System configuration for zion";
nixConfig = {
extra-substituters = "https://install.determinate.systems";
extra-trusted-public-keys = ''
cache.flakehub.com-3:hJuILl5sVK4iKm86JzgdXW12Y2Hwd5G07qKtHTOcDCM=
'';
};
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; nixpkgs.url = "nixpkgs/nixos-unstable";
determinate.url = "https://flakehub.com/f/DeterminateSystems/determinate/*";
agenix = { agenix = {
url = "github:ryantm/agenix"; url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
nixos-hardware.url = "github:NixOS/nixos-hardware/master"; nixos-hardware = {
url = "github:NixOS/nixos-hardware";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-matrix-appservices = { nix-matrix-appservices = {
url = "gitlab:coffeetables/nix-matrix-appservices"; url = "gitlab:coffeetables/nix-matrix-appservices";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };
outputs = outputs = { self, nixpkgs, agenix, nixos-hardware, nix-matrix-appservices, ...
{ self, nixpkgs, ... }@inputs: }@inputs:
let let
system = "x86_64-linux"; system = "aarch64-linux";
pkgs = import pkgs { inherit system; }; pkgs = import pkgs { inherit system; };
lib = nixpkgs.lib; lib = nixpkgs.lib;
in in {
{
nixosConfigurations.zion = lib.nixosSystem { nixosConfigurations.zion = lib.nixosSystem {
inherit system; inherit system;
modules = [ modules = [
(import ./configuration.nix) (import ./configuration.nix)
inputs.agenix.nixosModules.age agenix.nixosModules.age
inputs.nixos-hardware.nixosModules.aoostar-r1-n100 nixos-hardware.nixosModules.raspberry-pi-4
inputs.determinate.nixosModules.default nix-matrix-appservices.nixosModule
]; ];
specialArgs = { specialArgs = { inherit inputs; };
inherit inputs;
};
}; };
}; };

View File

@@ -1,23 +1,11 @@
{ { config, lib, pkgs, ... }:
config,
lib,
pkgs,
...
}:
with pkgs; with pkgs;
# NOTE Reference the environment variable set in the corresponding agenix secret # NOTE Reference the environment variable set in the corresponding agenix secret
let let database.connection_string = "$DB_STRING";
database = {
connection_string = "$DB_STRING";
max_open_conns = 100;
max_idle_conns = 5;
conn_max_lifetime = -1;
};
in in {
{
# Matrix server configuration # Matrix server configuration
services.dendrite = { services.dendrite = {
enable = true; enable = true;
@@ -29,37 +17,26 @@ in
server_name = "coolneng.duckdns.org"; server_name = "coolneng.duckdns.org";
private_key = config.age.secrets.dendrite.path; private_key = config.age.secrets.dendrite.path;
inherit database; inherit database;
dns_cache.enabled = true;
}; };
# HACK Inherit postgres connection string for the rest of the DBs # HACK Inherit postgres connection string for the rest of the DBs
app_service_api = { app_service_api = {
inherit database; inherit database;
}; config_files = [
media_api = { "/var/lib/matrix-as-facebook/facebook-registration.yaml"
inherit database; "/var/lib/matrix-as-signal/signal-registration.yaml"
}; "/var/lib/matrix-as-telegram/telegram-registration.yaml"
room_server = {
inherit database;
};
push_server = {
inherit database;
};
mscs = {
inherit database;
mscs = [
"msc2836"
"msc2946"
]; ];
}; };
sync_api = { media_api = { inherit database; };
inherit database; room_server = { inherit database; };
}; push_server = { inherit database; };
key_server = { mscs = {
inherit database;
};
federation_api = {
inherit database; inherit database;
mscs = [ "msc2836" "msc2946" ];
}; };
sync_api = { inherit database; };
key_server = { inherit database; };
federation_api = { inherit database; };
user_api = { user_api = {
account_database = database; account_database = database;
device_database = database; device_database = database;
@@ -67,37 +44,60 @@ in
}; };
}; };
# Start dendrite after config files are mounted # Matrix bridges
systemd.services.dendrite.unitConfig.RequiresMountsFor = [ services.matrix-appservices = {
/var/lib/matrix-as-facebook homeserver = "dendrite";
/var/lib/matrix-as-signal homeserverDomain = "coolneng.duckdns.org";
/var/lib/matrix-as-telegram homeserverURL = "https://matrix.coolneng.duckdns.org";
]; addRegistrationFiles = true;
services = {
telegram = {
port = 8118;
format = "mautrix-python";
package = mautrix-telegram;
serviceConfig.EnvironmentFile = config.age.secrets.telegram.path;
settings = {
telegram = {
api_id = "$API_ID";
api_hash = "$API_HASH";
};
bridge = {
permissions."@coolneng:coolneng.duckdns.org" = "admin";
backfill.normal_groups = true;
};
};
};
facebook = {
port = 8228;
format = "mautrix-python";
package = mautrix-facebook;
};
signal = {
port = 8338;
format = "mautrix-python";
package = mautrix-signal;
serviceConfig = {
StateDirectory = [ "matrix-as-signal" "signald" ];
JoinNamespaceOf = "signald.service";
SupplementaryGroups = [ "signald" ];
};
settings.signal = {
socket_path = config.services.signald.socketPath;
outgoing_attachment_dir = "/var/lib/signald/tmp";
};
};
};
};
# MQTT configuration # Additional settings for mautrix-signal
services.mosquitto = { services.signald = {
enable = true; enable = true;
dataDir = "/vault/mosquitto"; user = "matrix-as-signal";
logType = [
"websockets"
"error"
"warning"
"notice"
"information"
];
logDest = [ "syslog" ];
listeners = [
{
users.homeostasis = {
acl = [ "write #" ];
hashedPasswordFile = config.age.secrets.mqtt-sender.path;
}; };
users.prometheus = { systemd.services.matrix-as-signal = {
acl = [ "read #" ]; requires = [ "signald.service" ];
hashedPasswordFile = config.age.secrets.mqtt-receiver.path; after = [ "signald.service" ];
}; path = [ ffmpeg ];
}
];
}; };
} }

View File

@@ -1,68 +0,0 @@
{
config,
lib,
pkgs,
...
}:
{
# Podman setup
virtualisation = {
containers.enable = true;
podman = {
enable = true;
dockerCompat = true;
extraPackages = with pkgs; [ zfs ];
};
oci-containers = {
backend = "podman";
containers = {
# Openbooks configuration
openbooks = {
image = "evanbuss/openbooks@sha256:4fa9188885368c2303b7dc527d48b3159aaa7022010e29b3ed96842018793590";
ports = [ "127.0.0.1:9000:80" ];
cmd = [
"--name"
"bradar"
"--searchbot"
"searchook"
"--persist"
"--tls"
"false"
];
};
# Prometheus MQTT integration
mqtt2prometheus = {
image = "hikhvar/mqtt2prometheus@sha256:8e166d36feaa5ddcad703eef3a2c5167a154d6eef306a40fe6509861580c0714";
ports = [ "127.0.0.1:9641:9641" ];
volumes = [ "/vault/mqtt2prometheus/config.yaml:/config.yaml" ];
};
# Podcast synchronization
opodsync = {
image = "ganeshlab/opodsync@sha256:32626b732fe38687a5dfd703d515136e413c4b16f286b38656718ad03f0d94c1";
ports = [ "127.0.0.1:9090:8080" ];
volumes = [ "/vault/opodsync:/var/www/server/data" ];
};
# Photo gallery
pigallery2 = {
image = "bpatrik/pigallery2@sha256:c936e4504cfe7158198542a8db794b24afb0301155d89e911f13bd04e0b406c2";
ports = [ "127.0.0.1:9191:80" ];
volumes = [
"/vault/pigallery2/config:/app/data/config"
"/vault/pigallery2/db:/app/data/db"
"/vault/pigallery2/tmp:/app/data/tmp"
"/vault/syncthing/Photos:/app/data/images"
];
cmd = [
"-e"
"NODE_ENV=production"
];
};
};
};
};
# Start services after ZFS mount
systemd.services.podman-mqtt2prometheus.unitConfig.RequiresMountsFor = [ /vault/mqtt2prometheus ];
}

View File

@@ -1,10 +1,4 @@
{ { config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
{
# Syncthing configuration # Syncthing configuration
services.syncthing = { services.syncthing = {
@@ -13,54 +7,39 @@
guiAddress = "0.0.0.0:8384"; guiAddress = "0.0.0.0:8384";
dataDir = "/vault/syncthing"; dataDir = "/vault/syncthing";
key = config.age.secrets.syncthing.path; key = config.age.secrets.syncthing.path;
settings = {
extraOptions.options = {
maxFolderConcurrency = 4;
progressUpdateIntervalS = -1;
};
devices = { devices = {
panacea.id = "VEGVHKF-P4FT3BD-4T3ML7J-65URQOU-3XKNMI5-6LGWSCI-BIQZOUE-RKQ6PQX"; panacea.id =
caravanserai.id = "XQAXYEU-FWLAFZM-GTZYDGH-AIRBEXI-4CZD365-JUBTHDA-GOXXOYV-E5LEYQE"; "NF4SYEJ-RSGPDEF-CDEYC3A-JWZMKNC-KG4FVQP-CZ5HRFY-XM22BZD-N7B6VAH";
caravanserai.id =
"P6BJYCN-LWMB7HN-5JLNYM7-VHCG2S2-IC6YA3C-DOWMW7T-PX7GC3S-3BAZUAS";
}; };
folders = { folders = {
Documents = { Documents = {
id = "wusdj-bfjkr"; id = "wusdj-bfjkr";
type = "receiveonly"; type = "receiveonly";
path = "/vault/syncthing/Documents"; path = "/vault/syncthing/Documents";
devices = [ devices = [ "panacea" "caravanserai" ];
"panacea"
"caravanserai"
];
}; };
Notes = { Notes = {
id = "kafhz-bfmzm"; id = "kafhz-bfmzm";
type = "receiveonly"; type = "receiveonly";
path = "/vault/syncthing/Notes"; path = "/vault/syncthing/Notes";
devices = [ devices = [ "panacea" "caravanserai" ];
"panacea"
"caravanserai"
];
}; };
Music = { Music = {
id = "2aqt7-vpprc"; id = "2aqt7-vpprc";
type = "receiveonly"; type = "receiveonly";
path = "/vault/syncthing/Music"; path = "/vault/syncthing/Music";
devices = [ devices = [ "panacea" "caravanserai" ];
"panacea"
"caravanserai"
];
}; };
Photos = { Photos = {
id = "mjibc-ustcg"; id = "mjibc-ustcg";
type = "receiveonly"; type = "receiveonly";
path = "/vault/syncthing/Photos"; path = "/vault/syncthing/Photos";
devices = [ devices = [ "panacea" "caravanserai" ];
"panacea"
"caravanserai"
];
}; };
Projects = { Projects = {
@@ -74,41 +53,21 @@
id = "m2007j20cg_vc7r-photos"; id = "m2007j20cg_vc7r-photos";
type = "receiveonly"; type = "receiveonly";
path = "/vault/syncthing/Photos/Phone"; path = "/vault/syncthing/Photos/Phone";
devices = [ devices = [ "panacea" "caravanserai" ];
"panacea"
"caravanserai"
];
}; };
Files = { Files = {
id = "tsk52-u6rbk"; id = "tsk52-u6rbk";
type = "receiveonly"; type = "receiveonly";
path = "/vault/syncthing/Files"; path = "/vault/syncthing/Files";
devices = [ devices = [ "panacea" "caravanserai" ];
"panacea"
"caravanserai"
];
}; };
Phone-screenshots = { Phone-screenshots = {
id = "pp70r-pbr70"; id = "pp70r-pbr70";
type = "receiveonly"; type = "receiveonly";
path = "/vault/syncthing/Photos/Phone-screenshots"; path = "/vault/syncthing/Photos/Phone-screenshots";
devices = [ devices = [ "panacea" "caravanserai" ];
"panacea"
"caravanserai"
];
};
Audio = {
id = "tarrs-5mxck";
type = "receiveonly";
path = "/vault/syncthing/Audio";
devices = [
"panacea"
"caravanserai"
];
};
}; };
}; };
}; };
@@ -138,8 +97,4 @@
monthly = 12; monthly = 12;
}; };
# Start services after ZFS mount
systemd.services.syncthing.unitConfig.RequiresMountsFor = [ /vault/syncthing ];
systemd.services.radicale.unitConfig.RequiresMountsFor = [ /vault/radicale ];
} }

39
modules/device.nix Normal file
View File

@@ -0,0 +1,39 @@
{ config, lib, pkgs, ... }:
with pkgs;
{
# A bunch of boot parameters needed for optimal runtime on RPi 4B
boot.kernelPackages = linuxPackages_rpi4;
boot.kernelParams = [
"zfs.zfs_arc_max=134217728"
"console=TTYAMA0,115200"
"console=tty1"
"8250.nr_uarts=1"
"iomem=relaxed"
"strict-devmem=0"
];
# Enable SATA-HAT GPIO features
boot.loader = {
grub.enable = false;
generic-extlinux-compatible.enable = lib.mkForce false;
};
boot.loader.raspberryPi = {
enable = true;
version = 4;
firmwareConfig = ''
iomem=relaxed
strict-devmem=0
dtoverlay=w1-gpio
'';
};
boot.kernelModules = [ "pwm_bcm2835" "w1-gpio" "w1-therm" ];
# Load PWM hardware timers
hardware.raspberry-pi."4".pwm0.enable = true;
# Enable I2C
hardware.raspberry-pi."4".i2c1.enable = true;
}

View File

@@ -1,35 +1,21 @@
{ { config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
{
# Set up Gitea with LFS support # Set up Gitea with LFS support
services.gitea = { services.gitea = {
enable = true; enable = true;
domain = "git.coolneng.duckdns.org";
rootUrl = "https://git.coolneng.duckdns.org";
database = { database = {
type = "postgres"; type = "postgres";
passwordFile = config.age.secrets.gitea.path; passwordFile = config.age.secrets.gitea.path;
}; };
repositoryRoot = "/vault/git"; repositoryRoot = "/vault/git";
appName = "Gitea"; appName = "Gitea";
lfs = { lfs.enable = true;
enable = true;
contentDir = "${config.services.gitea.repositoryRoot}/data/lfs";
};
settings = { settings = {
server = { ui.DEFAULT_THEME = "arc-green";
DISABLE_SSH = true;
DOMAIN = "git.psydnd.org";
ROOT_URL = "https://git.psydnd.org";
};
service.DISABLE_REGISTRATION = true;
session.COOKIE_SECURE = true; session.COOKIE_SECURE = true;
actions.ENABLED = true; service.DISABLE_REGISTRATION = true;
server.DISABLE_SSH = true;
}; };
}; };
# Start services after ZFS mount
systemd.services.gitea.unitConfig.RequiresMountsFor = [ /vault/git ];
} }

View File

@@ -4,55 +4,69 @@
{ config, lib, pkgs, modulesPath, ... }: { config, lib, pkgs, modulesPath, ... }:
{ {
imports = imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "sd_mod" ]; boot.initrd.availableKernelModules = [ ];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ]; boot.kernelModules = [ ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems."/" = fileSystems."/" = {
{ device = "sysion/stateful/root"; device = "/dev/disk/by-uuid/44444444-4444-4444-8888-888888888888";
fsType = "zfs"; fsType = "ext4";
}; };
fileSystems."/nix" = fileSystems."/boot" = {
{ device = "sysion/ephemeral/nix"; device = "/dev/disk/by-uuid/2178-694E";
fsType = "zfs";
};
fileSystems."/tmp" =
{ device = "sysion/ephemeral/tmp";
fsType = "zfs";
};
fileSystems."/home/coolneng" =
{ device = "sysion/stateful/home";
fsType = "zfs";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/C332-4650";
fsType = "vfat"; fsType = "vfat";
options = [ "fmask=0022" "dmask=0022" ];
}; };
swapDevices = fileSystems."/vault" = {
[ { device = "/dev/disk/by-uuid/d388feef-a651-4dae-8161-f666136de240"; } device = "vault";
]; fsType = "zfs";
};
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking fileSystems."/vault/git" = {
# (the default) this is the recommended approach. When using systemd-networkd it's device = "vault/git";
# still possible to use this option, but it's recommended to use it in conjunction fsType = "zfs";
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`. };
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp2s0.useDHCP = lib.mkDefault true;
# networking.interfaces.enp3s0.useDHCP = lib.mkDefault true;
# networking.interfaces.wg0.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp4s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; fileSystems."/vault/nextcloud" = {
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; device = "vault/nextcloud";
fsType = "zfs";
};
fileSystems."/vault/syncthing" = {
device = "vault/syncthing";
fsType = "zfs";
};
fileSystems."/vault/backups" = {
device = "vault/backups";
fsType = "zfs";
};
fileSystems."/vault/backups/zion" = {
device = "vault/backups/zion";
fsType = "zfs";
};
fileSystems."/vault/backups/zion/databases" = {
device = "vault/backups/zion/databases";
fsType = "zfs";
};
fileSystems."/vault/backups/monolith" = {
device = "vault/backups/monolith";
fsType = "zfs";
};
fileSystems."/vault/radicale" = {
device = "vault/radicale";
fsType = "zfs";
};
swapDevices = [ ];
powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand";
} }

View File

@@ -1,44 +1,41 @@
{ { config, lib, pkgs, ... }:
config,
lib,
pkgs,
...
}:
{ {
# Miniflux configuration # Miniflux configuration
services.miniflux = { services.miniflux = {
enable = true; enable = true;
adminCredentialsFile = config.age.secrets.miniflux.path; adminCredentialsFile = config.age.secrets.miniflux.path;
config = {
BASE_URL = "https://rss.coolneng.duckdns.org";
RUN_MIGRATIONS = "1";
DISABLE_HSTS = "1";
};
}; };
# Microbin configuration # Php-fpm pool for Wallabag
services.microbin = { services.phpfpm.pools.wallabag = {
enable = true; user = "nginx";
passwordFile = config.age.secrets.microbin.path; group = "nginx";
settings = { settings = {
MICROBIN_PORT = 9091; "listen.owner" = config.services.nginx.user;
MICROBIN_PUBLIC_PATH = "https://bin.psydnd.org"; "listen.group" = config.services.nginx.group;
MICROBIN_QR = true; "listen.mode" = 600;
MICROBIN_WIDE = true; "pm" = "ondemand";
"pm.max_children " = 4;
"pm.max_requests" = 32;
"env[WALLABAG_DATA]" = "/var/lib/wallabag";
}; };
phpEnv."PATH" = lib.makeBinPath [ pkgs.php ];
}; };
# Readeck configuration # Set environment variable pointing to wallabag configuration directory
services.readeck = { environment.variables.WALLABAG_DATA = "/var/lib/wallabag";
enable = true;
settings = {
server = {
host = "127.0.0.1";
port = 9092;
allowed_hosts = [ "read.psydnd.org" ];
trusted_proxies = [ "127.0.0.1" ];
environmentFile = config.age.secrets.readeck.path;
};
};
};
# NOTE Load credentials using environment variables
systemd.services.readeck.serviceConfig.EnvironmentFile = config.age.secrets.readeck.path;
# Openbooks configuration
virtualisation.oci-containers.containers = {
openbooks = {
image = "evanbuss/openbooks:latest";
ports = [ "127.0.0.1:9000:80" ];
};
};
} }

View File

@@ -1,9 +1,4 @@
{ { config, lib, pkgs, ... }:
config,
lib,
pkgs,
...
}:
with pkgs; with pkgs;
@@ -47,46 +42,4 @@ with pkgs;
}; };
}; };
# Metrics collection
services.prometheus = {
enable = true;
port = 9001;
retentionTime = "10y";
extraFlags = [ "--web.enable-admin-api" ];
exporters = {
node = {
enable = true;
enabledCollectors = [ "systemd" ];
port = 9002;
};
postgres.enable = true;
smartctl.enable = true;
};
scrapeConfigs = [
{
job_name = "zion";
static_configs = [
{
targets = [
"localhost:${toString config.services.prometheus.exporters.node.port}"
"localhost:${toString config.services.prometheus.exporters.postgres.port}"
"localhost:${toString config.services.prometheus.exporters.smartctl.port}"
"localhost:9641" # MQTT2Prometheus
];
}
];
}
];
};
# Grafana configuration
services.grafana = {
enable = true;
settings.server = {
domain = "grafana.psydnd.org";
http_port = 9009;
http_addr = "127.0.0.1";
};
};
} }

View File

@@ -1,61 +1,47 @@
{ { config, pkgs, lib, ... }:
config,
pkgs,
lib,
...
}:
let let wireguard_port = 1194;
wireguard_port = 1194;
in in {
{ # Assign a static IP
# Enable systemd-networkd
networking = { networking = {
hostName = "zion"; hostName = "zion";
hostId = "760bfad7"; hostId = "4e74ea68";
interfaces.eth0 = {
useDHCP = false; useDHCP = false;
useNetworkd = true; ipv4.addresses = [{
dhcpcd.enable = false; address = "192.168.13.2";
prefixLength = 24;
}];
};
defaultGateway = {
address = "192.168.13.1";
interface = "eth0";
};
nameservers = [ "51.158.108.203" "195.10.195.195" ];
enableIPv6 = false;
}; };
systemd.network.wait-online.enable = false;
# Assign a static IP # Enable zeroconf
systemd.network.networks."24-home" = { services.avahi = {
name = "enp2s0"; enable = true;
matchConfig.Name = "enp2s0"; nssmdns = true;
address = [ "192.168.128.2/23" ]; publish = {
gateway = [ "192.168.128.1" ]; enable = true;
dns = [ userServices = true;
"127.0.0.1" domain = true;
"::1" workstation = true;
]; };
networkConfig.DNSSEC = "no"; reflector = true;
}; };
# Dynamic DNS configuration # Dynamic DNS configuration
services.inadyn = { services.ddclient = {
enable = true; enable = true;
interval = "*:0/30"; quiet = true;
settings.provider."duckdns" = { protocol = "duckdns";
hostname = "coolneng.duckdns.org"; domains = [ "coolneng.duckdns.org" ];
include = config.age.secrets.inadyn-duckdns.path; passwordFile = config.age.secrets.ddclient.path;
};
};
# Dynamic DNS configuration for Porkbun
# NOTE Temporary workaround until Inadyn fixes the Porkbun module
services.oink = {
enable = true;
apiKeyFile = config.age.secrets.inadyn-porkbun.path;
secretApiKeyFile = config.age.secrets.inadyn-porkbun-secret.path;
settings.interval = 1800;
domains = [
{
domain = "psydnd.org";
subdomain = "";
}
];
}; };
# Firewall configuration # Firewall configuration
@@ -65,125 +51,64 @@ in
443 # HTTPS 443 # HTTPS
53 # DNS 53 # DNS
8448 # Matrix 8448 # Matrix
1883 # MQTT
]; ];
allowedUDPPorts = [ allowedUDPPorts = [
wireguard_port # Wireguard wireguard_port # Wireguard
53 # DNS 53 # DNS
]; ];
extraCommands = '' extraCommands = ''
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o ${ iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
config.systemd.network.networks."24-home".name
} -j MASQUERADE
ip6tables -t nat -A POSTROUTING -s fd00::0/128 -o ${
config.systemd.network.networks."24-home".name
} -j MASQUERADE
''; '';
}; };
# Enable NAT for wireguard
networking.nat = {
enable = true;
externalInterface = "eth0";
internalInterfaces = [ "wg0" ];
};
# Wireguard setup # Wireguard setup
systemd.network.netdevs."wg0" = { networking.wireguard.interfaces = {
netdevConfig = { wg0 = {
Kind = "wireguard"; ips = [ "10.8.0.1/24" ];
Name = "wg0"; listenPort = wireguard_port;
}; privateKeyFile = config.age.secrets.wireguard.path;
wireguardConfig = { peers = [
ListenPort = wireguard_port;
PrivateKeyFile = config.age.secrets.wireguard.path;
};
wireguardPeers = [
# panacea # panacea
{ {
PublicKey = "XMkTztU2Y8hw6Fu/2o4Gszij+EmNacvFMXuZyHS1n38="; publicKey = "XMkTztU2Y8hw6Fu/2o4Gszij+EmNacvFMXuZyHS1n38=";
AllowedIPs = [ allowedIPs = [ "10.8.0.2/32" ];
"10.8.0.2/32"
"fd00::2/128"
];
} }
# caravanserai # caravanserai
{ {
PublicKey = "mCsTj09H7lfDDs8vMQkJOlItHtHQ6MPUyfGO5ZjBbVs="; publicKey = "eFykHmnMALRUluApRfSM32Xw80kTNo7yUsxs47URkX4=";
AllowedIPs = [ allowedIPs = [ "10.8.0.3/32" ];
"10.8.0.3/32"
"fd00::3/128"
];
}
# kathreftis
{
PublicKey = "qfHtv6LSZjtxvH46d8pysr+/yPo2tV9cZumgIpxBNF4=";
AllowedIPs = [
"10.8.0.4/32"
"fd00::4/128"
];
} }
]; ];
}; };
systemd.network.networks."wg0" = {
matchConfig.Name = "wg0";
networkConfig = {
Address = [
"10.8.0.1/24"
"fd00::1/128"
];
IPv4Forwarding = true;
IPv6Forwarding = true;
};
};
# Disable systemd-resolved DNS stub
services.resolved = {
enable = true;
llmnr = "false";
extraConfig = ''
MulticastDNS=yes
DNSStubListener=no
'';
}; };
# DNS server with ad-block # DNS server with ad-block
services.dnsmasq = { services.dnsmasq = {
enable = true; enable = true;
settings = { servers = config.networking.nameservers;
domain-needed = true; extraConfig = ''
bogus-priv = true; domain-needed
no-resolv = true; bogus-priv
no-resolv
listen-address = [ listen-address=127.0.0.1,192.168.13.2,10.8.0.1
"127.0.0.1" bind-interfaces
"192.168.128.2"
"10.8.0.1"
"::1"
"fd00::1"
];
bind-interfaces = true;
server = [ "127.0.0.1#43" ];
cache-size = 10000; cache-size=10000
local-ttl = 300; local-ttl=300
conf-file = "${pkgs.dnsmasq}/share/dnsmasq/trust-anchors.conf"; conf-file=/var/lib/dnsmasq/dnsmasq.blacklist.txt
dnssec = false;
address = "/psydnd.org/192.168.128.2";
};
};
# Encrypted DNS address=/coolneng.duckdns.org/192.168.13.2
services.dnscrypt-proxy = { '';
enable = true;
upstreamDefaults = true;
settings = {
listen_addresses = [
"127.0.0.1:43"
"[::1]:43"
];
sources.public-resolvers = {
urls = [ "https://download.dnscrypt.info/resolvers-list/v3/public-resolvers.md" ];
cache_file = "/var/lib/dnscrypt-proxy2/public-resolvers.md";
minisign_key = "RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3";
};
blocked_names.blocked_names_file = "/var/lib/dnscrypt-proxy/blocklist.txt";
};
}; };
} }

View File

@@ -1,16 +1,10 @@
{ { config, lib, pkgs, ... }:
config,
lib,
pkgs,
...
}:
let let
stateDir = "/var/lib/dnscrypt-proxy"; stateDir = "/var/lib/dnsmasq";
blocklist = "${stateDir}/blocklist.txt"; blocklist = "${stateDir}/dnsmasq.blacklist.txt";
in in {
{
# PostgreSQL daily backups # PostgreSQL daily backups
services.postgresqlBackup = { services.postgresqlBackup = {
enable = true; enable = true;
@@ -20,21 +14,69 @@ in
}; };
# Fetch hosts-blocklists daily # Fetch hosts-blocklists daily
# TODO Download the list if the file doesn't exist the first time
systemd.services.download-dns-blocklist = { systemd.services.download-dns-blocklist = {
description = "Download hosts-blocklists"; description = "Download hosts-blocklists";
wantedBy = [ "default.target" ]; wantedBy = [ "default.target" ];
path = with pkgs; [ path = with pkgs; [ curl coreutils ];
curl
coreutils
];
script = '' script = ''
curl -L https://download.dnscrypt.info/blacklists/domains/mybase.txt -o ${blocklist} curl -L https://github.com/notracking/hosts-blocklists/raw/master/dnsmasq/dnsmasq.blacklist.txt -o ${blocklist}
sed "/cainiao/d" -i ${blocklist}
''; '';
serviceConfig.Type = "oneshot"; serviceConfig.Type = "oneshot";
postStop = ''
chown -R dnsmasq ${stateDir}
systemctl restart dnsmasq
'';
after = [ "wireguard-wg0.service" ];
startAt = "02:00:00"; startAt = "02:00:00";
}; };
# Enable SATA HAT
systemd.services.sata-hat = {
description = "Enable software support for SATA Hat";
wantedBy = [ "zfs-import.target" ];
script = ''
${pkgs.bash}/bin/bash -c "/home/coolneng/system/scripts/SATA-hat.sh on"
'';
preStop = ''
${pkgs.bash}/bin/bash -c "/home/coolneng/system/scripts/SATA-hat.sh off"
'';
serviceConfig = {
Type = "oneshot";
RemainAfterExit = "yes";
};
before = [ "zfs-import.target" "zfs-import-vault.service" "umount.target" ];
requires = [ "systemd-udev-settle.service" ];
after = [ "systemd-udev-settle.service" ];
conflicts = [ "umount.target" ];
};
# HACK: restart services dependent on ZFS afer mount
systemd.services.restart-services-mount = {
description = "Restart services after the ZFS dataset is mounted";
wantedBy = [ "default.target" ];
script = ''
sleep 5
systemctl restart syncthing
systemctl restart radicale
systemctl restart gitea
'';
serviceConfig.Type = "oneshot";
requires = [ "sata-hat.service" ];
after = [ "vault.mount" ];
};
# Idle HDDs when not used
systemd.services.hd-idle = {
description = "Idle HDDs when not in use";
wantedBy = [ "default.target" ];
path = with pkgs; [ hd-idle ];
script = "${pkgs.hd-idle}/bin/hd-idle";
serviceConfig.Type = "simple";
requires = [ "sata-hat.service" ];
after = [ "vault.mount" ];
};
# Push zion changes to git daily # Push zion changes to git daily
systemd.user.services.zion-push = { systemd.user.services.zion-push = {
description = "Push zion changes to git"; description = "Push zion changes to git";

View File

@@ -1,21 +1,16 @@
# Web services configuration # Web services configuration
{ { config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
{
# Reverse proxy configuration # Reverse proxy configuration
services.nginx = { services.nginx = {
enable = true; enable = true;
recommendedTlsSettings = true; recommendedTlsSettings = true;
recommendedBrotliSettings = true; recommendedGzipSettings = true;
recommendedProxySettings = true; recommendedProxySettings = true;
recommendedOptimisation = true; recommendedOptimisation = true;
clientMaxBodySize = "0"; clientMaxBodySize = "0";
sslCiphers = "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK:!AES128"; sslCiphers =
"ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK:!AES128";
sslProtocols = "TLSv1.2 TLSv1.3"; sslProtocols = "TLSv1.2 TLSv1.3";
sslDhparam = "/var/lib/dhparams/nginx.pem"; sslDhparam = "/var/lib/dhparams/nginx.pem";
commonHttpConfig = '' commonHttpConfig = ''
@@ -34,36 +29,30 @@
proxy_cookie_path / "/; secure; HttpOnly; SameSite=strict"; proxy_cookie_path / "/; secure; HttpOnly; SameSite=strict";
''; '';
virtualHosts = { virtualHosts = {
# Old domain being redirected
"coolneng.duckdns.org" = { "coolneng.duckdns.org" = {
useACMEHost = "coolneng.duckdns.org"; enableACME = true;
forceSSL = true; forceSSL = true;
# Redirect from legacy subdirectory URL to subdomain
locations = { locations = {
"/".return = "301 https://psydnd.org$request_uri"; "/radicale/".return = "301 https://radicale.coolneng.duckdns.org";
"/syncthing/".return = "301 https://sync.coolneng.duckdns.org";
"/gitea/".extraConfig =
"rewrite ^/gitea/(.*)$ https://git.coolneng.duckdns.org/$1 last;";
"/miniflux/".extraConfig =
"rewrite ^/miniflux/(.*)$ https://rss.coolneng.duckdns.org/$1 last;";
# Delegation for Matrix # Delegation for Matrix
"/.well-known/" = { "/.well-known/" = {
alias = "${../well-known}" + "/"; alias = "${../well-known}" + "/";
extraConfig = '' extraConfig = ''
${config.services.nginx.commonHttpConfig} ${config.services.nginx.commonHttpConfig}
add_header Access-Control-Allow-Origin '*';
default_type application/json; default_type application/json;
add_header Access-Control-Allow-Origin * always;
''; '';
}; };
}; };
}; };
# Redirect subdomains "radicale.coolneng.duckdns.org" = {
"~^(?<subdomain>.+)\.coolneng\.duckdns\.org$" = { enableACME = true;
useACMEHost = "coolneng.duckdns.org";
forceSSL = true;
locations."/".return = "301 https://$subdomain.psydnd.org$request_uri";
};
# Current domain
"psydnd.org" = {
useACMEHost = "psydnd.org";
forceSSL = true;
};
"radicale.psydnd.org" = {
useACMEHost = "psydnd.org";
forceSSL = true; forceSSL = true;
locations."/" = { locations."/" = {
proxyPass = "http://localhost:5232/"; proxyPass = "http://localhost:5232/";
@@ -73,33 +62,32 @@
''; '';
}; };
}; };
"sync.psydnd.org" = { "sync.coolneng.duckdns.org" = {
useACMEHost = "psydnd.org"; enableACME = true;
forceSSL = true; forceSSL = true;
locations."/".proxyPass = "http://localhost:8384/"; locations."/".proxyPass = "http://localhost:8384/";
}; };
"git.psydnd.org" = { "git.coolneng.duckdns.org" = {
useACMEHost = "psydnd.org"; enableACME = true;
forceSSL = true; forceSSL = true;
locations."/" = { locations."/" = {
proxyPass = "http://localhost:3000/"; proxyPass = "http://localhost:3000/";
extraConfig = '' extraConfig = ''
${config.services.nginx.commonHttpConfig} ${config.services.nginx.commonHttpConfig}
# Disable embedding as a frame, except from the same origin # Disable embedding as a frame, except from the same origin
add_header Content-Security-Policy "frame-src git.psydnd.org; frame-ancestors git.psydnd.org"; add_header Content-Security-Policy "frame-src git.coolneng.duckdns.org; frame-ancestors git.coolneng.duckdns.org";
''; '';
}; };
}; };
"rss.psydnd.org" = { "rss.coolneng.duckdns.org" = {
useACMEHost = "psydnd.org"; enableACME = true;
forceSSL = true; forceSSL = true;
locations."/".proxyPass = "http://localhost:8080/"; locations."/".proxyPass = "http://localhost:8080/";
}; };
"matrix.psydnd.org" = { "matrix.coolneng.duckdns.org" = {
useACMEHost = "psydnd.org"; enableACME = true;
forceSSL = true; forceSSL = true;
listen = [ listen = [
# IPv4
{ {
addr = "0.0.0.0"; addr = "0.0.0.0";
port = 8448; port = 8448;
@@ -110,106 +98,87 @@
port = 443; port = 443;
ssl = true; ssl = true;
} }
# IPv6
{
addr = "[::]";
port = 8448;
ssl = true;
}
{
addr = "[::]";
port = 443;
ssl = true;
}
]; ];
locations."~ ^(/_matrix|/_synapse/client)".proxyPass = "http://localhost:8008"; locations."~ ^(/_matrix|/_synapse/client)" = {
proxyPass = "http://localhost:8008";
extraConfig = ''
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
'';
}; };
"element.psydnd.org" = { };
useACMEHost = "psydnd.org"; "element.coolneng.duckdns.org" = {
enableACME = true;
forceSSL = true; forceSSL = true;
locations."/".root = pkgs.element-web.override { locations."/".root = pkgs.element-web.override {
conf.default_server_config = { conf.default_server_config = {
"m.homeserver"."base_url" = "https://matrix.psydnd.org"; "m.homeserver"."base_url" = "https://matrix.coolneng.duckdns.org";
"m.identity_server"."base_url" = "https://vector.im"; "m.identity_server"."base_url" = "https://vector.im";
}; };
}; };
}; };
"books.psydnd.org" = { "wallabag.coolneng.duckdns.org" = {
useACMEHost = "psydnd.org"; enableACME = true;
forceSSL = true;
root = "${pkgs.wallabag}/web";
locations = {
"/".tryFiles = "$uri /app.php$is_args$args";
"/assets".root = "${config.environment.variables.WALLABAG_DATA}/web";
"~ ^/app.php(/|$)" = {
fastcgiParams = {
SCRIPT_FILENAME = "${pkgs.wallabag}/web/$fastcgi_script_name";
DOCUMENT_ROOT = "${pkgs.wallabag}/web";
};
extraConfig = ''
fastcgi_pass unix:${config.services.phpfpm.pools.wallabag.socket};
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include ${pkgs.nginx}/conf/fastcgi_params;
internal;
'';
};
};
};
"books.coolneng.duckdns.org" = {
enableACME = true;
forceSSL = true; forceSSL = true;
locations."/" = { locations."/" = {
proxyPass = "http://localhost:9000/"; proxyPass = "http://localhost:9000/";
proxyWebsockets = true;
extraConfig = '' extraConfig = ''
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade"; proxy_set_header Connection "Upgrade";
''; '';
}; };
}; };
"grafana.psydnd.org" = {
useACMEHost = "psydnd.org";
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:9009/";
proxyWebsockets = true;
};
};
"podcast.psydnd.org" = {
useACMEHost = "psydnd.org";
forceSSL = true;
locations."/".proxyPass = "http://localhost:9090/";
};
"bin.psydnd.org" = {
useACMEHost = "psydnd.org";
forceSSL = true;
locations."/".proxyPass = "http://localhost:9091/";
};
"read.psydnd.org" = {
useACMEHost = "psydnd.org";
forceSSL = true;
locations."/".proxyPass = "http://localhost:9092/";
};
"photos.psydnd.org" = {
useACMEHost = "psydnd.org";
forceSSL = true;
locations."/".proxyPass = "http://localhost:9191/";
};
}; };
}; };
# ACME certs configuration # ACME certs configuration
security.acme = { security.acme = {
acceptTerms = true; acceptTerms = true;
defaults = { defaults.email = "akasroua@gmail.com";
email = "akasroua@disroot.org"; certs."coolneng.duckdns.org".extraDomainNames = [
group = "nginx"; "radicale.coolneng.duckdns.org"
}; "sync.coolneng.duckdns.org"
certs = { "git.coolneng.duckdns.org"
"coolneng.duckdns.org" = { "rss.coolneng.duckdns.org"
domain = "*.coolneng.duckdns.org"; "matrix.coolneng.duckdns.org"
dnsProvider = "duckdns"; "element.coolneng.duckdns.org"
environmentFile = config.age.secrets.acme-duckdns.path; "wallabag.coolneng.duckdns.org"
}; "books.coolneng.duckdns.org"
"psydnd.org" = { ];
domain = "psydnd.org";
extraDomainNames = [ "*.psydnd.org" ];
dnsProvider = "porkbun";
environmentFile = config.age.secrets.acme-porkbun.path;
};
};
}; };
# Generate dhparams # Generate dhparams
security.dhparams = { security.dhparams = {
enable = true; enable = true;
defaultBitSize = 4096; params.nginx.bits = 2048;
params.nginx.bits = 4096;
}; };
# PostgreSQL databases configuration # PostgreSQL databases configuration
services.postgresql = { services.postgresql = {
enable = true; enable = true;
package = pkgs.postgresql_16; package = pkgs.postgresql_11;
authentication = lib.mkForce '' authentication = lib.mkForce ''
# Generated file; do not edit! # Generated file; do not edit!
# TYPE DATABASE USER ADDRESS METHOD # TYPE DATABASE USER ADDRESS METHOD
@@ -217,10 +186,6 @@
host all all 127.0.0.1/32 trust host all all 127.0.0.1/32 trust
host all all ::1/128 trust host all all ::1/128 trust
''; '';
settings = {
max_connections = "300";
shared_buffers = "1024MB";
};
}; };
# Restart reverse proxy after services startup # Restart reverse proxy after services startup
@@ -230,9 +195,6 @@
"miniflux.service" "miniflux.service"
"radicale.service" "radicale.service"
"dendrite.service" "dendrite.service"
"grafana.service" "phpfpm-wallabag.service"
"podman-openbooks.service"
"podman-mqtt2prometheus.service"
"podman-opodsync.service"
]; ];
} }

74
scripts/SATA-hat.sh Executable file
View File

@@ -0,0 +1,74 @@
#!/bin/sh
BASE_PATH=/sys/class
GPIO_PATH="$BASE_PATH"/gpio
PWM_PATH="$BASE_PATH"/pwm/pwmchip0
# GPIO pins
SATA0=26
SATA1=25
CPU_FAN=12
# Values
LOW=0
HIGH=1
export_pin() {
if [ ! -e $GPIO_PATH/gpio"$1" ]; then
echo "$1" >$GPIO_PATH/export
fi
}
unexport_pin() {
if [ -e $GPIO_PATH/gpio"$1" ]; then
echo "$1" >$GPIO_PATH/unexport
fi
}
set_gpio() {
export_pin "$1"
echo "out" >$GPIO_PATH/gpio"$1"/direction
echo "$2" >$GPIO_PATH/gpio"$1"/value
if [ "$3" = "clean" ]; then
unexport_pin "$1"
fi
}
enable_pwm_channel() {
echo "$1" >$PWM_PATH/export
echo 40000 >$PWM_PATH/pwm"$1"/period
echo 30000 >$PWM_PATH/pwm"$1"/duty_cycle
echo 1 >$PWM_PATH/pwm"$1"/enable
}
set_pwm() {
enable_pwm_channel 1
if [ "$1" = "clean" ]; then
echo 1 >$PWM_PATH/unexport
fi
}
turn_on() {
set_gpio $SATA0 $HIGH
sleep 1
set_gpio $SATA1 $HIGH
set_gpio $CPU_FAN $HIGH
set_pwm
}
turn_off() {
set_gpio $SATA0 $LOW clean
set_gpio $SATA1 $LOW clean
set_gpio $CPU_FAN $LOW clean
set_pwm clean
}
trap turn_off INT
if [ "$1" = "on" ]; then
turn_on
else
turn_off
fi
exit 0

View File

@@ -1,66 +0,0 @@
#!/bin/sh
partition_disk() {
parted "$DISK" -- mklabel gpt
parted "$DISK" -- mkpart ESP fat32 1MiB 1025MiB
parted "$DISK" -- mkpart linux-swap 1025MiB 17409MiB
parted "$DISK" -- mkpart primary 17409MiB 100%
parted "$DISK" -- set 1 boot on
mkfs.fat -F32 -n BOOT "$DISK"p1
mkswap "$DISK"p2
swapon "$DISK"p2
}
zfs_setup() {
zpool import -f vault
zpool create -f -o ashift=12 -o autotrim=on -O acltype=posixacl -O relatime=on \
-O xattr=sa -O dnodesize=legacy -O normalization=formD -O mountpoint=none \
-O canmount=off -O devices=off -R /mnt -O compression=zstd "$POOL_NAME" "$DISK"p3
zfs create -o mountpoint=legacy -o com.sun:auto-snapshot=false "$POOL_NAME"/ephemeral
zfs create -o mountpoint=legacy -o com.sun:auto-snapshot=false "$POOL_NAME"/ephemeral/nix
zfs create -o mountpoint=legacy -o com.sun:auto-snapshot=false -o sync=disabled -o setuid=off "$POOL_NAME"/ephemeral/tmp
zfs create -o mountpoint=legacy -o com.sun:auto-snapshot=false "$POOL_NAME"/stateful
zfs create -o mountpoint=legacy -o com.sun:auto-snapshot=true "$POOL_NAME"/stateful/home
zfs create -o mountpoint=legacy -o com.sun:auto-snapshot=false "$POOL_NAME"/stateful/root
}
mount_datasets() {
mount -t zfs sysion/stateful/root /mnt
mkdir -p /mnt/boot
mount "$DISK"p1 /mnt/boot
mkdir -p /mnt/home/coolneng
mount -t zfs sysion/stateful/home /mnt/home/coolneng
mkdir -p /mnt/nix
mount -t zfs sysion/ephemeral/nix /mnt/nix
mkdir -p /mnt/tmp
mount -t zfs sysion/ephemeral/tmp /mnt/tmp
}
install_system() {
nixos-generate-config --root /mnt
mv /mnt/etc/nixos/hardware-configuration.nix modules/hardware-configuration.nix
nix-shell -p git --command "nixos-install --root /mnt --flake .#zion"
}
usage() {
echo "Usage: install.sh <disk>"
echo "disk: full path to the disk (e.g. /dev/sda)"
exit 1
}
if [ $# != 1 ]; then
usage
fi
DISK="$1"
POOL_NAME="sysion"
echo "Let's start by partitioning the disk"
partition_disk
echo "Starting up the ZFS machinery"
zfs_setup
echo "Mounting the horse"
mount_datasets
echo "Lift off to the NixOS planet"
install_system
echo "All ready, time to rejoice"

View File

@@ -23,16 +23,15 @@ services=(
"syncthing.service" "syncthing.service"
"radicale.service" "radicale.service"
"miniflux.service" "miniflux.service"
"phpfpm-wallabag.service"
"gitea.service" "gitea.service"
"dendrite.service" "dendrite.service"
"matrix-as-telegram.service"
"matrix-as-facebook.service"
"matrix-as-signal.service"
"nginx.service" "nginx.service"
"dnsmasq.service" "dnsmasq.service"
"dnscrypt-proxy.service"
"podman-openbooks.service" "podman-openbooks.service"
"mosquitto.service"
"podman-mqtt2prometheus.service"
"prometheus.service"
"grafana.service"
) )
for var in "${services[@]}"; do for var in "${services[@]}"; do

Binary file not shown.

View File

@@ -1,5 +0,0 @@
age-encryption.org/v1
-> ssh-ed25519 iUaRGg 7JImhL2Wo/eJEwUGP+NhEf36yq5gHO9q1GYhY2HaMAY
eAMhD0sqHQS+aayBpOsY8+081i72QAhJCFbBe0//uwU
--- 4K8cXsDuWZrmWNJ+rz166ej9o/gLFc7CfJuzAsG0BxA
|.<2E><><EFBFBD> f<><66>f<EFBFBD>=<1D>-<2D>X$P<>:

8
secrets/ddclient.age Normal file
View File

@@ -0,0 +1,8 @@
age-encryption.org/v1
-> ssh-ed25519 iUaRGg mRkPNMBvRfbwb3GjcWWJ42RiJn4wxMdczvL2OJFagkY
jCqCSE2MMx74ZvXabmyHfI4jC6lwhtgrTSqjAflUksw
-> vH/-grease []_Tx" cZfV JHS /x/
SK1DATphyeQv8pjoNXTlQrRKQwn8oItd6xrhSic7fmxzmuKTQiPE
--- ObilbWkclfLnmjVql03OamXitnFgYnzfoZ04oq3XO1k
<EFBFBD>iy<13>݌1k{<7B><>OJ3<1F>H<EFBFBD>N<><4E><11><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%y<><1D><> <0C><>JA<4A>8<EFBFBD><38>
'<27>N<EFBFBD><4E>%<25><><EFBFBD><EFBFBD><EFBFBD>L@<12>6 &<26><>

Binary file not shown.

View File

@@ -1,6 +0,0 @@
age-encryption.org/v1
-> ssh-ed25519 iUaRGg XMrsd1RQcDq/SpFtqpB4Gj1keCvJsMB+VA58qZirYA4
tf8NQzoEYJXlKBjtX4ZplaPQv51RCW9yHulvKZB8c8g
--- 5wZntAZCQ4pGYrgDFd63w6Y+Taaatcw5z0tDSvShi30
<EFBFBD><EFBFBD>4<EFBFBD><EFBFBD><EFBFBD>Ɖq3<EFBFBD>&
><0E>4<EFBFBD><34>J<EFBFBD>?<3F><0F><> QW<51>jZ<:'<<16>x(<28>Y<16>i<EFBFBD>ZDO#<23>w<7F><77>R<EFBFBD><52><EFBFBD>O@2<>cAj (f<><66><EFBFBD><EFBFBD>M<EFBFBD><4D><EFBFBD>

View File

@@ -1,5 +0,0 @@
age-encryption.org/v1
-> ssh-ed25519 iUaRGg paS5BxWWicriSLAZyCBKd2xylLAp4/LcHmogO7me8yQ
MWW/Pkvn+4G4YeYXY9ZPXC92TbcFXQMyHJ2ltFzXpZs
--- ZdFfQ7tHfEo+u/0MmigCNh6OIxkd2bimRN30rMUs1ks
<EFBFBD>9<EFBFBD>7Y<EFBFBD>$B<>sX<0E>ʽb<CABD>O'J<><4A>S'<27>5!<21><>UMʯ-v<>m<EFBFBD><6D><EFBFBD><EFBFBD><EFBFBD>8%|R,<2C>~I<><14><>G<EFBFBD><47>VQE<0E>0D<30>:Qv<<1E><>)<29> <0B><>%fc<66><63>XZչ 7+yB

Binary file not shown.

Binary file not shown.

View File

@@ -1,8 +0,0 @@
age-encryption.org/v1
-> ssh-ed25519 iUaRGg JT+as1Cl66qOy5yY3WJNs0bh51DWaCe/+XZLR8m1L0A
/6CyRX6Ks7Wr/ySlJhdfkabcy4N5rQ0VzGtlbxL8RCs
-> L$l;-grease uU_g`a
N00Z5C8AKzdnGZuFUHqY6uZBiMryyT3IXkdNlYW2fVJLOSfkfFdXssIK9hcMObyi
sQENGphUf1Sk16Vo9p4emOL5mtzU
--- flb9q0/Q608TJ6K9fsGULVwi2Pk860Cz750d5DBSfMM
1<EFBFBD>%<25><>=<3D><4C><DAAE>s<EFBFBD>c/<2F>Iy<49><79>oT!<21>ڏ<EFBFBD>&X<0F><><EFBFBD>WՒZ̋<5A><CC8B> <0E>8Z<38><5A><EFBFBD><EFBFBD><EFBFBD>æ<19><><EFBFBD><EFBFBD><06> <09> <0B>tw<74>'<27><> i<>e’<65>_<EFBFBD>}-<2D>V<EFBFBD>$<24>S<EFBFBD><53><EFBFBD><EFBFBD><EFBFBD>خA<D8AE><41><EFBFBD>h<EFBFBD><68><EFBFBD><04><>!<21><>9Z<39><5A><05><>hqіIa<49><61>,

Binary file not shown.

Binary file not shown.

View File

@@ -1,25 +1,15 @@
let let
zion = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFRqINHR7/zc+c3/PuR+NeSsBHXXzBiEtFWSK6QaxQTW"; zion =
in "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFRqINHR7/zc+c3/PuR+NeSsBHXXzBiEtFWSK6QaxQTW";
{ in {
"wireguard.age".publicKeys = [ zion ]; "wireguard.age".publicKeys = [ zion ];
"syncthing.age".publicKeys = [ zion ]; "syncthing.age".publicKeys = [ zion ];
"msmtp.age".publicKeys = [ zion ]; "msmtp.age".publicKeys = [ zion ];
"gitea.age".publicKeys = [ zion ]; "gitea.age".publicKeys = [ zion ];
"ddclient.age".publicKeys = [ zion ];
"miniflux.age".publicKeys = [ zion ]; "miniflux.age".publicKeys = [ zion ];
"git.age".publicKeys = [ zion ]; "git.age".publicKeys = [ zion ];
"dendrite.age".publicKeys = [ zion ]; "dendrite.age".publicKeys = [ zion ];
"dendrite-postgres.age".publicKeys = [ zion ]; "dendrite-postgres.age".publicKeys = [ zion ];
"telegram.age".publicKeys = [ zion ]; "telegram.age".publicKeys = [ zion ];
"mqtt-sender.age".publicKeys = [ zion ];
"mqtt-receiver.age".publicKeys = [ zion ];
"facebook.age".publicKeys = [ zion ];
"signal.age".publicKeys = [ zion ];
"inadyn-duckdns.age".publicKeys = [ zion ];
"inadyn-porkbun.age".publicKeys = [ zion ];
"inadyn-porkbun-secret.age".publicKeys = [ zion ];
"acme-duckdns.age".publicKeys = [ zion ];
"acme-porkbun.age".publicKeys = [ zion ];
"microbin.age".publicKeys = [ zion ];
"readeck.age".publicKeys = [ zion ];
} }

View File

@@ -1,8 +0,0 @@
age-encryption.org/v1
-> ssh-ed25519 iUaRGg J/gZDBtDsIzjCzO1y2vXgxl8YuvWJgcpk+8KMOp63kg
1XF9JFAIscHWFJMTctZOxVIBYhYliUFays5gwjZt6hs
-> vM4\2y\'-grease
bj9VKIuH0l1v5X8N2v4p+u3VySDKjj3WAyVZ7f+wmy16wncrNyMtiUZ+ELBWfqXd
XOyeGZoKBHwd8lOgkZ+va0BEkBJs9piX
--- K2uN9JxuqPQpAxjQ+6dgsqhsq50nTkLsw8QGJprE5hQ
H<EFBFBD><EFBFBD><EFBFBD>S<>:<3A>eJ4}'<27><><EFBFBD>T<EFBFBD><54>˦ <0B><>[<5B>'<27>M<EFBFBD><4D><EFBFBD>9<><07><>E6_<36><12><><EFBFBD><1D><><EFBFBD>_<EFBFBD><5F><EFBFBD><EFBFBD>yPM8''<27>'<15>F<><46><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Rڡ"<22>ݏ<EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD>;<3B><>4<EFBFBD>J/>k<1C>5<EFBFBD><<15><>:<3A>M<EFBFBD>lK$<24>ӟq<D39F>S<EFBFBD><53><EFBFBD><EFBFBD>#<23>Ō<04>j<EFBFBD>X)<29><>v<EFBFBD><76><EFBFBD>–<EFBFBD>Ou<4F><75>J<>P<EFBFBD><12><>~

Binary file not shown.

View File

@@ -1,5 +0,0 @@
age-encryption.org/v1
-> ssh-ed25519 iUaRGg zWm4+j3/IRqd3uZqGzXVcHvs+urNrvDMOceWKbpl018
HlIKCFYt7n3iKZav5i0YiB4awRMJML0XUowX8sKKH2c
--- ysvYVxgK1OeqCk8KdNF+uWsaQ9EzVRku7nw37aUAW3A
c<EFBFBD><EFBFBD>b<EFBFBD>W|bU<62>B"<22><04>Ե<EFBFBD><D4B5><EFBFBD><EFBFBD><EFBFBD><03><>U<EFBFBD>

Binary file not shown.

View File

@@ -1,5 +1,8 @@
{ {
"m.homeserver": { "m.homeserver": {
"base_url": "https://matrix.psydnd.org" "base_url": "https://matrix.coolneng.duckdns.org"
},
"m.identity_server": {
"base_url": "https://vector.im"
} }
} }

View File

@@ -1 +1 @@
{ "m.server": "matrix.psydnd.org:443" } { "m.server": "matrix.coolneng.duckdns.org:443" }