Have noticed there are very few VPS providers that offer NixOS as an option along with other OS’s - even via generic ISO install images. Is this a technology issue, say, where NixOS requires the bare metal without an intermediary hypervisor?
Is it possible for Nix to install, configure and activate multiple packages, for say, an entire website. For example, PostGresql, PHP, Wordpress, Caddy 2, Matomo, etc?
Am getting familiar with Nix package manager basics on Debian 10, but it’s still not clear to me how/where I configure the packages I download to my local store, e.g. Jitsi-Meet and Caddy 2.
Is this done in a single configuration.nix file or in the normal package configuration files now accessed by Nix-managed links? If the former, where do I find package-specific configuration documentation?
Here’s an example of how it’s done with vim and neovim Vim - NixOS Wiki. However, not all packages are configured in Nix, many still rely on local files for the actual configuration. Home manager is a project that tries to move more config into Nix.
Documentation is not Nix’s strong suit unfortunately. A lot of the time this can require looking at the source code of the package expression. However, sometimes it’s documented in the wiki.
No, absolutely not! Nixos has some features that require a hypervisor for running VMs (e.g. for os testing or executing commands in oci container build steps), which cannot be used when already running under a hypervisor, but for anything you can do with a traditional distro on a VPS nixos works as expected. I’ve been running game and web servers on my VPS using NixOS for about two years now.
Yes. If you wanted to combine just wordpress and postgresql, and run postgresql on a non-default port, some sample configuration could look like this:
/etc/nixos/configuration.nix:
{ config, ... }:
{
services = {
portgresql = {
enable = true;
port = 54321; # Changing the default
};
wordpress = {
"tcbswordpress" = {
# Using the port we defined above, so we don't need to remember to update this
database.port = config.postgresql.port;
};
};
};
}
Obviously there are many more options than the ones listed there, see the options search site for the full set.
This is really where the strength of nixos is, that you have a centralized, git-able place for your whole system configuration, whose underlying function is maintained by distribution maintainers. The reproducibility of the packages that you download is really just a nice side benefit in practical use
If you’ve been installing packages with something like nix-env -iA, you’ve been missing out - and I would suggest forgetting that command exists, it’s a bit of an anti-pattern that will bring you nightmares later. Check if there is an option that enables your package first (like services.postgresql.enable), and if not use environment.systemPackages on a real NixOS install instead, and try out home-manager on other distros (though maybe just try installing NixOS in a VM instead of using nix on Debian, it’ll be much easier to learn and understand).
Generally for anything you would do on a server, it is managed using configuration.nix. The easiest place for a beginner is the search site linked above, though man configuration.nix exists too.
How this is done in detail is defined by a module written by some upstream maintainer. In practice, some packages lack modules (though this isn’t really the case for popular packages like wordpress or postgres). If a module is lacking you can fall back to normal configuration files, though I would suggest instead writing your own module instead, since that keeps the promise of reproducibility in tact.
The main problem you’ll run into is that there is a bit of a learning curve to all of this, it’s very different from traditional Linux sysadmining. You’ve already found the right place to ask questions though.
Pick a small, achievable goal (reimplementing your wordpress server is a good first goal, but I’d suggest sticking to just wordpress at first and extending from there), make nix do it in a VM and go from there
i think the only weakness nix has over containerization, is if you want to run say 4xpostgres database servers and not putting them in docker containers or systemd nspawn containers, or what ever you container of flavour of the month is the only way to do it AFAIK
However there are nixers working out there to make this configuration possible, and having multiple services run without containerization, and avoid state and complexity that brings.
This is already possible with nixos containers (which do use nspawn, but come with all the nix goodness). There’s no nice way around namespaces for that kind of thing, really, the only problem is that nixos containers are still a bit tricky to get networked the way you could network oci containers.
Personally, I also like that containers give you some degree of host isolation, especially if carefully configured to use non-root users. Even if it’s not perfect, it makes me a whole lot less concerned to run proprietary (modded!) game servers. Nix without containers doesn’t offer features like that, and has no way to.
But either way, we have our own container solution, and podman/docker/kubernetes/etc. are all supported, and just as well as they are on other distros. It’s just sad to go back to them if you want all the nix niceties
I’m currently in the process of spinning up a local Purism Mini that will run NixOs natively but I’m still unclear about the limitations of Nix on say Debian 10 and seek a way to leverage my existing VPS servers that do NOT support NixOS natively.
Your response and that of others seems to be that doing Nix-Env -i myPackage using Nix is not the preferred way to install packages on either NixOS or with Nix Package manager. Rather the way to capture the primary benefits is to use the configuration file.
Does the Configuration.nix file work the same way in both NixOS and Nix?
I understand the Nix version obviously can’t tweak the OS itself or kernel like NixOS can, but can Nix and a suitable configuration.nix file coordinate the installation of server components like say Jitsi-Meet, Synapse Server, etc. on the same VPS and ideally sharing a single instance of say PostgreSQL database and Caddy 2 webserver/reverse proxy?
Also it’s not clear to me what a ‘module’ is or why I’d need one if all configuration can be done in configuration.nix for both NixOS and Nix.
Is a module sort of like IDL in that it declares WHAT has to happen but not HOW or WHO does it?