2023-06-12 23:25:40 +02:00
|
|
|
# SPDX-FileCopyrightText: 2022 Richard Brežák <richard@brezak.sk>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
2023-06-18 20:07:47 +02:00
|
|
|
{ inputs, lib', config, ... }:
|
2023-06-12 23:25:40 +02:00
|
|
|
let
|
2023-06-18 20:07:47 +02:00
|
|
|
inherit (lib')
|
2023-06-12 23:25:40 +02:00
|
|
|
flip
|
|
|
|
mapAttrs
|
|
|
|
singleton;
|
|
|
|
|
|
|
|
config' = config;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
flake.nixosConfigurations.blowhole = inputs.nixpkgs.lib.nixosSystem {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
|
|
|
|
specialArgs = {
|
|
|
|
config' = config';
|
|
|
|
inputs' = inputs;
|
2023-06-18 20:07:47 +02:00
|
|
|
secret = lib'.loadSecrets inputs.secret;
|
2023-06-12 23:25:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
modules = singleton
|
2024-01-22 09:59:27 +01:00
|
|
|
({ secret, pkgs, config, ... }:
|
2023-06-12 23:25:40 +02:00
|
|
|
{
|
2024-02-09 15:40:00 +01:00
|
|
|
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib'.getName pkg) [
|
|
|
|
"consul-1.17.2"
|
|
|
|
];
|
|
|
|
|
2023-06-12 23:25:40 +02:00
|
|
|
imports = [
|
|
|
|
./bind.nix
|
|
|
|
./consul.nix
|
|
|
|
./filesystems.nix
|
|
|
|
./firewall.nix
|
|
|
|
./grub.nix
|
|
|
|
./hardware.nix
|
2023-07-10 23:35:56 +02:00
|
|
|
# ./hostapd.nix
|
2023-06-12 23:25:40 +02:00
|
|
|
./ical2org.nix
|
|
|
|
./klipper.nix
|
2023-10-07 22:28:48 +02:00
|
|
|
# ./monitoring.nix
|
2023-06-12 23:25:40 +02:00
|
|
|
./nas.nix
|
|
|
|
./networking.nix
|
|
|
|
./nfs.nix
|
|
|
|
./nomad.nix
|
|
|
|
./uterranix.nix
|
|
|
|
./vault-agent.nix
|
|
|
|
./vault.nix
|
|
|
|
./watchdog.nix
|
|
|
|
./nixpkgs.nix
|
|
|
|
./users.nix
|
2023-12-03 20:00:10 +01:00
|
|
|
./disk_monitoring.nix
|
2023-07-20 12:35:34 +02:00
|
|
|
./sol.nix
|
2023-06-12 23:25:40 +02:00
|
|
|
../../common/remote_access.nix
|
2023-09-28 10:31:25 +02:00
|
|
|
./microvms.nix
|
2023-12-23 20:01:59 +01:00
|
|
|
../../modules/notify-login.nix
|
2023-06-12 23:25:40 +02:00
|
|
|
inputs.serokell-nix.nixosModules.acme-sh
|
2023-09-28 10:31:25 +02:00
|
|
|
|
|
|
|
inputs.notnft.nixosModules.default
|
|
|
|
inputs.self.nixosModules.notnft
|
|
|
|
inputs.microvm.nixosModules.host
|
|
|
|
inputs.self.nixosModules.microvm-extras-host
|
|
|
|
|
2023-06-12 23:25:40 +02:00
|
|
|
config'.flake.nixosModules.hashicorp
|
|
|
|
config'.flake.nixosModules.hashicorp-envoy
|
|
|
|
config'.flake.nixosModules.telegraf
|
|
|
|
config'.flake.nixosModules.grafana
|
|
|
|
];
|
|
|
|
|
2023-12-23 20:01:59 +01:00
|
|
|
services.notify-login.ssh = {
|
|
|
|
enable = true;
|
|
|
|
method = "matrix";
|
|
|
|
settings = {
|
|
|
|
secretsFile = "/var/secrets/matrix-notify-login-ssh.json";
|
|
|
|
stateDirectory = "/var/lib/matrix-commander/notify-login-ssh";
|
|
|
|
markdown = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-06-12 23:25:40 +02:00
|
|
|
_module.args.nixinate = {
|
|
|
|
host = "blowhole.hosts.in.redalder.org";
|
|
|
|
sshUser = "main";
|
|
|
|
buildOn = "local";
|
|
|
|
substituteOnTarget = true;
|
|
|
|
hermetic = false;
|
|
|
|
nixOptions = [
|
|
|
|
"--override-input secret path://$HOME/dotfiles/secret"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2023-06-28 14:23:08 +02:00
|
|
|
systemd.services.vault-unsealed = {
|
|
|
|
description = "Check whether the local Vault instance is unsealed and fail if not.";
|
|
|
|
path = with pkgs; [ getent vault ];
|
|
|
|
|
|
|
|
unitConfig = {
|
|
|
|
StartLimitInterval = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Restart = "always";
|
|
|
|
RestartSec = 30;
|
|
|
|
};
|
|
|
|
|
|
|
|
script = ''
|
|
|
|
export VAULT_ADDR="https://vault.in.redalder.org:8200/"
|
|
|
|
|
|
|
|
while [ $( vault operator key-status |& grep -q "Vault is sealed" ; printf $? ) = 1 ]
|
|
|
|
do
|
|
|
|
sleep 30
|
|
|
|
done
|
|
|
|
exit 2
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-06-12 23:25:40 +02:00
|
|
|
system.stateVersion = "21.05";
|
2023-07-18 23:11:45 +02:00
|
|
|
|
2024-01-22 00:44:17 +01:00
|
|
|
systemd.services.home-assistant-pyscript = {
|
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
restartIfChanged = true;
|
|
|
|
path = [ pkgs.rsync ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = "yes";
|
|
|
|
};
|
|
|
|
script = ''
|
|
|
|
mkdir -p /mnt/kyle/infrastructure/home-assistant/home-assistant/pyscript
|
2024-01-22 09:59:27 +01:00
|
|
|
rsync --chown 403:403 --chmod Du=rwx,Dgo=rx,Fu=rw,Fgo=r -arvc --delete ${secret.pyscript or ""}/. /mnt/kyle/infrastructure/home-assistant/home-assistant/pyscript/
|
2024-01-22 00:44:17 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-07-18 23:11:45 +02:00
|
|
|
boot.kernel.sysctl."fs.inotify.max_user_instances" = 256;
|
2023-10-23 23:30:38 +02:00
|
|
|
services.udev.extraRules =
|
|
|
|
let
|
|
|
|
devPath =
|
|
|
|
"/dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_4c004e9c53c9eb118a9f8b4f1d69213e-if00-port0";
|
|
|
|
zigbeeScript = pkgs.writeShellScript "zigbeeScript" ''
|
2023-11-24 15:33:51 +01:00
|
|
|
touch /dev/ttyZigbee
|
2023-10-23 23:30:38 +02:00
|
|
|
${pkgs.lib.getExe' pkgs.utillinux "mount"} --bind \
|
|
|
|
"$(${pkgs.lib.getExe' pkgs.coreutils "readlink"} -f "${devPath}")" \
|
|
|
|
/dev/ttyZigbee
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
''
|
|
|
|
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="10c4", ATTR{idProduct}=="ea60", RUN+="${zigbeeScript}"
|
|
|
|
'';
|
2023-06-12 23:25:40 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|