Skip to content

Commit

Permalink
feat(cache): add cache os
Browse files Browse the repository at this point in the history
  • Loading branch information
klarkc committed Dec 19, 2023
1 parent 9bb76c2 commit 8e98f01
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

12 changes: 8 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
];

};
Expand Down
45 changes: 45 additions & 0 deletions machines/cache/default.nix
Original file line number Diff line number Diff line change
@@ -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";
}
1 change: 1 addition & 0 deletions machines/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ctx:
{
recover = import ./recover ctx;
cache = import ./cache ctx;
}
6 changes: 3 additions & 3 deletions machines/recover/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ system, lib, pkgs, ... }:
let
inherit (lib) mkSystem mkRecoverVm;
inherit (lib) mkSystem mkVirtualMachine;
inherit (pkgs.lib) mkDefault;
recover-module = {
nix = {
Expand Down Expand Up @@ -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";
}

0 comments on commit 8e98f01

Please sign in to comment.