diff --git a/nix/configuration/flake.nix b/nix/configuration/flake.nix index 2ec40d6..d8880c3 100644 --- a/nix/configuration/flake.nix +++ b/nix/configuration/flake.nix @@ -3,7 +3,7 @@ # output: result/iso/nixos.iso # Run the ISO image -# "$(nix-build '' --no-out-link -A 'qemu')/bin/qemu-system-x86_64" \ +# doas "$(nix-build '' --no-out-link -A 'qemu')/bin/qemu-system-x86_64" \ # -accel kvm \ # -cpu host \ # -smp cores=8 \ @@ -12,7 +12,7 @@ # -drive if=pflash,format=raw,file="/tmp/OVMF_VARS.fd" \ # -nic user,hostfwd=tcp::60022-:22 \ # -boot order=d \ -# -cdrom "$(readlink -f ./result/iso/nixos.iso)" \ +# -cdrom "$(readlink -f ./result/iso/nixos*.iso)" \ # -display vnc=127.0.0.1:0 # # doas cp "$(nix-build '' --no-out-link -A 'OVMF.fd')/FV/OVMF_VARS.fd" /tmp/OVMF_VARS.fd diff --git a/nix/configuration/hosts/hydra/default.nix b/nix/configuration/hosts/hydra/default.nix index ae0f5e7..389dc33 100644 --- a/nix/configuration/hosts/hydra/default.nix +++ b/nix/configuration/hosts/hydra/default.nix @@ -1,9 +1,31 @@ -{ config, pkgs, ... }: +# +# Testing: +# doas "$(nix-build '' --no-out-link -A 'qemu')/bin/qemu-system-x86_64" \ +# -accel kvm \ +# -cpu host \ +# -smp cores=8 \ +# -m 32768 \ +# -drive "file=$(nix-build '' --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 = [ - ./hardware-configuration.nix ./disk-config.nix + ./hardware-configuration.nix ./optimized_build.nix + ./vm_disk.nix ]; # Generate with `head -c4 /dev/urandom | od -A none -t x4` @@ -21,9 +43,10 @@ me.emacs_flavor = "plainmacs"; me.graphical = false; - me.zsh.enable = true; + me.vm_disk.enable = true; me.wireguard.activated = [ ]; me.wireguard.deactivated = [ ]; + me.zsh.enable = true; # Trust this key so nix running as root can ssh into hydra. users.users.talexander.openssh.authorizedKeys.keys = [ diff --git a/nix/configuration/hosts/hydra/vm_disk.nix b/nix/configuration/hosts/hydra/vm_disk.nix new file mode 100644 index 0000000..43fef88 --- /dev/null +++ b/nix/configuration/hosts/hydra/vm_disk.nix @@ -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" + ]; + }; + }; + } + ] + ); +}