dotfiles/home/Mallorea.nix

81 lines
3.1 KiB
Nix
Raw Normal View History

2024-06-03 20:09:38 +02:00
{ inputs, config, pkgs, ... }:
2024-06-04 16:16:30 +02:00
let
scripts = {
2024-06-13 11:53:29 +02:00
disk_check = import ./utils/disk_check.nix { inherit pkgs; };
2024-06-04 16:16:30 +02:00
vdirsyncer = {
when = "*:0/15";
script = toString (pkgs.writeShellScript "script" ''
${pkgs.vdirsyncer}/bin/vdirsyncer sync imec/pair
'');
};
mbsync = {
when = "*-*-* 00:00:00";
script = toString (pkgs.writeShellScript "script" ''
BASEDIR=/home/server/Containers/mbsync
# python3 $BASEDIR/config/oauth2/mutt_oauth2.py $BASEDIR/data/oauth2/credentials.json
docker exec --user "1000:1000" mbsync-container /home/user/.config/mbsync/run.sh -a
${pkgs.notmuch}/bin/notmuch new
'');
};
sync_vault = {
when = "*-*-* 02:00:00";
script = toString (pkgs.writeShellScript "script" ''
source $HOME/.secrets/Backup/env.sh
for _ in {1..2}; do
OUTPUT=$(echo "$ZFS_PASSPHRASE" | ssh 10.4.0.1 zfs load-key Vault/Thomas/Encrypted 2>&1);
if [ "$OUTPUT" == "Key load error: Key already loaded for 'Vault/Thomas/Encrypted'." ]; then
echo "Key successfully loaded, starting syncoid"
syncoid --no-privilege-elevation --no-sync-snap tank/Storage/Thomas/Workspace 10.4.0.1:Vault/Thomas/Encrypted/Storage/Workspace
syncoid --no-privilege-elevation --no-sync-snap tank/Storage/Thomas 10.4.0.1:Vault/Thomas/Encrypted/Storage/T
syncoid --no-privilege-elevation --no-sync-snap tank/Storage/Niels 10.4.0.1:Vault/Thomas/Encrypted/Storage/N
syncoid --no-privilege-elevation --no-sync-snap tank/Storage/Yolande 10.4.0.1:Vault/Thomas/Encrypted/Storage/Y
syncoid --no-privilege-elevation --no-sync-snap tank/Containers 10.4.0.1:Vault/Thomas/Encrypted/Containers
ssh 10.4.0.1 zfs unload-key Vault/Thomas/Encrypted
${pkgs.curl}/bin/curl https://uptime.thomasave.be/api/push/s39pIIrB0R
exit 0
fi
done
2024-06-03 20:09:38 +02:00
2024-06-04 16:16:30 +02:00
echo "Found output instead: $OUTPUT"
echo "Failed to load key: $OUTPUT" | sendmail
exit 1
'');
2024-06-03 20:09:38 +02:00
};
2024-06-04 16:16:30 +02:00
backup = {
when = "*-*-* 04:00:00";
script = toString (pkgs.writeShellScript "script" ''
${./scripts/files/backup.sh}
${pkgs.curl}/bin/curl https://uptime.thomasave.be/api/push/R6iJcWqGp0
'');
};
};
2024-06-13 11:53:29 +02:00
in
{
2024-06-03 21:04:20 +02:00
home.username = "server";
home.homeDirectory = "/home/server";
nix = {
2024-06-04 16:16:30 +02:00
package = pkgs.nix;
settings.use-xdg-base-directories = true;
2024-06-03 21:04:20 +02:00
};
2024-06-04 00:53:01 +02:00
xdg.enable = true;
2024-06-10 16:28:16 +02:00
imports = [
2024-06-13 11:53:29 +02:00
(import ./utils/common.nix { inherit inputs config pkgs; })
(import ./utils/services.nix { inherit pkgs; scripts = scripts; })
./ssh
2024-06-10 16:28:16 +02:00
];
2024-06-04 22:13:24 +02:00
programs.ssh.matchBlocks."*".identityFile = "/home/server/.secrets/SSH/Mallorea/id_ed25519";
2024-06-03 21:04:20 +02:00
home.sessionVariables = {
2024-06-21 15:26:24 +02:00
NIX_PATH = "${config.xdg.stateHome}/nix/profiles/channels/";
2024-06-04 16:16:30 +02:00
LANG = "en_US.UTF-8";
XDG_RUNTIME_DIR = "/run/user/$(id -u)";
2024-06-03 21:04:20 +02:00
};
2024-06-14 20:54:59 +02:00
2024-06-14 22:10:48 +02:00
programs.zsh.initExtra = pkgs.lib.mkForce ''
2024-06-14 20:54:59 +02:00
LOCAL_SEARCH_DIRS=(~/.dotfiles/ ~/Containers ~/Workspace ~/Storage/Thomas ~/Storage/Shared)
REMOTE_SEARCH_DIRS=()
'';
2024-06-03 20:09:38 +02:00
}