Start reworking the server for nix flakes
This removes all existing services as well, in preparation of moving them to `podman`. These are easier to update to virtualisation.oci-containers while retaining the "networks" through pods.
This commit is contained in:
parent
ce1a3fc3c1
commit
5e87a5ec0c
23 changed files with 183 additions and 973 deletions
55
README.md
55
README.md
|
@ -6,51 +6,30 @@ This is the NixOS configuration for [tlater.net](https://tlater.net/).
|
|||
|
||||
### Building
|
||||
|
||||
To test locally in a VM, [nix](https://nixos.org/nix/) is
|
||||
required. Using a properly-configured nix, a qemu-based VM running the
|
||||
server can be created by first applying the following patch to disable
|
||||
hardware-specific configuration:
|
||||
|
||||
```patch
|
||||
diff --git a/etc/nixos/configuration.nix b/etc/nixos/configuration.nix
|
||||
index 387113d..aabee88 100644
|
||||
--- a/etc/nixos/configuration.nix
|
||||
+++ b/etc/nixos/configuration.nix
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
{
|
||||
imports = [
|
||||
- ./hardware-configuration.nix
|
||||
- ./linode.nix
|
||||
+ # ./hardware-configuration.nix
|
||||
+ # ./linode.nix
|
||||
];
|
||||
|
||||
networking = {
|
||||
```
|
||||
|
||||
Then building the VM with:
|
||||
Build the VM with:
|
||||
|
||||
```
|
||||
nix-build '<nixpkgs/nixos>' -A vm -k -I nixos-config=./configuration.nix
|
||||
nixos-rebuild build-vm --flake '.#vm'
|
||||
```
|
||||
|
||||
### Running
|
||||
|
||||
To invoke the VM, use:
|
||||
Running should *mostly* be as simple as running the command the build
|
||||
script echos.
|
||||
|
||||
```
|
||||
QEMU_NET_OPTS="hostfwd=tcp::2222-:2222,hostfwd=tcp::8000-:80" ./result/bin/run-tlater.net-vm
|
||||
One caveat: create a larger disk image first. This can be done by
|
||||
running the following in the repository root:
|
||||
|
||||
```bash
|
||||
qemu-img create -f qcow2 ./tlaternet.qcow2 20G
|
||||
```
|
||||
|
||||
This will set up a qemu VM with ports 2222 linked to the ssh port, and
|
||||
8000 to the http port. If other ports are required, adjust the
|
||||
environment variable (notably, ssl is provided by the image, although
|
||||
it should not work since it is unlikely that letsencrypt will supply
|
||||
any certificates).
|
||||
Everything else should be handled by the devShell.
|
||||
|
||||
Note that other environment variables are available (such as one for
|
||||
disabling the qt GUI, probably handy for eventual CI). They are listed
|
||||
under "Building a service as a VM (for testing)"
|
||||
[here](https://nixos.wiki/wiki/Cheatsheet) (not linked since the page
|
||||
isn't set up very nicely).
|
||||
### New services
|
||||
|
||||
Whenever a new service is added, append an appropriate
|
||||
`,hostfwd=::3<port>:<port>` to the `QEMU_NET_OPTS` specified in
|
||||
`flake.nix` to bind the service to a host port.
|
||||
|
||||
There is no way to test this without binding to the host port, sadly.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue