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?)

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.

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.

1 participant