machines/sirius: finalize config
This commit is contained in:
21
machines/sirius/README.md
Normal file
21
machines/sirius/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
## How to setup this machine.
|
||||
|
||||
This machine cannot be setup the same way as other machines are setup. Meaning that `clan machine install` won't work. Because of `disko` issue. So, below is how the machine is setup.
|
||||
|
||||
1. Build an image to flash to an sd-card using
|
||||
|
||||
```
|
||||
nix build -L --show-trace .\#nixosConfigurations.sirius.config.system.build.images.sd-card
|
||||
```
|
||||
|
||||
2. Import the `zdata`
|
||||
|
||||
```
|
||||
zpool import zdata
|
||||
```
|
||||
|
||||
3. Update configuration
|
||||
|
||||
```
|
||||
clan machine update sirius
|
||||
```
|
||||
@@ -1,13 +1,20 @@
|
||||
{
|
||||
config,
|
||||
self,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
self.nixosModules.common
|
||||
|
||||
./hardware-configuration.nix
|
||||
];
|
||||
|
||||
image.modules.sd-card = {
|
||||
disabledModules = [
|
||||
./hardware-configuration.nix
|
||||
];
|
||||
};
|
||||
|
||||
clan.core.sops.defaultGroups = [ "admins" ];
|
||||
|
||||
nixpkgs.hostPlatform = {
|
||||
@@ -32,4 +39,35 @@
|
||||
options = "--delete-older-than 15d";
|
||||
};
|
||||
|
||||
boot.loader.grub.enable = false;
|
||||
boot.loader.generic-extlinux-compatible.enable = true;
|
||||
|
||||
boot.zfs.extraPools = [ "zdata" ];
|
||||
boot.supportedFilesystems = [ "zfs" ];
|
||||
boot.initrd.availableKernelModules = [
|
||||
"usb_storage"
|
||||
"sd_mod"
|
||||
];
|
||||
|
||||
fileSystems."/mnt/hdd" = {
|
||||
device = "zdata/nas";
|
||||
fsType = "zfs";
|
||||
mountPoint = "/mnt/hdd";
|
||||
options = [
|
||||
"nofail"
|
||||
"zfsutil"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib" = {
|
||||
device = "zdata/service-data";
|
||||
fsType = "zfs";
|
||||
mountPoint = "/var/lib";
|
||||
options = [
|
||||
"x-initrd.mount"
|
||||
"nofail"
|
||||
"zfsutil"
|
||||
];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
150
machines/sirius/disko-ref.nix
Normal file
150
machines/sirius/disko-ref.nix
Normal file
@@ -0,0 +1,150 @@
|
||||
{ lib, pkgs, ... }:
|
||||
let
|
||||
hashDisk = disk: "os-${builtins.substring 0 5 (builtins.hashString "sha256" disk)}";
|
||||
# os = "/dev/disk/by-id/mmc-SD64G_0x8336354b";
|
||||
vdev = [
|
||||
"/dev/disk/by-id/ata-ST20000NM002H-3KV133_ZYDBVV7Z"
|
||||
"/dev/disk/by-id/ata-ST20000NM002H-3KV133_ZYDBSJRE"
|
||||
];
|
||||
configTxt = pkgs.writeText "config.txt" ''
|
||||
[pi4]
|
||||
kernel=u-boot-rpi4.bin
|
||||
enable_gic=1
|
||||
|
||||
# Otherwise the resolution will be weird in most cases, compared to
|
||||
# what the pi3 firmware does by default.
|
||||
disable_overscan=1
|
||||
|
||||
# Supported in newer board revisions
|
||||
arm_boost=1
|
||||
|
||||
[all]
|
||||
# Boot in 64-bit mode.
|
||||
arm_64bit=1
|
||||
|
||||
# U-Boot needs this to work, regardless of whether UART is actually used or not.
|
||||
# Look in arch/arm/mach-bcm283x/Kconfig in the U-Boot tree to see if this is still
|
||||
# a requirement in the future.
|
||||
enable_uart=1
|
||||
|
||||
# Prevent the firmware from smashing the framebuffer setup done by the mainline kernel
|
||||
# when attempting to show low-voltage or overtemperature warnings.
|
||||
avoid_warnings=1
|
||||
'';
|
||||
in
|
||||
{
|
||||
|
||||
boot.loader = {
|
||||
systemd-boot = {
|
||||
enable = true;
|
||||
};
|
||||
efi = {
|
||||
canTouchEfiVariables = true;
|
||||
};
|
||||
};
|
||||
# boot.tmp.useTmpfs = true;
|
||||
|
||||
disko.devices = {
|
||||
disk = {
|
||||
# "os-${hashDisk os}" = {
|
||||
# type = "disk";
|
||||
# device = os;
|
||||
# content = {
|
||||
# type = "gpt";
|
||||
# partitions = {
|
||||
# firmware = {
|
||||
# size = "60M";
|
||||
# priority = 1;
|
||||
# type = "0700";
|
||||
# content = {
|
||||
# type = "filesystem";
|
||||
# format = "vfat";
|
||||
# mountpoint = "/firmware";
|
||||
# postMountHook = toString (
|
||||
# pkgs.writeScript "postMountHook.sh" ''
|
||||
# (cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf *.dtb /mnt/firmware/)
|
||||
# cp ${pkgs.ubootRaspberryPi4_64bit}/u-boot.bin /mnt/firmware/u-boot-rpi4.bin
|
||||
# cp ${configTxt} /mnt/firmware/config.txt
|
||||
# ''
|
||||
# );
|
||||
# };
|
||||
# };
|
||||
# ESP = {
|
||||
# size = "2G";
|
||||
# type = "EF00";
|
||||
# content = {
|
||||
# type = "filesystem";
|
||||
# format = "vfat";
|
||||
# mountpoint = "/boot";
|
||||
# mountOptions = [ "umask=0077" ];
|
||||
# };
|
||||
# };
|
||||
# root = {
|
||||
# name = "root";
|
||||
# end = "-0";
|
||||
# content = {
|
||||
# type = "filesystem";
|
||||
# format = "f2fs";
|
||||
# mountpoint = "/";
|
||||
# extraArgs = [
|
||||
# "-O"
|
||||
# "extra_attr,inode_checksum,sb_checksum,compression"
|
||||
# ];
|
||||
# mountOptions = [ "compress_algorithm=zstd:6,compress_chksum,atgc,gc_merge,lazytime,nodiscard" ];
|
||||
# };
|
||||
# };
|
||||
# };
|
||||
# };
|
||||
# };
|
||||
}
|
||||
// (lib.listToAttrs (
|
||||
map (disk: {
|
||||
name = "data-${hashDisk disk}";
|
||||
value = {
|
||||
type = "disk";
|
||||
device = disk;
|
||||
content = {
|
||||
type = "zfs";
|
||||
pool = "zdata";
|
||||
};
|
||||
};
|
||||
}) vdev
|
||||
));
|
||||
zpool = {
|
||||
zdata = {
|
||||
type = "zpool";
|
||||
options.ashift = "12";
|
||||
rootFsOptions = {
|
||||
mountpoint = "none";
|
||||
compression = "lz4";
|
||||
acltype = "posixacl";
|
||||
xattr = "sa";
|
||||
"com.sun:auto-snapshot" = "true";
|
||||
};
|
||||
mode = {
|
||||
topology = {
|
||||
type = "topology";
|
||||
vdev = [
|
||||
{
|
||||
mode = "mirror";
|
||||
members = vdev;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
datasets = {
|
||||
"nas" = {
|
||||
type = "zfs_fs";
|
||||
mountpoint = "/mnt/hdd";
|
||||
mountOptions = [ "nofail" ];
|
||||
};
|
||||
"service-data" = {
|
||||
type = "zfs_fs";
|
||||
mountpoint = "/var/lib";
|
||||
mountOptions = [ "nofail" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
{ lib, ... }:
|
||||
let
|
||||
hashDisk = disk: "os-${builtins.substring 0 5 (builtins.hashString "sha256" disk)}";
|
||||
os = "/dev/disk/by-id/mmc-SD64G_0x8336354b";
|
||||
vdev = [
|
||||
"/dev/disk/by-id/ata-ST20000NM002H-3KV133_ZYDBVV7Z"
|
||||
"/dev/disk/by-id/ata-ST20000NM002H-3KV133_ZYDBSJRE"
|
||||
];
|
||||
in
|
||||
{
|
||||
|
||||
boot.loader = {
|
||||
systemd-boot = {
|
||||
enable = true;
|
||||
};
|
||||
efi = {
|
||||
canTouchEfiVariables = true;
|
||||
};
|
||||
};
|
||||
boot.tmp.useTmpfs = true;
|
||||
|
||||
disko.devices = {
|
||||
disk = {
|
||||
"os-${hashDisk os}" = {
|
||||
type = "disk";
|
||||
device = os;
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
ESP = {
|
||||
end = "500M";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
mountOptions = [ "umask=0077" ];
|
||||
};
|
||||
};
|
||||
root = {
|
||||
name = "root";
|
||||
end = "-0";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "f2fs";
|
||||
mountpoint = "/";
|
||||
extraArgs = [
|
||||
"-O"
|
||||
"extra_attr,inode_checksum,sb_checksum,compression"
|
||||
];
|
||||
mountOptions = [ "compress_algorithm=zstd:6,compress_chksum,atgc,gc_merge,lazytime,nodiscard" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
// (lib.listToAttrs (
|
||||
map (disk: {
|
||||
name = "data-${hashDisk disk}";
|
||||
value = {
|
||||
type = "disk";
|
||||
device = disk;
|
||||
content = {
|
||||
type = "zfs";
|
||||
pool = "zdata";
|
||||
};
|
||||
};
|
||||
}) vdev
|
||||
));
|
||||
zpool = {
|
||||
zdata = {
|
||||
type = "zpool";
|
||||
options.ashift = "12";
|
||||
rootFsOptions = {
|
||||
mountpoint = "none";
|
||||
compression = "lz4";
|
||||
acltype = "posixacl";
|
||||
xattr = "sa";
|
||||
"com.sun:auto-snapshot" = "true";
|
||||
};
|
||||
mode = {
|
||||
topology = {
|
||||
type = "topology";
|
||||
vdev = [
|
||||
{
|
||||
mode = "mirror";
|
||||
members = vdev;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
datasets = {
|
||||
"nas" = {
|
||||
type = "zfs_fs";
|
||||
mountpoint = "/mnt/hdd";
|
||||
mountOptions = [ "nofail" ];
|
||||
};
|
||||
"service-data" = {
|
||||
type = "zfs_fs";
|
||||
mountpoint = "/var/lib";
|
||||
mountOptions = [ "nofail" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
6
machines/sirius/hardware-configuration.nix
Normal file
6
machines/sirius/hardware-configuration.nix
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-uuid/44444444-4444-4444-8888-888888888888";
|
||||
fsType = "ext4";
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user