forked from DGNum/liminix
bordervm: make configurable
This commit is contained in:
parent
05576eeb94
commit
ef0b5cb815
2 changed files with 98 additions and 53 deletions
|
@ -1,8 +1,43 @@
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
{
|
let
|
||||||
|
cfg = config.bordervm;
|
||||||
|
inherit (lib) mkOption mdDoc types;
|
||||||
|
in {
|
||||||
|
options.bordervm = {
|
||||||
|
l2tp = {
|
||||||
|
host = mkOption {
|
||||||
|
description = mdDoc ''
|
||||||
|
Hostname or IP address of an L2TP LNS that this VM
|
||||||
|
will connect to when it receives a PPPoE connection request
|
||||||
|
'';
|
||||||
|
type = types.str;
|
||||||
|
example = "l2tp.example.org";
|
||||||
|
};
|
||||||
|
port = mkOption {
|
||||||
|
description = mdDoc ''
|
||||||
|
Port number, if non-standard, of the LNS.
|
||||||
|
'';
|
||||||
|
type = types.int;
|
||||||
|
default = 1701;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
ethernet = {
|
||||||
|
pciId = mkOption {
|
||||||
|
description = ''
|
||||||
|
Host PCI ID (as shown by `lspci`) of the ethernet adaptor
|
||||||
|
to be used by the VM. This uses VFIO and requires setup
|
||||||
|
on the emulation host before it will work!
|
||||||
|
'';
|
||||||
|
type = types.str;
|
||||||
|
example = "04:00.0";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
imports = [
|
imports = [
|
||||||
<nixpkgs/nixos/modules/virtualisation/qemu-vm.nix>
|
<nixpkgs/nixos/modules/virtualisation/qemu-vm.nix>
|
||||||
|
./bordervm.conf.nix
|
||||||
];
|
];
|
||||||
|
config = {
|
||||||
boot.kernelParams = [
|
boot.kernelParams = [
|
||||||
"loglevel=9"
|
"loglevel=9"
|
||||||
];
|
];
|
||||||
|
@ -11,7 +46,7 @@
|
||||||
''
|
''
|
||||||
interface_name = "eth1"
|
interface_name = "eth1"
|
||||||
services = [ "myservice" ]
|
services = [ "myservice" ]
|
||||||
lns_ipaddr = "90.155.53.19:1701"
|
lns_ipaddr = "${cfg.l2tp.host}:${builtins.toString cfg.l2tp.port}"
|
||||||
ac_name = "kpppoed-1.0"
|
ac_name = "kpppoed-1.0"
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
|
@ -33,7 +68,7 @@
|
||||||
qemu = {
|
qemu = {
|
||||||
networkingOptions = [];
|
networkingOptions = [];
|
||||||
options = [
|
options = [
|
||||||
"-device vfio-pci,host=01:00.0"
|
"-device vfio-pci,host=${cfg.ethernet.pciId}"
|
||||||
"-nographic"
|
"-nographic"
|
||||||
"-serial mon:stdio"
|
"-serial mon:stdio"
|
||||||
];
|
];
|
||||||
|
@ -67,4 +102,5 @@
|
||||||
extraGroups = [ "wheel"];
|
extraGroups = [ "wheel"];
|
||||||
};
|
};
|
||||||
services.getty.autologinUser = "liminix";
|
services.getty.autologinUser = "liminix";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
9
bordervm.conf-example.nix
Normal file
9
bordervm.conf-example.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{...}:
|
||||||
|
{
|
||||||
|
bordervm = {
|
||||||
|
ethernet.pciId = "01:00.0";
|
||||||
|
l2tp = {
|
||||||
|
host = "l2tp.aa.net.uk";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue