Skip to content

build: Add Nix/NixOS support#823

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

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
Comment thread nix/module.nix
Comment thread nix/module.nix
Comment thread nix/package.nix
Comment thread nix/package-dist.nix
Comment thread .gitignore
@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
Comment thread nix/package-dist.nix
@duesee duesee force-pushed the duesee_nix_support branch from 2b6112f to 5b58c19 Compare July 13, 2026 08:55
@duesee duesee marked this pull request as ready for review July 13, 2026 09:09
@duesee

duesee commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Hey and thanks for the patience! I think this should be fine now (and would already help us very much.)

I would propose to put a minimal (but still complete) example into the docs. Nix/NixOS users will know how to integrate it into their system config and use it.

# flake.nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/26.05";
    script-server.url = "github:bugy/script-server";
  };

  outputs = { nixpkgs, script-server, ... }: {
    nixosConfigurations = {
      demo = nixpkgs.lib.nixosSystem {
        modules = [
          {
            imports = [
              script-server.nixosModules.default
            ];

            nixpkgs = {
              overlays = [ script-server.overlays.default ];
              hostPlatform = "x86_64-linux";
            };

            networking.firewall.allowedTCPPorts = [ 5000 ];

            services = {
              script-server = {
                enable = true;
                settings = {
                  title = "Service Center";
                };
                configuration = "/var/lib/script-server/conf";
              };
            };
          }
        ];
      };
    };
  };
}

My proposal would be to go with it as it is for a while and see how it works out. As soon as we get more experience and start to feel confident that everything works as we want, we could try to merge it into nixpkgs. This way, much of the code from above will go away and script-server could basically really be installed by doing services.script-server.enable = true; But: Future work :-)

Comment thread nix/package-dist.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.

I renamed script-server-web to script-server-dist and it now auto-generates the version.txt. This way, the version is also showed correctly.

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