Last active
December 1, 2017 12:46
-
-
Save cleverca22/5da6f037df2c7ea76211 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, pkgs, ... }: | |
{ | |
imports = [ ./default.nix /root/nixcfg/core.nix ]; | |
services = { | |
example = { | |
enable = true; | |
}; | |
}; | |
environment.systemPackages = with pkgs; [ wget tcpdump ltrace gdb ]; | |
networking.hostName = "nixos.example.com"; | |
networking.firewall.allowedTCPPorts = [ 80 ]; | |
virtualisation = { | |
memorySize = 512; | |
graphics = false; | |
qemu.networkingOptions = [ "-net nic,macaddr=52:54:00:12:34:01" "-net vde,sock=/run/vde.ctl" ]; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, pkgs, ... }: | |
{ | |
imports = [ ./default.nix /root/nixcfg/core.nix ]; | |
services = { | |
dhcpd = { | |
enable = true; | |
interfaces = [ "eth0" ]; | |
machines = [ | |
{ hostName = "nix1"; ethernetAddress = "52:54:00:12:34:01"; ipAddress = "192.168.3.11"; } | |
{ hostName = "nix2"; ethernetAddress = "52:54:00:12:34:02"; ipAddress = "192.168.3.12"; } | |
]; | |
extraConfig = '' | |
subnet 192.168.3.0 netmask 255.255.255.0 { | |
option subnet-mask 255.255.255.0; | |
option broadcast-address 192.168.3.255; | |
option routers 192.168.3.1; | |
option domain-name-servers 192.168.2.61; | |
range 192.168.3.100 192.168.3.200; | |
} | |
''; | |
}; | |
xserver = { | |
enable = true; | |
displayManager.slim = { | |
enable = true; | |
autoLogin = true; | |
defaultUser = "clever"; | |
}; | |
desktopManager.xfce = { | |
enable = true; | |
}; | |
}; | |
}; | |
environment.systemPackages = with pkgs; [ chromium wget nmap ]; | |
networking = { | |
hostName = "router"; | |
interfaces.eth0 = { | |
ipAddress = "192.168.3.1"; | |
prefixLength = 24; | |
}; | |
# nat = { | |
# enable = true; | |
# externalInterface = "eth0"; | |
# internalIPs = [ "192.168.3.0/24" ]; | |
# internalInterfaces = [ "eth1" ]; | |
# }; | |
}; | |
virtualisation = { | |
memorySize = 1024; | |
qemu.networkingOptions = [ | |
"-net nic,vlan=0,macaddr=52:54:00:12:34:00" | |
"-net vde,vlan=0,sock=/run/vde.ctl" | |
]; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ system ? builtins.currentSystem }: | |
let | |
loadcfg = cfgfile: { config, pkgs, ...}: { | |
imports = [ <nixos/modules/virtualisation/qemu-vm.nix> cfgfile ]; | |
config = { | |
networking.extraHosts = '' | |
192.168.3.11 nixos.example.com | |
192.168.3.12 nixos2.example.com | |
''; | |
virtualisation = { | |
}; | |
users.extraUsers.root.password = "root"; | |
}; | |
}; | |
mkcfg = cfgfile: | |
import <nixos/lib/eval-config.nix> { | |
inherit system; | |
modules = [ (loadcfg cfgfile) ]; | |
}; | |
in { | |
router = (mkcfg ./routercfg.nix).config.system.build.vm; | |
master = (mkcfg ./configuration.nix).config.system.build.vm; | |
slave = (mkcfg ./configuration2.nix).config.system.build.vm; | |
tox = (mkcfg ./tox.nix).config.system.build.vm; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment