|
|
@ -1,7 +1,7 @@ |
|
|
|
--- |
|
|
|
title: "NixOS inside LXC on Proxmox" |
|
|
|
summary: "A guide on creating NixOS LXC containers inside of proxmox" |
|
|
|
date: 2021-02-23T13:27:48+01:00 |
|
|
|
lastmod: 2021-11-13T16:48:42+01:00 |
|
|
|
draft: false |
|
|
|
keywords: |
|
|
|
- LXC |
|
|
@ -15,7 +15,7 @@ categories: |
|
|
|
- Homelab |
|
|
|
--- |
|
|
|
|
|
|
|
This tutorial will explain how to install NixOS as an LXC container inside of proxmox. |
|
|
|
This guide will explain how to install NixOS as an LXC container inside of proxmox. |
|
|
|
Do be warned that this setup isn't extensively tested for stability or officially supported. |
|
|
|
|
|
|
|
# Getting the container tarball |
|
|
@ -29,30 +29,32 @@ mv nixos-system-x86_64-linux.tar.xz nixos-$RELEASE-default_$BUILDID_amd64.tar.xz |
|
|
|
``` |
|
|
|
|
|
|
|
## Uploading to proxmox |
|
|
|
Uploading it to proxmox is quite easy just go to your storage, |
|
|
|
Uploading it to proxmox is quite easy: just go to your storage, |
|
|
|
most likely called "local" then to "CT Templates" and click on upload and upload the tarball. |
|
|
|
|
|
|
|
{{< webm path="webm/upload-nixos-container.webm" >}} |
|
|
|
|
|
|
|
# Creating the container |
|
|
|
To create the container on proxmox we need to either `ssh` into it or use the web shell. |
|
|
|
After in a shell on the proxmox host execute the following command. But, make sure you understand what the options |
|
|
|
After in a shell on the proxmox host execute the following command. However, make sure you understand what the options |
|
|
|
do before executing it. You can see the [proxmox docs][proxmox-lxc] if you are unsure. |
|
|
|
|
|
|
|
```sh |
|
|
|
pct create $(nextid) \ |
|
|
|
pct create $(pvesh get /cluster/nextid) \ |
|
|
|
--arch amd64 \ |
|
|
|
--description nixos-template \ |
|
|
|
local:vztmpl/nixos-$RELEASE-default_$BUILDID_amd64.tar.xz \ |
|
|
|
--ostype unmanaged \ |
|
|
|
--net0 name=eth0 \ |
|
|
|
--storage local-lvm \ |
|
|
|
--storage local-zfs \ |
|
|
|
--unprivileged 1 |
|
|
|
``` |
|
|
|
|
|
|
|
after running this the container should show up in the Proxmox Web UI. |
|
|
|
|
|
|
|
## Fix LXC config |
|
|
|
> This step is only necessary if you are using nix older than 21.11, if using a newer version feel free to skip |
|
|
|
|
|
|
|
After creating the container we need to make a simple edit to the lxc config file located in `/etc/pve/lxc/$ID.conf`, |
|
|
|
`$ID` being the ID you passed in the previous step, if unsure you can check the web UI. |
|
|
|
|
|
|
@ -94,7 +96,7 @@ Finally we need to add a small tweak inside of `/etc/nixos/configuration.nix`. W |
|
|
|
supress some systemds unit as they will otherwise error upon |
|
|
|
every invocation of `nixos-rebuild switch` which can be annoying. |
|
|
|
```nix |
|
|
|
# Supress sys-kernel-debug |
|
|
|
# Supress systemd units that don't work because of LXC |
|
|
|
systemd.suppressedSystemUnits = [ |
|
|
|
"dev-mqueue.mount" |
|
|
|
"sys-kernel-debug.mount" |
|
|
@ -117,7 +119,7 @@ This guide is based heavily on the resources below |
|
|
|
* [NixOS issue 2 on LXC][nixos-issue-2] |
|
|
|
* [Nix Generate issue on LXC][nix-generate-issue] |
|
|
|
|
|
|
|
[nixos-tar]: https://hydra.nixos.org/job/nixos/release-20.09/nixos.containerTarball.x86_64-linux |
|
|
|
[nixos-tar]: https://hydra.nixos.org/job/nixos/trunk-combined/nixos.containerTarball.x86_64-linux |
|
|
|
[nixos-lxc]: https://nixos.wiki/wiki/Proxmox_Linux_Container |
|
|
|
[proxmox-lxc]: https://pve.proxmox.com/wiki/Linux_Container |
|
|
|
[nixos-issue-1]: https://github.com/NixOS/nixpkgs/issues/9735 |
|
|
|