Skip to content

build: Add Nix/NixOS support#823

Draft
duesee wants to merge 1 commit into
bugy:masterfrom
duesee:duesee_nix_support
Draft

build: Add Nix/NixOS support#823
duesee wants to merge 1 commit into
bugy:masterfrom
duesee:duesee_nix_support

Conversation

@duesee

@duesee duesee commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Hello, and sorry for the delay!

Here comes the first version (where I avoided depending on a configurable web folder.) I've added a few comments inline.

Why do we want it?

NixOS integration

With the files in place, NixOS users can (basically) add ...

services.script-server.enable = true;

... to their NixOS configuration and get a fully configured (systemd) script-server.

Linux VM demo

With the files in place, Nix users can start a live qemu VM demo with script-server preconfigured via ...

nix run .#demo

Linux image creation

With the files in place, Nix users can create {qemu,lxc,oci,...} images with script-server preinstalled and preconfigured by running ...

nix run .#nixosConfigurations.demo.config.system.build.images.<variant>

Especially LXC containers could make a lot of sense since they can be run natively on Proxmox.

Full list of supported images
nixosConfigurations.demo.config.system.build.images.amazon              nixosConfigurations.demo.config.system.build.images.kubevirt            nixosConfigurations.demo.config.system.build.images.qemu
nixosConfigurations.demo.config.system.build.images.azure               nixosConfigurations.demo.config.system.build.images.linode              nixosConfigurations.demo.config.system.build.images.qemu-efi
nixosConfigurations.demo.config.system.build.images.cloudstack          nixosConfigurations.demo.config.system.build.images.lxc                 nixosConfigurations.demo.config.system.build.images.raw
nixosConfigurations.demo.config.system.build.images.digital-ocean       nixosConfigurations.demo.config.system.build.images.lxc-metadata        nixosConfigurations.demo.config.system.build.images.raw-efi
nixosConfigurations.demo.config.system.build.images.google-compute      nixosConfigurations.demo.config.system.build.images.oci                 nixosConfigurations.demo.config.system.build.images.sd-card
nixosConfigurations.demo.config.system.build.images.hyperv              nixosConfigurations.demo.config.system.build.images.openstack           nixosConfigurations.demo.config.system.build.images.vagrant-virtualbox
nixosConfigurations.demo.config.system.build.images.iso                 nixosConfigurations.demo.config.system.build.images.openstack-zfs       nixosConfigurations.demo.config.system.build.images.virtualbox
nixosConfigurations.demo.config.system.build.images.iso-installer       nixosConfigurations.demo.config.system.build.images.proxmox             nixosConfigurations.demo.config.system.build.images.vmware
nixosConfigurations.demo.config.system.build.images.kexec               nixosConfigurations.demo.config.system.build.images.proxmox-lxc

NixOS test integration

With the files in place (and a little more effort), we could provide end-to-end integration tests where we automatically spawn a script-server via qemu and run all kinds of integration tests.

Comment thread nix/module.nix

@duesee duesee Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defines how the script-server would be configured in NixOS.

With enable = true; we "install" the script-server. settings is a Nix "attribute set" / dictionary that is placed unchanged in JSON format to /etc/script-server/conf.json. configuration is the path to the script configuration.

Example:

services.script-server = {
  enable = true;

  # Optional
  settings = { }; # JSON config in Nix syntax
  # Optional
  configuration = "..."; # Path to `conf` / `database` folder; Default: "/var/lib/script-server/conf"
};

Comment thread nix/module.nix
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];

environment.etc."script-server/conf.json".source =

@duesee duesee Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Settings" could be put under /etc/script-server/conf.json when using NixOS.

Comment thread nix/module.nix
--tmp-folder /tmp
'';

# `main.py` expects `web` to be in working directory.

@duesee duesee Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding: When launcher.py is used, the web folder must be co-located to it. We could bundle the NixOS package so that this is always the case and keep calling launcher.py. But... according to the Filesystem Hierarchy Standard, we probably should put launcher.py under /usr/bin/launcher.py and would then need to put the web folder there as well which feels off.

Instead, we call main.py and set the working directory to where the web package is located in the systemd unit. It feels hacky and I think we need to put version.txt there as well...

(I think this is not specific to NixOS. Packaging for e.g. Ubuntu would raise the same questions?)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But working dir is used not only for web, is it? All other folders from the release are expected to be there

Comment thread nix/package.nix

@duesee duesee Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This builds the backend.

Comment thread nix/package-web.nix

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This builds/bundles the frontend.

Comment thread .gitignore
/venv2/
e2e_venv/

# Nix / NixOS

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result is for Nix build artifacts. There is also a qemu demo startable via nix run .#demo. Since the demo will instantiate a VM, we ignore the .qcow2 hard drive, too.

@bugy

bugy commented Jul 7, 2026

Copy link
Copy Markdown
Owner

How is it supposed to be used/built?

Imagine that I'm a normal Nix user (which would be a bad example, since I have no clue about nix), who would like to start using script server.
What should I do?

@duesee

duesee commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

If you have Nix installed (see https://nixos.org/download/), cd into the script-server folder, and execute nix run .#demo (to start a qemu VM), nix run .#nixosConfigurations.demo.config.system.build.images.lxc (to e.g. build an lxc image), nix build .#script-server-frontend to bundle the web sources, etc.

If you are on NixOS system, you could (almost*) only add services.script-server.enable = true; to your global system configuration to install and preconfigure script-server on your machine.

You can look at, e.g., https://wiki.nixos.org/wiki/Nginx to get a feeling for NixOS. You could think about it being a "wrapper" over everything Linux/packages that allows you to fully declaratively and reproducibly define your running system. If you decide later to not wanting a software/service anymore, you delete the lines from your config and everything is cleanly rebuild w/o the software/service from scratch.

f you feel this is going in the right direction, I would love to add a little to the README.

*) We currently also need to point the system to this repo, but let's see how far we come :-)

@bugy bugy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general looks fine to me (considering that I have no clue about nix ecosystem)
But I would highly prefer to put all these files into tools/nix folder
To avoid polluting the main folder
Also, I would rather put "demo" config (if possible) into wiki section of github

Comment thread nix/module.nix
--tmp-folder /tmp
'';

# `main.py` expects `web` to be in working directory.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But working dir is used not only for web, is it? All other folders from the release are expected to be there

Comment thread nix/package-web.nix

src = ../web-src;

npmDepsHash = "sha256-aBZDh2NcDU4OpsdTS8JqwGMa8WeIoyW9I6bUwTXfllU=";

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be automatically calculated as a result of some build tool?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it would be the same for "version"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hash ensures that we always downloaded the exact same npm dependencies. We could adapt the hash in CI when updating the deps, though, to make our life easier. But I would suggest to tackle this later.

If you don't mind, I'll take care about the maintenance of the Nix support. Ideally, the files can eventually be moved into nixpkgs but I don't have experience here and probably want to ask someone before starting anything :-) Let's see first how well this works.

Since you seem fine with the direction, I'll try to finalize the PR soon(tm) and write a short NixOS Wiki entry.

@duesee duesee Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

soon = "probably next week";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants