2021-04-07 14:03:52 -07:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
2021-04-18 23:24:01 -07:00
|
|
|
let
|
|
|
|
shinobi-port = "7080";
|
|
|
|
shinobi-od-port = "7082";
|
2021-07-25 22:45:36 -07:00
|
|
|
state-dir = "/state"; # This must be a string!
|
2021-04-18 23:24:01 -07:00
|
|
|
|
2022-03-16 09:49:35 -07:00
|
|
|
home-assistant-port = 8123;
|
|
|
|
|
|
|
|
parent-config = config;
|
|
|
|
|
|
|
|
generate-mac = pkgs.lib.network.generate-mac-address;
|
|
|
|
|
2021-04-18 23:24:01 -07:00
|
|
|
in {
|
2021-09-22 18:43:23 -07:00
|
|
|
boot = {
|
|
|
|
loader.grub.copyKernels = true;
|
|
|
|
kernelModules = [ "rpcsec_gss_krb5" ];
|
|
|
|
};
|
2021-07-20 18:28:12 -07:00
|
|
|
|
2021-04-07 14:03:52 -07:00
|
|
|
networking = {
|
|
|
|
interfaces = {
|
|
|
|
enp3s0f0.useDHCP = false;
|
|
|
|
enp3s0f1.useDHCP = false;
|
|
|
|
enp4s0f0.useDHCP = false;
|
|
|
|
enp4s0f1.useDHCP = false;
|
|
|
|
|
2021-07-20 18:28:12 -07:00
|
|
|
intif0.useDHCP = true;
|
2021-04-07 14:03:52 -07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-07-16 12:57:36 -07:00
|
|
|
systemd.tmpfiles.rules = [
|
2021-08-04 12:37:55 -07:00
|
|
|
"L /root/.gnupg - - - - ${state-dir}/user/root/gnupg"
|
|
|
|
"L /root/.ssh/id_rsa - - - - ${state-dir}/user/root/ssh/id_rsa"
|
|
|
|
"L /root/.ssh/id_rsa.pub - - - - ${state-dir}/user/root/ssh/id_rsa.pub"
|
2021-07-20 18:39:07 -07:00
|
|
|
"L /root/.ssh/known_hosts - - - - ${state-dir}/user/root/ssh/known_hosts"
|
2021-07-26 12:09:47 -07:00
|
|
|
];
|
|
|
|
|
|
|
|
services.openssh.hostKeys = [
|
|
|
|
{
|
|
|
|
path = "${state-dir}/ssh/ssh_host_rsa_key";
|
|
|
|
type = "rsa";
|
|
|
|
bits = 4096;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
path = "${state-dir}/ssh/ssh_host_ed25519_key";
|
|
|
|
type = "ed25519";
|
|
|
|
bits = 4096;
|
|
|
|
}
|
2021-07-16 12:57:36 -07:00
|
|
|
];
|
|
|
|
|
2021-07-20 18:28:12 -07:00
|
|
|
environment.etc = {
|
|
|
|
"ssh/ssh_host_rsa_key" = {
|
|
|
|
source = "${state-dir}/ssh/ssh_host_rsa_key";
|
|
|
|
user = "root";
|
|
|
|
group = "root";
|
|
|
|
mode = "0400";
|
|
|
|
};
|
|
|
|
"ssh/ssh_host_rsa_key.pub" = {
|
|
|
|
source = "${state-dir}/ssh/ssh_host_rsa_key.pub";
|
|
|
|
user = "root";
|
|
|
|
group = "root";
|
|
|
|
mode = "0444";
|
|
|
|
};
|
|
|
|
"ssh/ssh_host_ed25519_key" = {
|
|
|
|
source = "${state-dir}/ssh/ssh_host_ed25519_key";
|
|
|
|
user = "root";
|
|
|
|
group = "root";
|
|
|
|
mode = "0400";
|
|
|
|
};
|
|
|
|
"ssh/ssh_host_ed25519_key.pub" = {
|
|
|
|
source = "${state-dir}/ssh/ssh_host_ed25519_key.pub";
|
|
|
|
user = "root";
|
|
|
|
group = "root";
|
|
|
|
mode = "0444";
|
|
|
|
};
|
2021-07-26 12:09:47 -07:00
|
|
|
nixos.source = "/etc/nixos-live";
|
|
|
|
"host-config.nix".source = "/state/host/host-config.nix";
|
|
|
|
adjtime.source = "/state/host/adjtime";
|
|
|
|
NIXOS.source = "/state/host/NIXOS";
|
2021-07-20 18:28:12 -07:00
|
|
|
};
|
|
|
|
|
2021-07-16 12:57:36 -07:00
|
|
|
security.sudo.extraConfig = ''
|
|
|
|
# Due to rollback, sudo will lecture after every reboot
|
|
|
|
Defaults lecture = never
|
|
|
|
'';
|
|
|
|
|
2022-03-16 09:49:35 -07:00
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
recommendedOptimisation = true;
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
recommendedGzipSettings = true;
|
|
|
|
|
|
|
|
virtualHosts."home.sea.fudo.org" = {
|
|
|
|
locations."/" = {
|
2022-04-08 14:21:56 -07:00
|
|
|
proxyPass = "http://localhost:${toString home-assistant-port}";
|
2022-03-16 09:49:35 -07:00
|
|
|
proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-07-28 12:01:06 -07:00
|
|
|
virtualisation = {
|
|
|
|
docker = {
|
|
|
|
enable = true;
|
|
|
|
enableOnBoot = true;
|
|
|
|
autoPrune = { enable = true; };
|
|
|
|
};
|
|
|
|
|
|
|
|
oci-containers = {
|
2022-03-16 09:49:35 -07:00
|
|
|
backend = "docker";
|
2021-07-28 12:01:06 -07:00
|
|
|
containers = {
|
2022-03-16 09:49:35 -07:00
|
|
|
home-assistant = {
|
|
|
|
image = "homeassistant/home-assistant:stable";
|
|
|
|
autoStart = true;
|
|
|
|
environment.TZ = config.time.timeZone;
|
2022-04-08 14:21:56 -07:00
|
|
|
# ports = [ "${toString home-assistant-port}:8123" ];
|
|
|
|
volumes = [ "/state/services/home-assistant:/config" ];
|
|
|
|
extraOptions = [ "--network=host" "--device=/dev/ttyACM0" ];
|
2021-07-28 12:01:06 -07:00
|
|
|
};
|
|
|
|
|
2022-03-16 09:49:35 -07:00
|
|
|
# shinobi = {
|
|
|
|
# image = "shinobisystems/shinobi:latest";
|
|
|
|
# ports = [ "${shinobi-port}:8080" ];
|
|
|
|
# volumes = [
|
|
|
|
# "/state/shinobi/plugins:/home/Shinobi/plugins"
|
|
|
|
# "/state/shinobi/config:/home/Shinobi/config"
|
|
|
|
# "/state/shinobi/videos:/home/Shinobi/videos"
|
|
|
|
# "/state/shinobi/db-data:/var/lib/mysql"
|
|
|
|
# "/etc/localtime:/etc/localtime:ro"
|
|
|
|
# ];
|
|
|
|
# };
|
|
|
|
|
2021-07-28 12:01:06 -07:00
|
|
|
# shinobi-od = {
|
|
|
|
# image = "shinobisystems/shinobi-tensorflow:latest";
|
|
|
|
# volumes =
|
|
|
|
# [ "/srv/shinobi/od-config:/home/Shinobi/docker-plugins/tensorflow" ];
|
|
|
|
# ports = [ "${shinobi-od-port}:8082" ];
|
|
|
|
# environment = {
|
|
|
|
# PLUGIN_HOST = "panopticon.sea.fudo.org";
|
|
|
|
# PLUGIN_PORT = shinobi-port;
|
|
|
|
# PLUGIN_KEY = "30sWllylOxsDcE4vQXEPaXNfe5DiB3";
|
|
|
|
# };
|
|
|
|
# };
|
|
|
|
|
|
|
|
# photoprism = { image = "photoprism/photoprism"; };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2021-04-07 14:03:52 -07:00
|
|
|
}
|