8000 Adding config for pve, qemu and vmware by stephenquoll · Pull Request #3 · Dogebox-WG/os · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Adding config for pve, qemu and vmware #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ VM_NAME = dogebox-$(shell date +%s)

pve:
@echo "Generating Proxmox LXC..."
@nixos-generate -c nix/default-builder.nix -f proxmox-lxc
@nixos-generate -c nix/pve-builder.nix -f proxmox-lxc

qemu:
@echo "Generating QEMU qcow2..."
@nixos-generate -c nix/qemu-builder.nix -f qcow

raw:
@echo "Generating raw image..."
@nixos-generate -c nix/default-builder.nix -f raw

virtualbox:
@echo "Generating VirtualBox OVA..."
Expand All @@ -17,4 +25,8 @@ virtualbox-launch: virtualbox
VBoxManage modifyvm "$(VM_NAME)" --nic1 bridged --bridgeadapter1 $$BRIDGE_ADAPTER && \
VBoxManage startvm "$(VM_NAME)"

.PHONY: pve qcow virtualbox virtualbox-launch
vmware:
@echo "Generating VMWare VMDK..."
@nixos-generate -c nix/vmware-builder.nix -f vmware

.PHONY: pve qemu raw virtualbox virtualbox-launch vmware
41 changes: 41 additions & 0 deletions nix/pve-builder.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{ pkgs, ... }:

let
pveFile = pkgs.writeTextFile {
name = "pve.nix";
text = builtins.readFile ./pve.nix;
};

baseFile = pkgs.writeTextFile {
name = "base.nix";
text = builtins.readFile ./base.nix;
};

dogeboxFile = pkgs.writeTextFile {
name = "dogebox.nix";
text = builtins.readFile ./dogebox.nix;
};

dogeboxdFile = pkgs.writeTextFile {
name = "dogeboxd.nix";
text = builtins.readFile ./dogeboxd.nix;
};

dkmFile = pkgs.writeTextFile {
name = "dkm.nix";
text = builtins.readFile ./dkm.nix;
};
in
{
imports = [ ./pve.nix ];

system.activationScripts.copyFiles = ''
mkdir -p /opt/nixos
echo "pve" >> /opt/build-type
cp ${pveFile} /etc/nixos/configuration.nix
cp ${baseFile} /etc/nixos/base.nix
cp ${dogeboxFile} /etc/nixos/dogebox.nix
cp ${dogeboxdFile} /etc/nixos/dogeboxd.nix
cp ${dkmFile} /etc/nixos/dkm.nix
'';
}
9 changes: 9 additions & 0 deletions nix/pve.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{ modulesPath, ... }:

{
imports = [
(modulesPath + "/virtualisation/proxmox-lxc.nix")
./base.nix
];

}
41 changes: 41 additions & 0 deletions nix/qemu-builder.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{ pkgs, ... }:

let
qemuFile = pkgs.writeTextFile {
name = "qemu.nix";
text = builtins.readFile ./qemu.nix;
};

baseFile = pkgs.writeTextFile {
name = "base.nix";
text = builtins.readFile ./base.nix;
};

dogeboxFile = pkgs.writeTextFile {
name = "dogebox.nix";
text = builtins.readFile ./dogebox.nix;
};

dogeboxdFile = pkgs.writeTextFile {
name = "dogeboxd.nix";
text = builtins.readFile ./dogeboxd.nix;
};

dkmFile = pkgs.writeTextFile {
name = "dkm.nix";
text = builtins.readFile ./dkm.nix;
};
in
{
imports = [ ./qemu.nix ];

system.activationScripts.copyFiles = ''
mkdir -p /opt/nixos
echo "qemu" >> /opt/build-type
cp ${qemuFile} /etc/nixos/configuration.nix
cp ${baseFile} /etc/nixos/base.nix
cp ${dogeboxFile} /etc/nixos/dogebox.nix
cp ${dogeboxdFile} /etc/nixos/dogeboxd.nix
cp ${dkmFile} /etc/nixos/dkm.nix
'';
}
25 changes: 25 additions & 0 deletions nix/qemu.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{ modulesPath, ... }:

10000 {
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
./base.nix
];

fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
autoResize = true;
fsType = "ext4";
};

fileSystems."/boot" = {
device = "/dev/disk/by-label/ESP";
fsType = "vfat";
};

boot.growPartition = true;

boot.loader.grub.device = "/dev/sda";

services.qemuGuest.enable = true;
}
43 changes: 43 additions & 0 deletions nix/vmware-builder.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{ pkgs, ... }:

let
vmwareFile = pkgs.writeTextFile {
name = "vmware.nix";
text = builtins.readFile ./vmware.nix;
};

baseFile = pkgs.writeTextFile {
name = "base.nix";
text = builtins.readFile ./base.nix;
};

dogeboxFile = pkgs.writeTextFile {
name = "dogebox.nix";
text = builtins.readFile ./dogebox.nix;
};

dogeboxdFile = pkgs.writeTextFile {
name = "dogeboxd.nix";
text = builtins.readFile ./dogeboxd.nix;
};

dkmFile = pkgs.writeTextFile {
name = "dkm.nix";
text = builtins.readFile ./dkm.nix;
};
in
{
imports = [ ./vmware.nix ];

vmware.baseImageSize = 6144;

system.activationScripts.copyFiles = ''
mkdir -p /opt/nixos
echo "vmware" >> /opt/build-type
cp ${vmwareFile} /etc/nixos/configuration.nix
cp ${baseFile} /etc/nixos/base.nix
cp ${dogeboxFile} /etc/nixos/dogebox.nix
cp ${dogeboxdFile} /etc/nixos/dogeboxd.nix
cp ${dkmFile} /etc/nixos/dkm.nix
'';
}
26 changes: 26 additions & 0 deletions nix/vmware.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
imports = [ ./base.nix ];

/* Below copied from ${nixpkgs}/nixos/modules/virtualization/vmware-image.nix */

fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
autoResize = true;
fsType = "ext4";
};

fileSystems."/boot" = {
device = "/dev/disk/by-label/ESP";
fsType = "vfat";
};

boot.growPartition = true;

boot.loader.grub = {
device = "nodev";
efiSupport = true;
efiInstallAsRemovable = true;
};

virtualisation.vmware.guest.enable = true;
}
1 change: 1 addition & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

pkgs.mkShell {
buildInputs = [
pkgs.gnumake
pkgs.nixos-generators
];
}
0