{ config, lib, pkgs, ... }: let cfg = config.services.abuilder; in { options.services.abuilder = { enable = lib.mkEnableOption "abuilder build daemon"; repositories = lib.mkOption { type = lib.types.listOf lib.types.path; default = [ ]; }; }; config = lib.mkIf cfg.enable (lib.mkMerge [ { environment.systemPackages = [ pkgs.abuilder ]; # TODO harden `systemd.services.abuilder` systemd.services."abuilder".after = [ "network.target" ]; systemd.services."abuilder".environment.ABUILDER_STATE = "/var/lib/abuilder"; systemd.services."abuilder".environment.ABUILDER_URLS = lib.concatStringsSep ":" cfg.repositories; systemd.services."abuilder".environment.NIX_PATH = "nixpkgs=/etc/nixos/nixpkgs"; systemd.services."abuilder".path = [ pkgs.git pkgs.nix ]; systemd.services."abuilder".script = "${pkgs.abuilder}/bin/abuilder"; systemd.services."abuilder".wantedBy = [ "multi-user.target" ]; } ]); }