nixos-cesium/config/mounts.nix
2026-02-08 16:00:39 +01:00

115 lines
2.7 KiB
Nix

# /etc/nixos/mounts.nix
{ config, pkgs, ... }:
{
# Credentials-Datei als Template erstellen
environment.etc."nixos/setup-smb-credentials.sh" = {
text = ''
#!/bin/sh
CREDS_FILE="/etc/nixos/secrets/truenas2.local"
if [ -f "$CREDS_FILE" ]; then
echo "Credentials file already exists: $CREDS_FILE"
exit 0
fi
echo "Creating SMB credentials file..."
mkdir -p /etc/nixos/secrets
# Username aus Config oder abfragen
read -p "Enter SMB username: " username
read -sp "Enter SMB password: " password
echo
cat > "$CREDS_FILE" << EOF
username=$username
password=$password
domain=WORKGROUP
EOF
chmod 640 "$CREDS_FILE"
chown root:users "$CREDS_FILE"
echo "Credentials file created: $CREDS_FILE"
'';
mode = "0755";
};
# Mount-Verzeichnisse erstellen
systemd.tmpfiles.rules = [
"d /mnt/betrieb 0755 sebastian users - -"
"d /mnt/familie 0755 sebastian users - -"
"d /mnt/medien 0755 sebastian users - -"
"d /mnt/home 0755 sebastian users - -"
];
# CIFS/SMB Mounts
fileSystems."/mnt/betrieb" = {
device = "//truenas2.local.fischer.im/Betrieb";
fsType = "cifs";
options = [
"noauto"
"credentials=/etc/nixos/secrets/truenas2.local"
"x-systemd.automount"
"x-systemd.idle-timeout=60"
"x-systemd.device-timeout=10"
"uid=sebastian"
"gid=users"
"file_mode=0644"
"dir_mode=0755"
"vers=3.0"
];
};
fileSystems."/mnt/familie" = {
device = "//truenas2.local.fischer.im/Familie";
fsType = "cifs";
options = [
"noauto"
"credentials=/etc/nixos/secrets/truenas2.local"
"x-systemd.automount"
"x-systemd.idle-timeout=60"
"x-systemd.device-timeout=10"
"uid=sebastian"
"gid=users"
"file_mode=0644"
"dir_mode=0755"
"vers=3.0"
];
};
fileSystems."/mnt/medien" = {
device = "//truenas2.local.fischer.im/Medien";
fsType = "cifs";
options = [
"noauto"
"credentials=/etc/nixos/secrets/truenas2.local"
"x-systemd.automount"
"x-systemd.idle-timeout=60"
"x-systemd.device-timeout=10"
"uid=sebastian"
"gid=users"
"file_mode=0644"
"dir_mode=0755"
"vers=3.0"
];
};
fileSystems."/mnt/home" = {
device = "//truenas2.local.fischer.im/sebastian";
fsType = "cifs";
options = [
"noauto"
"credentials=/etc/nixos/secrets/truenas2.local"
"x-systemd.automount"
"x-systemd.idle-timeout=60"
"x-systemd.device-timeout=10"
"uid=sebastian"
"gid=users"
"file_mode=0644"
"dir_mode=0755"
"vers=3.0"
];
};
}