aboutsummaryrefslogtreecommitdiffstats
path: root/modules/abuilder/default.nix
blob: a4dc76aea95f75c8bbfd4df1d3413065d55530b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{ 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" ];
    }
  ]);
}