11 cfg = config.services.pixiecore;
14 meta.maintainers = with maintainers; [ bbigras ];
17 services.pixiecore = {
18 enable = mkEnableOption "Pixiecore";
20 openFirewall = mkOption {
24 Open ports (67, 69, 4011 UDP and 'port', 'statusPort' TCP) in the firewall for Pixiecore.
29 description = "Which mode to use";
41 description = "Log more things that aren't directly related to booting a recognized client";
44 dhcpNoBind = mkOption {
47 description = "Handle DHCP traffic without binding to the DHCP server port";
51 description = "Which quick option to use";
65 type = types.str or types.path;
67 description = "Kernel path. Ignored unless mode is set to 'boot'";
71 type = types.str or types.path;
73 description = "Initrd path. Ignored unless mode is set to 'boot'";
79 description = "Kernel commandline arguments. Ignored unless mode is set to 'boot'";
85 description = "IPv4 address to listen on";
91 description = "Port to listen on for HTTP";
94 statusPort = mkOption {
97 description = "HTTP port for status information (can be the same as --port)";
100 apiServer = mkOption {
102 example = "http://localhost:8080";
103 description = "URI to connect to the API. Ignored unless mode is set to 'api'";
106 extraArguments = mkOption {
107 type = types.listOf types.str;
109 description = "Additional command line arguments to pass to Pixiecore";
114 config = mkIf cfg.enable {
115 users.groups.pixiecore = { };
116 users.users.pixiecore = {
117 description = "Pixiecore daemon user";
122 networking.firewall = mkIf cfg.openFirewall {
134 systemd.services.pixiecore = {
135 description = "Pixiecore server";
136 after = [ "network.target" ];
137 wants = [ "network.target" ];
138 wantedBy = [ "multi-user.target" ];
142 AmbientCapabilities = [ "cap_net_bind_service" ] ++ optional cfg.dhcpNoBind "cap_net_raw";
146 if cfg.mode == "boot" then
151 ++ optional (cfg.initrd != "") cfg.initrd
152 ++ optionals (cfg.cmdLine != "") [
156 else if cfg.mode == "quick" then
168 ${pkgs.pixiecore}/bin/pixiecore \
169 ${lib.escapeShellArgs argString} \
170 ${optionalString cfg.debug "--debug"} \
171 ${optionalString cfg.dhcpNoBind "--dhcp-no-bind"} \
172 --listen-addr ${lib.escapeShellArg cfg.listen} \
173 --port ${toString cfg.port} \
174 --status-port ${toString cfg.statusPort} \
175 ${escapeShellArgs cfg.extraArguments}