Compare commits
7 Commits
5c17164fd8
...
microvm-mo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edddfc5e3f | ||
|
|
e94410ca54 | ||
|
|
f7943d981b | ||
|
|
e22c895cf7 | ||
|
|
a07bec0472 | ||
|
|
4a67683462 | ||
|
|
fb222bc1a4 |
@@ -69,7 +69,8 @@ in
|
||||
};
|
||||
|
||||
services.malobeo.microvm.enableHostBridge = true;
|
||||
services.malobeo.microvm.deployHosts = [ "overwatch" "infradocs" "nextcloud" "durruti" ];
|
||||
services.malobeo.microvm.deployHosts = [ "overwatch" "infradocs" "durruti" ];
|
||||
services.malobeo.microvm.client.nextcloud.enable = true;
|
||||
|
||||
networking = {
|
||||
nat = {
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
{ config, self, inputs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
inputs.disko.nixosModules.disko
|
||||
];
|
||||
|
||||
# https://github.com/nix-community/disko/blob/master/example/luks-btrfs-subvolumes.nix
|
||||
disko.devices = {
|
||||
disk = {
|
||||
main = {
|
||||
type = "disk";
|
||||
# When using disko-install, we will overwrite this value from the commandline
|
||||
device = "/dev/disk/by-id/some-disk-id";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
ESP = {
|
||||
size = "512M";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
mountOptions = [ "umask=0077" ];
|
||||
};
|
||||
};
|
||||
luks = {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "luks";
|
||||
name = "crypted";
|
||||
passwordFile = /tmp/secret.key; # Interactive
|
||||
content = {
|
||||
type = "btrfs";
|
||||
extraArgs = [ "-f" ];
|
||||
subvolumes = {
|
||||
"/root" = {
|
||||
mountpoint = "/";
|
||||
mountOptions = [ "compress=zstd" "noatime" ];
|
||||
};
|
||||
"/home" = {
|
||||
mountpoint = "/home";
|
||||
mountOptions = [ "compress=zstd" "noatime" ];
|
||||
};
|
||||
"/nix" = {
|
||||
mountpoint = "/nix";
|
||||
mountOptions = [ "compress=zstd" "noatime" ];
|
||||
};
|
||||
"/swap" = {
|
||||
mountpoint = "/.swapvol";
|
||||
swap.swapfile.size = "20M";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -187,6 +187,7 @@ in
|
||||
postCreateHook = lib.mkIf cfg.encryption ''
|
||||
zfs set keylocation="prompt" zroot/encrypted;
|
||||
'';
|
||||
|
||||
};
|
||||
"encrypted/root" = {
|
||||
type = "zfs_fs";
|
||||
@@ -244,13 +245,12 @@ in
|
||||
};
|
||||
# use this to read the key during boot
|
||||
postCreateHook = lib.mkIf cfg.encryption ''
|
||||
zfs set keylocation="prompt" storage/encrypted;
|
||||
zfs set keylocation="file:///root/secret.key" storage/encrypted;
|
||||
'';
|
||||
};
|
||||
"encrypted/data" = {
|
||||
type = "zfs_fs";
|
||||
mountpoint = "/data";
|
||||
options.mountpoint = "legacy";
|
||||
};
|
||||
reserved = {
|
||||
# for cow delete if pool is full
|
||||
@@ -267,7 +267,7 @@ in
|
||||
};
|
||||
|
||||
boot.zfs.devNodes = lib.mkDefault cfg.devNodes;
|
||||
|
||||
boot.zfs.extraPools = lib.mkIf cfg.storage.enable [ "storage" ];
|
||||
fileSystems."/".neededForBoot = true;
|
||||
fileSystems."/etc".neededForBoot = true;
|
||||
fileSystems."/boot".neededForBoot = true;
|
||||
|
||||
@@ -30,9 +30,7 @@ in
|
||||
loader.efi.canTouchEfiVariables = true;
|
||||
supportedFilesystems = [ "vfat" "zfs" ];
|
||||
zfs = {
|
||||
forceImportAll = true;
|
||||
requestEncryptionCredentials = true;
|
||||
|
||||
};
|
||||
initrd = {
|
||||
availableKernelModules = cfg.ethernetDrivers;
|
||||
|
||||
28
machines/modules/malobeo/microvm_client.nix
Normal file
28
machines/modules/malobeo/microvm_client.nix
Normal file
@@ -0,0 +1,28 @@
|
||||
{config, lib, pkgs, ...}:
|
||||
let
|
||||
cfg = config.services.malobeo.microvm.client;
|
||||
in
|
||||
{
|
||||
options.services.malobeo.microvm.client = {
|
||||
nextcloud = {
|
||||
enable = lib.mkEnableOption "enable the nextcloud microvm wrapper";
|
||||
datadir = lib.mkOption {
|
||||
type = lib.types.string;
|
||||
default = "/data/services/nextcloud/";
|
||||
description = "set a custom datadir";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf cfg.nextcloud.enable { #add check for run-vm?
|
||||
services.malobeo.microvm.deployHosts = ["nextcloud"];
|
||||
microvm.vms.nextcloud.config.microvm.shares = lib.mkAfter [{
|
||||
source = cfg.datadir;
|
||||
mountPoint = "/datadir";
|
||||
tag = "nc-datadir";
|
||||
proto = "virtiofs";
|
||||
}];
|
||||
})
|
||||
];
|
||||
}
|
||||
@@ -37,6 +37,7 @@ with lib;
|
||||
hostName = "cloud.malobeo.org";
|
||||
config.adminpassFile = config.sops.secrets.nextcloudAdminPass.path;
|
||||
#https = true; #disable for testing
|
||||
datadir = "/datadir";
|
||||
database.createLocally = true;
|
||||
config.dbtype = "pgsql";
|
||||
configureRedis = true;
|
||||
@@ -55,6 +56,12 @@ with lib;
|
||||
};
|
||||
settings = {
|
||||
trusted_domains = ["10.0.0.13"];
|
||||
"maintenance_window_start" = "1";
|
||||
"default_phone_region" = "DE";
|
||||
};
|
||||
phpOptions = {
|
||||
"realpath_cache_size" = "0";
|
||||
"opcache.interned_strings_buffer" = "23";
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ in
|
||||
|
||||
malobeo.disks = {
|
||||
enable = true;
|
||||
encryption = false;
|
||||
encryption = true;
|
||||
hostId = "83abc8cb";
|
||||
devNodes = "/dev/disk/by-path/";
|
||||
root = {
|
||||
|
||||
@@ -108,7 +108,7 @@ in (utils.lib.eachSystem (builtins.filter filter_system utils.lib.defaultSystems
|
||||
|
||||
nixosModules.malobeo = {
|
||||
host.imports = [ ./machines/durruti/host_config.nix ];
|
||||
microvm.imports = [ ./machines/modules/malobeo/microvm_host.nix ];
|
||||
microvm.imports = [ ./machines/modules/malobeo/microvm_host.nix ./machines/modules/malobeo/microvm_client.nix];
|
||||
vpn.imports = [ ./machines/modules/malobeo/wireguard.nix ];
|
||||
initssh.imports = [ ./machines/modules/malobeo/initssh.nix ];
|
||||
metrics.imports = [ ./machines/modules/malobeo/metrics.nix ];
|
||||
|
||||
@@ -37,9 +37,11 @@ trap cleanup EXIT
|
||||
|
||||
# Create the directory where sshd expects to find the host keys
|
||||
install -d -m755 "$temp/etc/ssh/"
|
||||
install -d -m755 "$temp/root/"
|
||||
|
||||
diskKey=$(sops -d machines/$hostname/disk.key)
|
||||
echo "$diskKey" > /tmp/secret.key
|
||||
echo "$diskKey" > $temp/root/secret.key
|
||||
|
||||
ssh-keygen -f $temp/etc/ssh/"$hostname" -t ed25519 -N ""
|
||||
ssh-keygen -f $temp/etc/ssh/initrd -t ed25519 -N ""
|
||||
|
||||
@@ -23,18 +23,14 @@ echo
|
||||
if [ $# = 1 ]
|
||||
then
|
||||
diskkey=$(sops -d machines/$HOSTNAME/disk.key)
|
||||
echo "$diskkey" | ssh $sshoptions root@$HOSTNAME-initrd "systemd-tty-ask-password-agent" #storage
|
||||
|
||||
echo "$diskkey" | ssh $sshoptions root@$HOSTNAME-initrd "systemd-tty-ask-password-agent" #root
|
||||
|
||||
elif [ $# = 2 ]
|
||||
then
|
||||
diskkey=$(sops -d machines/$HOSTNAME/disk.key)
|
||||
IP=$2
|
||||
echo "$diskkey" | ssh $sshoptions root@$IP "systemd-tty-ask-password-agent" #storage
|
||||
|
||||
echo "$diskkey" | ssh $sshoptions root@$IP "systemd-tty-ask-password-agent" #root
|
||||
|
||||
|
||||
else
|
||||
echo
|
||||
echo "Unlock the root disk on a remote host."
|
||||
|
||||
Reference in New Issue
Block a user