Skip to content

Commit

Permalink
lab: move sshfs config into it's own nix file
Browse files Browse the repository at this point in the history
Related to #142
  • Loading branch information
ahayzen committed Jun 23, 2024
1 parent 705027e commit 4a40181
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 80 deletions.
81 changes: 1 addition & 80 deletions nixos/hosts/lab/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
inputs.nixos-hardware.nixosModules.common-cpu-intel-sandy-bridge
./hardware.nix
./periodic.nix
./sshfs.nix
];

# System76 Pangolin Performance uses BIOS so we need to disable systemd-boot and use grub
Expand Down Expand Up @@ -77,86 +78,6 @@
# Enable thermal control as this is an intel laptop
services.thermald.enable = true;

# Use SSHFS to mount folders from NAS for data and restic backups
system.fsPackages = [ pkgs.sshfs ];
fileSystems = lib.mkIf (!config.ahayzen.testing) {
mntbackuprestic = {
# TODO: can we use name?
# https://github.com/ahayzen/nix-config/issues/141
device = "[email protected]:/restic/repository";
mountPoint = "/mnt/backup-restic";
fsType = "sshfs";
options =
[
"_netdev"

"allow_other"

"IdentityFile=/etc/ssh/ssh_host_ed25519_key"
"Port=8022"

"reconnect"
"ServerAliveInterval=10"
"ServerAliveCountMax=3"

"follow_symlinks"

"idmap=user"
"uid=2000"
"gid=2000"
];
};
mntdata = {
# TODO: can we use name?
# https://github.com/ahayzen/nix-config/issues/141
device = "[email protected]:/restic/data";
mountPoint = "/mnt/data";
fsType = "sshfs";
options =
[
"_netdev"

# might need user_allow_other in fuse cofig?
"allow_other"

"IdentityFile=/etc/ssh/ssh_host_ed25519_key"
"Port=8022"

"reconnect"
"ServerAliveInterval=10"
"ServerAliveCountMax=3"

"follow_symlinks"

"idmap=user"
"uid=2000"
"gid=2000"
];
};
};

# Emulate sshfs mount folders for testing
systemd.tmpfiles.settings = lib.mkIf (config.ahayzen.testing) {
"99-sshfs-mount" = {
"/mnt/backup-restic" = {
d = {
age = "-";
group = "unpriv";
mode = "0750";
user = "unpriv";
};
};
"/mnt/data" = {
d = {
age = "-";
group = "unpriv";
mode = "0750";
user = "unpriv";
};
};
};
};

# Increase disk size for build VM
virtualisation.vmVariant.virtualisation.diskSize = 2 * 1024;
}
86 changes: 86 additions & 0 deletions nixos/hosts/lab/sshfs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# SPDX-FileCopyrightText: Andrew Hayzen <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

{ config, lib, pkgs, ... }:
{
# Use SSHFS to mount folders from NAS for data and restic backups
system.fsPackages = [ pkgs.sshfs ];
fileSystems = lib.mkIf (!config.ahayzen.testing) {
mntbackuprestic = {
# TODO: can we use name?
# https://github.com/ahayzen/nix-config/issues/141
device = "[email protected]:/restic/repository";
mountPoint = "/mnt/backup-restic";
fsType = "sshfs";
options =
[
"_netdev"

"allow_other"

"IdentityFile=/etc/ssh/ssh_host_ed25519_key"
"Port=8022"

"reconnect"
"ServerAliveInterval=10"
"ServerAliveCountMax=3"

"follow_symlinks"

"idmap=user"
"uid=2000"
"gid=2000"
];
};
mntdata = {
# TODO: can we use name?
# https://github.com/ahayzen/nix-config/issues/141
device = "[email protected]:/restic/data";
mountPoint = "/mnt/data";
fsType = "sshfs";
options =
[
"_netdev"

# might need user_allow_other in fuse cofig?
"allow_other"

"IdentityFile=/etc/ssh/ssh_host_ed25519_key"
"Port=8022"

"reconnect"
"ServerAliveInterval=10"
"ServerAliveCountMax=3"

"follow_symlinks"

"idmap=user"
"uid=2000"
"gid=2000"
];
};
};

# Emulate sshfs mount folders for testing
systemd.tmpfiles.settings = lib.mkIf (config.ahayzen.testing) {
"99-sshfs-mount" = {
"/mnt/backup-restic" = {
d = {
age = "-";
group = "unpriv";
mode = "0750";
user = "unpriv";
};
};
"/mnt/data" = {
d = {
age = "-";
group = "unpriv";
mode = "0750";
user = "unpriv";
};
};
};
};
}

0 comments on commit 4a40181

Please sign in to comment.