This project aims to repurpose an old 2012 Mac mini as a Network Attached Storage (NAS) device. NixOS was chosen as the operating system due to its ease of installation, configuration, and the ability to create a live CD beforehand. This is not a step-by-step guide, but rather an observational guide.
Some blogs I recommend reading on the same subject.
- https://xeiaso.net/blog/my-homelab-nas-2021-11-29
- https://dataswamp.org/~solene/2020-10-18-nixos-nas.html
- https://www.codedbearder.com/posts/nixos-terramaster-f2-221/
I already own a Mac mini from 2012 that has been off for a number of years. Mac minis are known for their quietness, compactness, and the 2012 model can be upgraded for more storage.
Its my print server, I have a HP deskjet 1050 which is desperate for me to replace it. I'm not gonna let that happen (no matter how many surprise test pages it prints).
- Unscrew Macmini and upgrade the harddrive to solid state
- Create a liveCD, create a custom USB Installer with the wifi driver available
- Tests the liveCD via QEMU
- Install
There are a lot of tutorials on how to do this
- https://www.ifixit.com/Guide/Mac+mini+Late+2012+Hard+Drive+Replacement/11716
- https://www.imore.com/how-upgrade-2012-mac-mini
ifixit includes some tool requirements, I already own this https://www.amazon.co.uk/gp/product/B0189YWOIO, which included everything required.
The best tip I found was making a handle from tape (https://youtu.be/BP3oPq1I-iQ?t=419) when reinserting the SSD drive.
Nixos has an intuitive API for making livecd's.
Creating a USB installer that is custom for the Mac mini has the following advantages:
- WIFI Broadcom drivers, can be included in the installer
- Can Install over SSH
- Can set the username/password in the livecd
- Enable WiFi in the livecd
- Installer can include any additional programs e.g. vim, git
To create an installer I used QEMU running nixos in a virtual machine.
- The
nixos.iso
is an iso from Nixos Downloads - SSH is enabled, running
passwd
in the vm term to create a password may be required
qemu-system-x86_64 -enable-kvm -boot d \
-nic user,model=virtio-net-pci,hostfwd=tcp::10022-:22 \
-cdrom nixos.iso \
-m 4G -smp 2
Cloning this git repository in the VM and navigating to the livecd folder, the command I used to make the installer (this can be found on the above link):
nix-build '<nixpkgs/nixos>' -A config.system.build.isoImage -I nixos-config=iso.nix
After creating the .iso
it can be put onto a USB to be installed onto the Mac
mini (using tools like DD or cp
cp installer.iso /dev/sdX
I tested the iso before directly running on the mac, this gave me the opportunity to understand what to expect and also what to research before hand.
The following will create an image to install nixos
qemu-img create -f qcow2 nixos.img 15g
After creating the above image, running the following command with the iso
retrieved from the VM:
qemu-system-x86_64 -enable-kvm -boot d \
-nic user,model=virtio-net-pci,hostfwd=tcp::10022-:22 \
-cdrom nixos-macmini-installer.iso \
-m 4G -smp 2 -hda nixos.img
The nixos manual has a great tutorial on how to install:
https://nixos.org/manual/nixos/stable/index.html#sec-installation-manual
Regarding internet, if the iso.nix has not been edited the following commands can be used to connect to wifi
https://wiki.archlinux.org/title/NetworkManager#nmcli_examples
I have opted for a encrypted drive, and followed this tutorial:
https://gist.github.com/walkermalling/23cf138432aee9d36cf59ff5b63a2a58
And also this command which was missing when retrieving the UUID
lsblk -o NAME,SIZE,MOUNTPOINT,UUID
To opt for a USB drive to decrypt to decrypt the LUKS drive: