Pihole: finishing touches for external storage
This commit is contained in:
parent
8c661ce914
commit
4fda2ebe85
|
@ -8,6 +8,54 @@
|
||||||
let
|
let
|
||||||
stateVersion = "24.05";
|
stateVersion = "24.05";
|
||||||
hostName = "Pihole";
|
hostName = "Pihole";
|
||||||
|
|
||||||
|
# Script to unlock /sda and create /home symlinks, mount /swap, etc.
|
||||||
|
start-pihole_script = pkgs.writeShellScriptBin "start-pihole" ''
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Script to unlock the /sda partition and setup its files.
|
||||||
|
|
||||||
|
# check if the current user is root
|
||||||
|
if [ "$(id -u)" != "0" ]; then
|
||||||
|
echo "This script must be run as root" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Immediately exit on any errors
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# local storage partition
|
||||||
|
echo "Unlocking storage partition:"
|
||||||
|
cryptsetup luksOpen /dev/disk/by-uuid/b09893d7-cc1f-4482-bf7a-126d03923b45 sda
|
||||||
|
|
||||||
|
# mount local storage
|
||||||
|
if [ ! -f /dev/mapper/sda ]; then
|
||||||
|
echo "Mounting and symlinking home:"
|
||||||
|
mount -o relatime /dev/mapper/sda /sda
|
||||||
|
|
||||||
|
if [ $? -eq "0" ]; then
|
||||||
|
# Symlink @home files out into my actual home
|
||||||
|
# See https://superuser.com/a/633610
|
||||||
|
|
||||||
|
ln -s sda/@home/* /home/aires
|
||||||
|
else
|
||||||
|
echo "Failed to mount @home"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Mounting and symlinking swap:"
|
||||||
|
mount -o subvol=@swap,noatime /dev/mapper/sda /swap
|
||||||
|
|
||||||
|
if [ $? -eq "0" ]; then
|
||||||
|
swapon /swap/swapfile
|
||||||
|
else
|
||||||
|
echo "Failed to mount swap"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Failed to unlock sda."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ ./hardware-configuration.nix ];
|
imports = [ ./hardware-configuration.nix ];
|
||||||
|
@ -37,9 +85,10 @@ in
|
||||||
btrfs-progs
|
btrfs-progs
|
||||||
cryptsetup
|
cryptsetup
|
||||||
libraspberrypi
|
libraspberrypi
|
||||||
|
linuxKernel.kernels.linux_rpi4
|
||||||
raspberrypifw
|
raspberrypifw
|
||||||
raspberrypi-eeprom
|
raspberrypi-eeprom
|
||||||
linuxKernel.kernels.linux_rpi4
|
start-pihole_script
|
||||||
];
|
];
|
||||||
services = {
|
services = {
|
||||||
autoUpgrade = {
|
autoUpgrade = {
|
||||||
|
|
|
@ -17,17 +17,13 @@
|
||||||
"dtparam=audio=on"
|
"dtparam=audio=on"
|
||||||
];
|
];
|
||||||
|
|
||||||
# Configure bootloader
|
# Switch to a compatible bootloader
|
||||||
loader = lib.mkForce {
|
loader = lib.mkForce {
|
||||||
grub.enable = false;
|
grub.enable = false;
|
||||||
generic-extlinux-compatible.enable = true;
|
generic-extlinux-compatible.enable = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#boot.kernelParams = [
|
|
||||||
# "console=serial0,115200n8"
|
|
||||||
#];
|
|
||||||
|
|
||||||
fileSystems."/" = {
|
fileSystems."/" = {
|
||||||
device = "/dev/disk/by-uuid/44444444-4444-4444-8888-888888888888";
|
device = "/dev/disk/by-uuid/44444444-4444-4444-8888-888888888888";
|
||||||
fsType = "ext4";
|
fsType = "ext4";
|
||||||
|
@ -38,13 +34,6 @@
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
swapDevices = [
|
|
||||||
{
|
|
||||||
device = "/swapfile";
|
|
||||||
size = 2048;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
hardware = {
|
hardware = {
|
||||||
enableRedistributableFirmware = true;
|
enableRedistributableFirmware = true;
|
||||||
raspberry-pi."4" = {
|
raspberry-pi."4" = {
|
||||||
|
|
Loading…
Reference in a new issue