Nixos-shell: Difference between revisions
imported>Onny Initial page |
imported>Onny mNo edit summary |
||
Line 23: | Line 23: | ||
</nowiki>}} | </nowiki>}} | ||
In this example, we'll have a virtual guest machine running an instance of [[ | In this example, we'll have a virtual guest machine running an instance of [[Dokuwiki]] on port <code>80</code>. Start the VM while forwarding port <code>8080</code> on the host to port <code>80</code> on the guest | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 29: | Line 29: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
After the VM is successfully booted, | After the VM is successfully booted, Dokuwiki will be available on http://localhost:8080 |
Revision as of 14:10, 24 October 2023
Nixos-shell is a small helper script for spawning lightweight NixOS virtual machines in a shell.
Installation
Add following line to your system configuration to install the program
environment.systemPackages = [ pkgs.nixos-shell ];
Usage
Create a signle example file containing the system configuration for the virtual machine
myvm.nix
{ pkgs, ... }: {
services.dokuwiki.sites."localhost" = {
enable = true;
settings.title = "My Wiki";
};
};
In this example, we'll have a virtual guest machine running an instance of Dokuwiki on port 80
. Start the VM while forwarding port 8080
on the host to port 80
on the guest
QEMU_NET_OPTS="hostfwd=tcp::8080-:80" nixos-shell myvm.nix
After the VM is successfully booted, Dokuwiki will be available on http://localhost:8080