Skip to content

Add externalDrives module to auto-mount known external drives#560

Open
goromal wants to merge 2 commits into
masterfrom
dev/drives
Open

Add externalDrives module to auto-mount known external drives#560
goromal wants to merge 2 commits into
masterfrom
dev/drives

Conversation

@goromal

@goromal goromal commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary

New externalDrives NixOS module (imported into pc-base.nix) that auto-mounts known external hard drives at fixed /mnt/<name> mount points whenever they happen to be connected — at boot or hot-plugged at any later time.

  • Each drive is declared by filesystem UUID (/dev/disk/by-uuid/…), so /dev/sd? renaming doesn't matter.
  • Mounts use nofail + x-systemd.automount (+ idle/device timeouts): boot never blocks when a drive is absent, the mount point always exists, and the drive mounts transparently on first access whenever present. Auto-unmounts after idle, so it's safe to unplug.
  • Foreign filesystems (ntfs/ntfs-3g/vfat/exfat, which lack Unix permissions) get uid/gid + dmask=007/fmask=117, so user andrew and the dev group always have read/write. Native filesystems (ext4, …) skip these and keep their on-disk permissions.

Default drives

Name UUID Filesystem Mount
seagate A4E83FF7E83FC5F8 NTFS (Seagate Backup Plus) /mnt/seagate
aegis 0259FC5C6268D54B NTFS (Apricorn Aegis Padlock SSD) /mnt/aegis

Adding more is a one-liner: machines.externalDrives.drives.<name>.uuid = "…";

Options

machines.externalDrives: enable (default true), user (default andrew), group (default dev), and drives (attrset of { uuid, fsType = "ntfs-3g", extraOptions = [] } keyed by mount-point name).

Testing

Deployed locally via anix-upgrade and verified on the Dell machine:

  • mnt-seagate.automount / mnt-aegis.automount active; both mount on access.
  • findmnt shows the ntfs-3g mounts; a touch as andrew succeeds and the created file is owned andrew:dev with mode -rw-rw---- (matches uid=1000,gid=1000,fmask=117).

🤖 Generated with Claude Code

Mounts known external drives at /mnt/<name> via nofail +
x-systemd.automount, so they mount transparently whenever connected
(at boot or hot-plugged later) and never block boot when absent.
Foreign filesystems (ntfs/vfat/exfat) get uid/gid + dmask/fmask so
andrew and the dev group always have read/write access.

Default drives: seagate (Seagate Backup Plus, NTFS) and aegis
(Apricorn Aegis Padlock SSD, NTFS). Imported into pc-base.nix.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@github-actions

Copy link
Copy Markdown

Change Description

Add externalDrives module to auto-mount known external drives

  • Add to global changelog

in
{
options.machines.externalDrives = {
enable = lib.mkOption {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this mkEnableOption instead, so it defaults to false and requires an additional line in pc-base.nix to set to true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants