mirror of
https://github.com/0xbbjubjub/miniguest.git
synced 2024-09-11 05:55:35 +03:00
add defaultTemplate
This commit is contained in:
parent
84d66f158a
commit
4c4b9126fd
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
.direnv
|
||||
result*
|
||||
|
||||
/template/flake.lock
|
||||
|
12
README.md
12
README.md
@ -34,6 +34,14 @@ second command.
|
||||
|
||||
[flakes]: https://nixos.wiki/wiki/Flakes
|
||||
|
||||
## Getting started
|
||||
|
||||
You base your flake on the template. Copy the `template/` directory from the
|
||||
repository, or run:
|
||||
```sh
|
||||
nix flake new -t github:bbjubjub2494/miniguest
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Guest system configuration must be presented within a Nix flake, import the
|
||||
@ -43,9 +51,7 @@ Guest system configuration must be presented within a Nix flake, import the
|
||||
sudo miniguest install «flakePath»#«guestName»
|
||||
```
|
||||
The configuration will then be built and will appear under
|
||||
`/etc/miniguests/«guestName»`. Refer to [this
|
||||
template](templates/libvirt-kvm.xml) to create the corresponding libvirt
|
||||
domain.
|
||||
`/etc/miniguests/«guestName»`.
|
||||
|
||||
It is recommended to create at most one domain per configuration so that they
|
||||
can all be rebuilt independently of each other.
|
||||
|
@ -11,6 +11,10 @@
|
||||
overlay = final: prev: {
|
||||
miniguest = final.callPackage ./miniguest { };
|
||||
};
|
||||
defaultTemplate = {
|
||||
description = "Example guest configurations";
|
||||
path = ./template;
|
||||
};
|
||||
} // simpleFlake {
|
||||
inherit self nixpkgs;
|
||||
name = "miniguest";
|
||||
|
7
template/README.md
Normal file
7
template/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# My Miniguest guests
|
||||
|
||||
To create and start a VM, run
|
||||
```sh
|
||||
sudo miniguest install .#stateless
|
||||
virsh create --console --autodestroy guests/stateless/domain.xml
|
||||
```
|
18
template/flake.nix
Normal file
18
template/flake.nix
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
description = "My Miniguest guests";
|
||||
|
||||
inputs = {
|
||||
nixos.url = "nixpkgs/nixos-unstable";
|
||||
miniguest.url = "github:bbjubjub2494/miniguest";
|
||||
miniguest.inputs.nixpkgs.follows = "nixos";
|
||||
};
|
||||
|
||||
outputs = { self, miniguest, nixos }:
|
||||
with nixos.lib; {
|
||||
nixosConfigurations = attrsets.genAttrs [ "stateless" ] (name:
|
||||
nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [ miniguest.nixosModules.miniguest (./guests + "/${name}") ];
|
||||
});
|
||||
};
|
||||
}
|
19
template/guests/stateless/default.nix
Normal file
19
template/guests/stateless/default.nix
Normal file
@ -0,0 +1,19 @@
|
||||
{ modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
# Use miniguest
|
||||
boot.loader.grub.enable = false;
|
||||
boot.miniguest.enable = true;
|
||||
|
||||
fileSystems."/" = {
|
||||
device = "none";
|
||||
fsType = "tmpfs";
|
||||
options = [ "defaults" "mode=755" ];
|
||||
};
|
||||
|
||||
users.users.root.hashedPassword = "";
|
||||
}
|
28
template/guests/stateless/domain.xml
Normal file
28
template/guests/stateless/domain.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<domain type="kvm">
|
||||
<name>stateless-example-miniguest</name>
|
||||
<metadata>
|
||||
<libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
|
||||
<libosinfo:os id="http://nixos.org/nixos/unstable"/>
|
||||
</libosinfo:libosinfo>
|
||||
</metadata>
|
||||
<os>
|
||||
<type>hvm</type>
|
||||
<kernel>/etc/miniguests/stateless/kernel</kernel>
|
||||
<initrd>/etc/miniguests/stateless/initrd</initrd>
|
||||
<cmdline>console=ttyS0</cmdline>
|
||||
</os>
|
||||
<memory unit="GiB">1</memory>
|
||||
<devices>
|
||||
<serial type="pty"/>
|
||||
<filesystem type="mount" accessmode="squash">
|
||||
<source dir="/nix/store"/>
|
||||
<target dir="nix-store"/>
|
||||
<readonly/>
|
||||
</filesystem>
|
||||
<filesystem type="mount" accessmode="squash">
|
||||
<source dir="/etc/miniguests/stateless/boot"/>
|
||||
<target dir="boot"/>
|
||||
<readonly/>
|
||||
</filesystem>
|
||||
</devices>
|
||||
</domain>
|
@ -1,17 +0,0 @@
|
||||
<domain type="kvm">
|
||||
<name>@guestName@</name>
|
||||
<os>
|
||||
<kernel>@guestsDir@/@guestName@/kernel</kernel>
|
||||
<initrd>@guestsDir@/@guestName@/initrd</initrd>
|
||||
</os>
|
||||
<filesystem type="mount" accessmode="squash">
|
||||
<source dir="/nix/store"/>
|
||||
<target dir="nix-store"/>
|
||||
<readonly/>
|
||||
</filesystem>
|
||||
<filesystem type="mount" accessmode="squash">
|
||||
<source dir="@guestsDir@/@guestName@/boot"/>
|
||||
<target dir="boot"/>
|
||||
<readonly/>
|
||||
</filesystem>
|
||||
</domain>
|
Loading…
Reference in New Issue
Block a user