summary refs log tree commit diff
path: root/nixos/modules/services/games
diff options
context:
space:
mode:
authorlegendofmiracles <legendofmiracles@protonmail.com>2021-12-04 08:15:04 -0600
committerlegendofmiracles <legendofmiracles@protonmail.com>2022-01-05 14:09:24 -0600
commit86f45c7c6f8223e6a414139c322b6221fbe50314 (patch)
tree50aecaf1c795f9727b14df590e041e08c67c7f11 /nixos/modules/services/games
parent4b513af50111de7cd24c246cd2de776e9b0681aa (diff)
downloadnixpkgs-86f45c7c6f8223e6a414139c322b6221fbe50314.tar
nixpkgs-86f45c7c6f8223e6a414139c322b6221fbe50314.tar.gz
nixpkgs-86f45c7c6f8223e6a414139c322b6221fbe50314.tar.bz2
nixpkgs-86f45c7c6f8223e6a414139c322b6221fbe50314.tar.lz
nixpkgs-86f45c7c6f8223e6a414139c322b6221fbe50314.tar.xz
nixpkgs-86f45c7c6f8223e6a414139c322b6221fbe50314.tar.zst
nixpkgs-86f45c7c6f8223e6a414139c322b6221fbe50314.zip
ArchiSteamFarm: 5.2.0.9 -> 5.2.0.10; ASF-ui: update
Diffstat (limited to 'nixos/modules/services/games')
-rw-r--r--nixos/modules/services/games/asf.nix65
1 files changed, 45 insertions, 20 deletions
diff --git a/nixos/modules/services/games/asf.nix b/nixos/modules/services/games/asf.nix
index f204ac5a02a..2c343dc2c00 100644
--- a/nixos/modules/services/games/asf.nix
+++ b/nixos/modules/services/games/asf.nix
@@ -12,8 +12,11 @@ let
     # and nixos takes care of restarting the service
     # is in theory not needed as this is already the default for default builds
     UpdateChannel = 0;
+    Headless = true;
   });
 
+  ipc-config = format.generate "IPC.config" cfg.ipcSettings;
+
   mkBot = n: c:
     format.generate "${n}.json" (c.settings // {
       SteamLogin = if c.username == "" then n else c.username;
@@ -39,19 +42,19 @@ in
       type = types.submodule {
         options = {
           enable = mkEnableOption
-            "Wheter to start the web-ui. This is the preffered way of configuring things such as the steam guard token";
+            "Wheter to start the web-ui. This is the preferred way of configuring things such as the steam guard token";
 
           package = mkOption {
             type = types.package;
-            default = pkgs.ASF-ui;
+            default = pkgs.ArchiSteamFarm.ui;
             description =
-              "Web ui package to use. Contents must be in lib/dist.";
+              "Web-UI package to use. Contents must be in lib/dist.";
           };
         };
       };
       default = {
         enable = true;
-        package = pkgs.ASF-ui;
+        package = pkgs.ArchiSteamFarm.ui;
       };
       example = {
         enable = false;
@@ -75,7 +78,7 @@ in
     };
 
     settings = mkOption {
-      type = let format = pkgs.formats.json { }; in format.type;
+      type = format.type;
       description = ''
         The ASF.json file, all the options are documented <link xlink:href="https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Configuration#global-config">here</link>.
         Do note that `AutoRestart`  and `UpdateChannel` is always to `false`
@@ -88,6 +91,25 @@ respectively `0` because NixOS takes care of updating everything.
       };
       default = { };
     };
+
+    ipcSettings = mkOption {
+      type = format.type;
+      description = ''
+        Settings to write to IPC.config.
+        All options can be found <link xlink:href="https://github.com/JustArchiNET/ArchiSteamFarm/wiki/IPC#custom-configuration">here</link>.
+      '';
+      example = {
+        Kestrel = {
+          Endpoints = {
+            HTTP = {
+              Url = "http://*:1242";
+            };
+          };
+        };
+      };
+      default = { };
+    };
+
     bots = mkOption {
       type = types.attrsOf (types.submodule {
         options = {
@@ -147,8 +169,8 @@ respectively `0` because NixOS takes care of updating everything.
         after = [ "network.target" ];
         wantedBy = [ "multi-user.target" ];
 
-        serviceConfig = lib.mkMerge [
-          (lib.mkIf (cfg.dataDir == "/var/lib/asf") { StateDirectory = "asf"; })
+        serviceConfig = mkMerge [
+          (mkIf (cfg.dataDir == "/var/lib/asf") { StateDirectory = "asf"; })
           {
             User = "asf";
             Group = "asf";
@@ -181,22 +203,25 @@ respectively `0` because NixOS takes care of updating everything.
         ];
 
         preStart = ''
-          set -x
-          # we remove config to have no complexity when creating the required files/directories
           mkdir -p config
+          rm -f www
+          rm -f config/{*.json,*.config}
 
-          rm -rf config/*.json
-          rm -rf www
           ln -s ${asf-config} config/ASF.json
-          echo -e '${
-            lib.strings.concatStringsSep "\\n"
-            (attrsets.mapAttrsToList mkBot cfg.bots)
-          }' \
-          | while read -r line; do
-              ln -s $line config/$(basename $line)
-          done
-
-          ${lib.strings.optionalString cfg.web-ui.enable ''
+
+          ${strings.optionalString (cfg.ipcSettings != {}) ''
+            ln -s ${ipc-config} config/IPC.config
+          ''}
+
+          ln -s ${pkgs.runCommandLocal "ASF-bots" {} ''
+            mkdir -p $out/lib/asf/bots
+            for i in ${strings.concatStringsSep " " (lists.map (x: "${getName x},${x}") (attrsets.mapAttrsToList mkBot cfg.bots))}; do IFS=",";
+              set -- $i
+              ln -s $2 $out/lib/asf/bots/$1
+            done
+          ''}/lib/asf/bots/* config/
+
+          ${strings.optionalString cfg.web-ui.enable ''
             ln -s ${cfg.web-ui.package}/lib/dist www
           ''}
         '';