Skip to content

Commit

Permalink
nixos/quake3-server: add package config option
Browse files Browse the repository at this point in the history
- Remove top-level `with lib;`
  • Loading branch information
drupol committed Aug 19, 2023
1 parent dbcc734 commit 5fdff21
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions nixos/modules/services/games/quake3-server.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{ config, pkgs, lib, ... }:
with lib;

let
inherit (lib) literalMD mkEnableOption mkIf mkOption types;
cfg = config.services.quake3-server;

configFile = pkgs.writeText "q3ds-extra.cfg" ''
set net_port ${builtins.toString cfg.port}
${cfg.extraConfig}
'';

defaultBaseq3 = pkgs.requireFile rec {
name = "baseq3";
hashMode = "recursive";
Expand All @@ -25,6 +27,7 @@ let
$services.quake3-server.baseq3/.q3a/
'';
};

home = pkgs.runCommand "quake3-home" {} ''
mkdir -p $out/.q3a/baseq3
Expand All @@ -38,6 +41,7 @@ in {
options = {
services.quake3-server = {
enable = mkEnableOption (lib.mdDoc "Quake 3 dedicated server");
package = lib.mkPackageOptionMD pkgs "ioquake3" { };

port = mkOption {
type = types.port;
Expand Down Expand Up @@ -103,10 +107,10 @@ in {
ReadOnlyPaths = if baseq3InStore then home else cfg.baseq3;
ExecStartPre = optionalString (!baseq3InStore) "+${pkgs.coreutils}/bin/cp ${configFile} ${cfg.baseq3}/.q3a/baseq3/nix.cfg";

ExecStart = "${pkgs.ioquake3}/ioq3ded.x86_64 +exec nix.cfg";
ExecStart = "${cfg.package}/bin/ioq3ded +exec nix.cfg";
};
};
};

meta.maintainers = with maintainers; [ f4814n ];
meta.maintainers = with lib.maintainers; [ f4814n ];
}

0 comments on commit 5fdff21

Please sign in to comment.