Hello everyone,
TL;DR: My Peertube container configuration doesn’t work and I don’t know why.
I am trying to run Peertube in a NixOS container with the following container configuration which is located in /etc/nixos/container.nix
.
containers.peertube = {
autoStart = true;
privateNetwork = true;
hostAddress = "192.168.100.17";
localAddress = "192.168.100.18";
config = {config, pkgs, ...}: {
system.stateVersion = "24.11";
environment.etc = {
"peertube/password-posgressql-db".text = "example_password";
"peertube/password-redis-db".text = "example_password";
"peertube/secrets".text = "example_password";
};
services = {
peertube = {
package = pkgs.peertube;
listenWeb = 9000;
enable = true;
settings = {
listen = {
hostname = "0.0.0.0";
};
log = {
level = "debug";
};
storage = {
tmp = "/opt/data/peertube/storage/tmp";
logs = "/opt/data/peertube/storage/logs/";
cache = "/opt/data/peertube/storage/cache/";
};
};
group = "peertube";
enableWebHttps = false;
user = "peertube";
# redis.createLocally = false;
redis.createLocally = true;
localDomain = "127.0.0.1";
configureNginx = false;
smtp.createLocally = false;
listenHttp = 9000;
# database.createLocally = false;
database.createLocally = true;
secrets.secretsFile = "/etc/peertube/secrets";
smtp.passwordFile = null;
serviceEnvironmentFile = null;
redis.port = null;
redis.passwordFile = "/etc/peertube/password-redis-db";
redis.host = null;
redis.enableUnixSocket = true;
database.user = "peertube";
database.port = 5432;
database.passwordFile = "/etc/peertube/password-postgresql";
database.name = "peertube";
database.host = "/run/postgresql";
dataDirs = [ "/var/www/peertube" ];
};
};
};
};
A container is created, but the Peertube service fails to start. The following error is given when running the executable manually.
sudo nixos-container root-login peertube
[root@peertube:~]# /nix/store/6nyjcd5nrpp3g0csak0vw53nh4v66b1v-unit-script-peertube-start/bin/peertube-start
cat: /run/secrets/peertube: No such file or directory
cat: /run/keys/peertube/password-redis-db: No such file or directory
/nix/store/6nyjcd5nrpp3g0csak0vw53nh4v66b1v-unit-script-peertube-start/bin/peertube-start: line 20: exec: node: not found
I am confused by this error because the files given are defaults or examples to options which were overwritten in the container configuration, specifically the redis.passwordFile
and secrets.secretsFile
from the NixOS options documentation. These could be remnants from a previous configuration. I have tried to recreate the container with nixos-rebuild switch
and nixos-container destroy
, but these commands were unsuccessful. The nixos-container destroy
command gives the following output instructing me to remove it from the configuration instead.
nixos-container destroy peertube
/run/current-system/sw/bin/nixos-container: cannot destroy declarative container (remove it from your configuration.nix instead)
I am assuming that rebuilding the system configuration file does not destroy and recreate the entire container because databases would need to be preserved, but it seems like rebuilding the container in this case does not even transform trivial files to match a new state.
What is the correct way to rebuild a container after changing the configuration? Or if my assumption about the problem is incorrect, what could I do to further investigate the issue?
If I create a separate container, peertubeA
, the errors about the password files being located in the incorrect locations disappear, but I still get a similar error:
/nix/store/ikaa3jhx93763aq9p7blmm28mlz0yc4x-unit-script-peertube-start/bin/peertube-start
/nix/store/ikaa3jhx93763aq9p7blmm28mlz0yc4x-unit-script-peertube-start/bin/peertube-start: line 20: exec: node: not found
And systemctl posts the same status for both scenarios:
...(code=exited, status=226/NAMESPACE)
The error message implies that node is missing, but installing node
(fetched from the nix source, I don’t know why it wasn’t installed to begin with) still doesn’t fully resolve the issue. Adding the following gives a different error.
environment.systemPackages = with pkgs; [
nodejs_18
yarn
ffmpeg-headless
openssl
];
/nix/store/2ymkvkvr2sk4xl705gyad13x33r1lfvb-unit-script-peertube-start/bin/peertube-start
node:internal/modules/cjs/loader:1143
throw err;
^
Error: Cannot find module '/root/dist/server'
at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
at Module._load (node:internal/modules/cjs/loader:981:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v18.20.6
At this point I am kind of stuck. I have looked on the wiki, forums, and other places for additional information but have had no luck, and I am very new to Nix so I am not sure where to start. Any pointers would be greatly appreciated.
Thank you for your help.