Skip to content

Commit

Permalink
Get gallium NAS up and running with a basic config
Browse files Browse the repository at this point in the history
  • Loading branch information
giodamelio committed Apr 15, 2024
1 parent 8f9ba27 commit 7c7165a
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Used to configure all of my machines

# Machines

There are currently 6 machines listed in the [data](./homelab.toml)
There are currently 7 machines listed in the [data](./homelab.toml)


- `cadmium`
Expand All @@ -19,6 +19,9 @@ There are currently 6 machines listed in the [data](./homelab.toml)
- `cesium`
- Description: Light development work on the go
- Hardware: Lenovo Chromebook Linux Developer Container
- `gallium`
- Description: Main NAS in the closet
- Hardware: QNAP NAS TS-462-2G
- `gio-pixel-7`
- Description: My Phone
- Hardware: Pixel 7 Pro
Expand Down
8 changes: 8 additions & 0 deletions homelab.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ targetUser = "server"
hardwareDescription = "Lenovo Chromebook Linux Developer Container"
useDescription = "Light development work on the go"

[machines.gallium]
hardwareDescription = "QNAP NAS TS-462-2G"
useDescription = "Main NAS in the closet"

[machines.gallium.deployment]
targetHost = "10.0.128.214"
targetUser = "server"

[machines.zirconium]
hardwareDescription = "VM Running in Hetzner Cloud"
useDescription = "Critical services running on a DigitalOcean VM"
Expand Down
15 changes: 15 additions & 0 deletions src/nixosConfigurations/gallium.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
root,
inputs,
...
}:
inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";

extraModules = [
# Not sure why this has to be an extraModule instead of a regular module
inputs.colmena.nixosModules.deploymentOptions
];

modules = [root.nixosModules.machines.gallium.default];
}
32 changes: 32 additions & 0 deletions src/nixosModules/machines/gallium/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
root,
inputs,
super,
homelab,
...
}: _: {
imports = [
# Disk layout
super.disko

# Hardware
super.hardware

# Encrypted Secrets
inputs.ragenix.nixosModules.default

# Basic packages I want on every system
root.nixosModules.basic-packages
root.nixosModules.basic-settings

# Add server user
root.nixosModules.users.server

(_: {
networking.hostId = "8425e349";

# Load the deployment config from our homelab.toml
inherit (homelab.machines.gallium) deployment;
})
];
}
79 changes: 79 additions & 0 deletions src/nixosModules/machines/gallium/disko.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{inputs, ...}: {
imports = [
inputs.disko.nixosModules.disko
];

config = {
disko.devices = {
disk = {
a = {
type = "disk";
device = "/dev/disk/by-id/nvme-WD_BLACK_SN770_1TB_23192N800112";
content = {
type = "gpt";
partitions = {
ESP = {
size = "1G";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
zfs = {
size = "100%";
content = {
type = "zfs";
pool = "boot";
};
};
};
};
};
};
zpool = {
boot = {
type = "zpool";
postCreateHook = "zfs snapshot boot@blank";
rootFsOptions = {
compression = "zstd";
mountpoint = "none";
};

datasets = {
reserve = {
type = "zfs_fs";
options = {
mountpoint = "none";
reservation = "5G";
};
};
root = {
type = "zfs_fs";
mountpoint = "/";
options = {
mountpoint = "legacy";
};
postCreateHook = "zfs snapshot boot/root@blank";
};
nix = {
type = "zfs_fs";
mountpoint = "/nix";
options = {
mountpoint = "legacy";
};
};
home = {
type = "zfs_fs";
mountpoint = "/home";
options = {
mountpoint = "legacy";
};
};
};
};
};
};
};
}
32 changes: 32 additions & 0 deletions src/nixosModules/machines/gallium/hardware.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
_: {
config,
lib,
...
}: {
boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "sd_mod" "sdhci_pci"];
boot.initrd.kernelModules = [];
boot.kernelModules = ["kvm-intel"];
boot.extraModulePackages = [];

networking.useDHCP = lib.mkDefault true;

time.timeZone = "America/Los_Angeles";

networking.hostName = "gallium";

boot.loader = {
systemd-boot = {
enable = true;
consoleMode = "auto";
netbootxyz.enable = true;
};

efi.canTouchEfiVariables = true;
};
boot.zfs.forceImportRoot = false;
boot.supportedFilesystems = ["zfs"];
boot.initrd.supportedFilesystems = ["zfs"];

nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

0 comments on commit 7c7165a

Please sign in to comment.