diff --git a/README.md b/README.md index 2233a95..ed5406b 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,5 @@ [![Test](https://github.com/klarkc/os/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/klarkc/os/actions/workflows/test.yml?query=branch%3Amain) -This is my brand new attempt to use NixOS as my personal OS. +Personal collection of NixOS machines. + diff --git a/flake.nix b/flake.nix index c49d4b3..dca1ad1 100644 --- a/flake.nix +++ b/flake.nix @@ -23,7 +23,7 @@ else nixosSystem options; # TODO: find a faster way to run vm in devShell - mkRecoverVm = efi: name: args: pkgs.writeShellApplication { + mkVirtualMachine = efi: name: args: pkgs.writeShellApplication { name = "${name}-vm"; text = '' IMG="${name}-efi.img" @@ -47,19 +47,23 @@ { nixosConfigurations = { inherit (machines.recover) recover-os; + inherit (machines.cache) cache-os; }; packages.${system} = { inherit (machines.recover) recover-efi recover-vm recover-kvm; + inherit (machines.cache) cache-efi cache-vm cache-kvm; }; devShells.${system}.default = pkgs.mkShell { packages = - with machines.recover; [ - recover-vm - recover-kvm + with machines; [ + recover.recover-vm + recover.recover-kvm + cache.cache-vm + cache.cache-kvm ]; }; diff --git a/machines/cache/default.nix b/machines/cache/default.nix new file mode 100644 index 0000000..5c266aa --- /dev/null +++ b/machines/cache/default.nix @@ -0,0 +1,45 @@ +{ system, lib, pkgs, ... }: +let + inherit (lib) mkSystem mkVirtualMachine; + inherit (pkgs.lib) mkDefault; + cache-module = { + networking = { + hostName = "cache-os"; + networkmanager.enable = true; + }; + boot = { + kernelParams = [ + "copytoram" + "console=ttyS0,115200" + "console=tty1" + "boot.shell_on_fail" + ]; + loader = { + timeout = 15; + grub = { + enable = true; + device = "nodev"; + efiSupport = true; + useOSProber = true; + }; + }; + }; + fileSystems."/".device = mkDefault "none"; + }; +in +rec { + cache-os = mkSystem { + inherit system; + modules = [ cache-module ]; + }; + + cache-efi = mkSystem { + inherit system; + modules = [ cache-module ]; + format = "raw-efi"; + }; + + cache-vm = mkVirtualMachine cache-efi "cache" ""; + + cache-kvm = mkVirtualMachine cache-efi "cache" "--enable-kvm"; +} diff --git a/machines/default.nix b/machines/default.nix index e8fb32d..c7080b5 100644 --- a/machines/default.nix +++ b/machines/default.nix @@ -1,4 +1,5 @@ ctx: { recover = import ./recover ctx; + cache = import ./cache ctx; } diff --git a/machines/recover/default.nix b/machines/recover/default.nix index da21b1f..83721f9 100644 --- a/machines/recover/default.nix +++ b/machines/recover/default.nix @@ -1,6 +1,6 @@ { system, lib, pkgs, ... }: let - inherit (lib) mkSystem mkRecoverVm; + inherit (lib) mkSystem mkVirtualMachine; inherit (pkgs.lib) mkDefault; recover-module = { nix = { @@ -132,7 +132,7 @@ rec { format = "raw-efi"; }; - recover-vm = mkRecoverVm recover-efi "recover" ""; + recover-vm = mkVirtualMachine recover-efi "recover" ""; - recover-kvm = mkRecoverVm recover-efi "recover" "--enable-kvm"; + recover-kvm = mkVirtualMachine recover-efi "recover" "--enable-kvm"; }