Add support for persistent disks in the hydra iso.
This commit is contained in:
parent
2b20ab5123
commit
83de1e3708
@ -3,7 +3,7 @@
|
|||||||
# output: result/iso/nixos.iso
|
# output: result/iso/nixos.iso
|
||||||
|
|
||||||
# Run the ISO image
|
# Run the ISO image
|
||||||
# "$(nix-build '<nixpkgs>' --no-out-link -A 'qemu')/bin/qemu-system-x86_64" \
|
# doas "$(nix-build '<nixpkgs>' --no-out-link -A 'qemu')/bin/qemu-system-x86_64" \
|
||||||
# -accel kvm \
|
# -accel kvm \
|
||||||
# -cpu host \
|
# -cpu host \
|
||||||
# -smp cores=8 \
|
# -smp cores=8 \
|
||||||
@ -12,7 +12,7 @@
|
|||||||
# -drive if=pflash,format=raw,file="/tmp/OVMF_VARS.fd" \
|
# -drive if=pflash,format=raw,file="/tmp/OVMF_VARS.fd" \
|
||||||
# -nic user,hostfwd=tcp::60022-:22 \
|
# -nic user,hostfwd=tcp::60022-:22 \
|
||||||
# -boot order=d \
|
# -boot order=d \
|
||||||
# -cdrom "$(readlink -f ./result/iso/nixos.iso)" \
|
# -cdrom "$(readlink -f ./result/iso/nixos*.iso)" \
|
||||||
# -display vnc=127.0.0.1:0
|
# -display vnc=127.0.0.1:0
|
||||||
#
|
#
|
||||||
# doas cp "$(nix-build '<nixpkgs>' --no-out-link -A 'OVMF.fd')/FV/OVMF_VARS.fd" /tmp/OVMF_VARS.fd
|
# doas cp "$(nix-build '<nixpkgs>' --no-out-link -A 'OVMF.fd')/FV/OVMF_VARS.fd" /tmp/OVMF_VARS.fd
|
||||||
|
@ -1,9 +1,31 @@
|
|||||||
{ config, pkgs, ... }:
|
#
|
||||||
|
# Testing:
|
||||||
|
# doas "$(nix-build '<nixpkgs>' --no-out-link -A 'qemu')/bin/qemu-system-x86_64" \
|
||||||
|
# -accel kvm \
|
||||||
|
# -cpu host \
|
||||||
|
# -smp cores=8 \
|
||||||
|
# -m 32768 \
|
||||||
|
# -drive "file=$(nix-build '<nixpkgs>' --no-out-link -A 'OVMF.fd')/FV/OVMF.fd,if=pflash,format=raw,readonly=on" \
|
||||||
|
# -drive file=/tmp/localdisk.img,if=none,id=nvm,format=raw \
|
||||||
|
# -device nvme,serial=deadbeef,drive=nvm \
|
||||||
|
# -nic user,hostfwd=tcp::60022-:22 \
|
||||||
|
# -boot order=d \
|
||||||
|
# -cdrom "$(readlink -f /persist/machine_setup/nix/configuration/result/iso/nixos*.iso)" \
|
||||||
|
# -display vnc=127.0.0.1:0
|
||||||
|
#
|
||||||
|
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./hardware-configuration.nix
|
|
||||||
./disk-config.nix
|
./disk-config.nix
|
||||||
|
./hardware-configuration.nix
|
||||||
./optimized_build.nix
|
./optimized_build.nix
|
||||||
|
./vm_disk.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
# Generate with `head -c4 /dev/urandom | od -A none -t x4`
|
# Generate with `head -c4 /dev/urandom | od -A none -t x4`
|
||||||
@ -21,9 +43,10 @@
|
|||||||
|
|
||||||
me.emacs_flavor = "plainmacs";
|
me.emacs_flavor = "plainmacs";
|
||||||
me.graphical = false;
|
me.graphical = false;
|
||||||
me.zsh.enable = true;
|
me.vm_disk.enable = true;
|
||||||
me.wireguard.activated = [ ];
|
me.wireguard.activated = [ ];
|
||||||
me.wireguard.deactivated = [ ];
|
me.wireguard.deactivated = [ ];
|
||||||
|
me.zsh.enable = true;
|
||||||
|
|
||||||
# Trust this key so nix running as root can ssh into hydra.
|
# Trust this key so nix running as root can ssh into hydra.
|
||||||
users.users.talexander.openssh.authorizedKeys.keys = [
|
users.users.talexander.openssh.authorizedKeys.keys = [
|
||||||
|
77
nix/configuration/hosts/hydra/vm_disk.nix
Normal file
77
nix/configuration/hosts/hydra/vm_disk.nix
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ ];
|
||||||
|
|
||||||
|
options.me = {
|
||||||
|
vm_disk.enable = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
example = true;
|
||||||
|
description = "Whether we want to mount the local disk for persistent storage.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf config.me.vm_disk.enable (
|
||||||
|
lib.mkMerge [
|
||||||
|
{
|
||||||
|
# Mount the local disk
|
||||||
|
fileSystems = {
|
||||||
|
"/.disk" = lib.mkForce {
|
||||||
|
device = "/dev/nvme0n1p1";
|
||||||
|
fsType = "ext4";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"discard"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/persist" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.disk/persist";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.disk/persist"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
"/state" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.disk/state";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.disk/state"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
"/nix/store" = lib.mkForce {
|
||||||
|
fsType = "overlay";
|
||||||
|
device = "overlay";
|
||||||
|
options = [
|
||||||
|
"lowerdir=/nix/.ro-store"
|
||||||
|
"upperdir=/.disk/persist/store"
|
||||||
|
"workdir=/.disk/state/work"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/nix/.ro-store"
|
||||||
|
"/.disk/persist/store"
|
||||||
|
"/.disk/state/work"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user