nix-config: 20707c182d5dcf0f822cbff419ec62f2b23c082c
1: {
2: config,
3: lib,
4: pkgs,
5: ...
6: }:
7:
8: with builtins;
9: with lib;
10: with rec {
11: cfg = config.services.laminar;
12:
13: # Workaround for https://groups.google.com/forum/#!topic/nix-devel/fAMADzFhcFo
14: stdenv6 = with pkgs; overrideCC stdenv gcc6;
15:
16: capnproto =
17: with pkgs;
18: stdenv6.mkDerivation {
19: name = "capnproto";
20: src = fetchFromGitHub {
21: owner = "capnproto";
22: repo = "capnproto";
23: rev = "3079784";
24: sha256 = "0d7v9310gq12qwhxbsjcdxwaz9fhyxq13x2lz8cdhm6hbsg8756z";
25: };
26: buildInputs = [
27: autoconf
28: automake
29: libtool
30: ];
31: patchPhase = ''
32: cd c++/
33: autoreconf -i
34: '';
35: hardeningDisable = [ "all" ];
36: };
37:
38: laminar = stdenv6.mkDerivation rec {
39: name = "laminar-${version}";
40: version = "0.6";
41: src = pkgs.fetchFromGitHub {
42: owner = "ohwgiles";
43: repo = "laminar";
44: rev = "bbbef11"; # v0.6
45: sha256 = "07nnqccm0dgyzkj6k3gcrs6f22h2ac7hdq05zq4wjs1xdyqdksl0";
46: };
47: buildInputs =
48: [ capnproto ]
49: ++ (with pkgs; [
50: boost
51: cmake
52: rapidjson
53: nix-helpers.replace
54: sqlite
55: websocketpp
56: zlib
57: ]);
58: hardeningDisable = [ "all" ];
59: __noChroot = true; # TODO: Prefetch deps (e.g. vue.js)
60: preConfigure = ''
61: cmakeFlags="$cmakeFlags -DSYSTEMD_UNITDIR='$out/lib/systemd/system'"
62: replace 'usr/bin' 'bin' -- CMakeLists.txt
63: '';
64: };
65: };
66: {
67: options.services.laminar = {
68: enable = mkOption {
69: type = types.bool;
70: default = false;
71: description = ''
72: Enable the Laminar continuous integration system as a systemd service.
73: '';
74: };
75:
76: package = mkOption {
77: type = types.package;
78: default = laminar;
79: description = ''
80: The package providing Laminar binaries.
81: '';
82: };
83:
84: home = mkOption {
85: type = types.path;
86: default = "/var/lib/laminar";
87: description = ''
88: The directory used to load config, store results, etc.
89: '';
90: };
91:
92: cfg = mkOption {
93: type = types.path;
94: description = ''
95: Path to symlink as LAMINAR_HOME/cfg, used to control Laminar. We use a
96: symlink so that content can be managed externally, e.g. via version
97: control, without needing to rebuild the service. Note that raw paths
98: like './foo' will have a snapshot added to the Nix store; to prevent
99: this use a string like '"/.../foo"' or 'toString ./foo'.
100: '';
101: };
102:
103: custom = mkOption {
104: type = types.nullOr types.path;
105: default = null;
106: description = ''
107: Path to symlink as 'home'/custom, used for Web UI customisation. We use
108: a symlink so that content can be managed externally, e.g. via version
109: control.
110: '';
111: };
112:
113: bindHttp = mkOption {
114: type = types.str;
115: default = "*:8080";
116: description = ''
117: Value for LAMINAR_BIND_HTTP, used for Laminar's read-only WebUI. Has
118: the form IPADDR:PORT, unix:PATH/TO/SOCKET or unix-abstract:SOCKETNAME.
119: IPADDR may be * to bind on all interfaces.
120: '';
121: };
122:
123: title = mkOption {
124: type = types.nullOr types.str;
125: default = null;
126: example = "My Build Server";
127: description = ''
128: Sets LAMINAR_TITLE, to use your preferred page title on the WebUI. For
129: further WebUI customization, consider using a custom style sheet.
130: '';
131: };
132:
133: user = mkOption {
134: default = "laminar";
135: type = types.str;
136: description = "User the laminar service should execute under.";
137: };
138:
139: group = mkOption {
140: default = "laminar";
141: type = types.str;
142: description = "Primary group of the laminar user.";
143: };
144:
145: extraGroups = mkOption {
146: type = types.listOf types.str;
147: default = [ ];
148: description = "List of extra groups that the laminar user should be in.";
149: };
150: };
151:
152: config = mkIf cfg.enable {
153: environment.systemPackages = [ laminar ];
154:
155: systemd.services.laminar = {
156: description = "Laminar continuous integration service";
157: wantedBy = [ "multi-user.target" ];
158: environment = {
159: LAMINAR_BIND_HTTP = cfg.bindHttp;
160: LAMINAR_HOME = cfg.home;
161: LAMINAR_TITLE = cfg.title;
162: };
163: path = [ cfg.package ];
164: preStart = ''
165: mkdir -vp "${cfg.home}"
166: chown -v "${cfg.user}"."${cfg.group}" "${cfg.home}"
167:
168: if [[ -h "${cfg.home}"/cfg ]]
169: then
170: rm -v "${cfg.home}"/cfg
171: fi
172: ln -sfv "${cfg.cfg}" ${cfg.home}/cfg
173:
174: if [[ -h "${cfg.home}"/custom ]]
175: then
176: rm -v "${cfg.home}"/custom
177: fi
178: ${
179: if cfg.custom == null then
180: ""
181: else
182: ''ln -sfv "${cfg.custom}" ${cfg.home}/custom''
183: }
184: '';
185: serviceConfig = {
186: User = cfg.user;
187: Group = cfg.group;
188: PermissionsStartOnly = true; # Allow preStart to run as root
189: ExecStart = "${cfg.package}/bin/laminard";
190: };
191: };
192:
193: users.extraGroups = optionalAttrs (cfg.group == "laminar") {
194: laminar = {
195: name = "laminar";
196: };
197: };
198:
199: users.extraUsers = optionalAttrs (cfg.user == "laminar") {
200: "${cfg.user}" = {
201: name = "laminar";
202: description = "Laminar User.";
203: isNormalUser = true;
204: createHome = false;
205: group = cfg.group;
206: extraGroups = cfg.extraGroups;
207: useDefaultShell = true;
208: };
209: };
210: };
211: }
Generated by git2html.