Merge pull request #176030 from SuperSandro2000/asf
This commit is contained in:
commit
c09782950f
@ -13,6 +13,8 @@ let
|
||||
# is in theory not needed as this is already the default for default builds
|
||||
UpdateChannel = 0;
|
||||
Headless = true;
|
||||
} // lib.optionalAttrs (cfg.ipcPasswordFile != "") {
|
||||
IPCPassword = "#ipcPassword#";
|
||||
});
|
||||
|
||||
ipc-config = format.generate "IPC.config" cfg.ipcSettings;
|
||||
@ -81,8 +83,7 @@ in
|
||||
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`
|
||||
respectively `0` because NixOS takes care of updating everything.
|
||||
Do note that `AutoRestart` and `UpdateChannel` is always to `false` respectively `0` because NixOS takes care of updating everything.
|
||||
`Headless` is also always set to `true` because there is no way to provide inputs via a systemd service.
|
||||
You should try to keep ASF up to date since upstream does not provide support for anything but the latest version and you're exposing yourself to all kinds of issues - as is outlined <link xlink:href="https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Configuration#updateperiod">here</link>.
|
||||
'';
|
||||
@ -92,6 +93,11 @@ respectively `0` because NixOS takes care of updating everything.
|
||||
default = { };
|
||||
};
|
||||
|
||||
ipcPasswordFile = mkOption {
|
||||
type = types.path;
|
||||
description = "Path to a file containig the password. The file must be readable by the <literal>asf</literal> user/group.";
|
||||
};
|
||||
|
||||
ipcSettings = mkOption {
|
||||
type = format.type;
|
||||
description = ''
|
||||
@ -115,14 +121,12 @@ respectively `0` because NixOS takes care of updating everything.
|
||||
options = {
|
||||
username = mkOption {
|
||||
type = types.str;
|
||||
description =
|
||||
"Name of the user to log in. Default is attribute name.";
|
||||
description = "Name of the user to log in. Default is attribute name.";
|
||||
default = "";
|
||||
};
|
||||
passwordFile = mkOption {
|
||||
type = types.path;
|
||||
description =
|
||||
"Path to a file containig the password. The file must be readable by the <literal>asf</literal> user/group.";
|
||||
description = "Path to a file containig the password. The file must be readable by the <literal>asf</literal> user/group.";
|
||||
};
|
||||
enabled = mkOption {
|
||||
type = types.bool;
|
||||
@ -131,8 +135,7 @@ respectively `0` because NixOS takes care of updating everything.
|
||||
};
|
||||
settings = mkOption {
|
||||
type = types.attrs;
|
||||
description =
|
||||
"Additional settings that are documented <link xlink:href=\"https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Configuration#bot-config\">here</link>.";
|
||||
description = "Additional settings that are documented <link xlink:href=\"https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Configuration#bot-config\">here</link>.";
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
@ -156,6 +159,7 @@ respectively `0` because NixOS takes care of updating everything.
|
||||
users = {
|
||||
users.asf = {
|
||||
home = cfg.dataDir;
|
||||
homeMode = "700";
|
||||
isSystemUser = true;
|
||||
group = "asf";
|
||||
description = "Archis-Steam-Farm service user";
|
||||
@ -176,8 +180,7 @@ respectively `0` because NixOS takes care of updating everything.
|
||||
Group = "asf";
|
||||
WorkingDirectory = cfg.dataDir;
|
||||
Type = "simple";
|
||||
ExecStart =
|
||||
"${cfg.package}/bin/ArchiSteamFarm --path ${cfg.dataDir} --process-required --no-restart --service --no-config-migrate";
|
||||
ExecStart = "${cfg.package}/bin/ArchiSteamFarm --path ${cfg.dataDir} --process-required --no-restart --service --no-config-migrate";
|
||||
|
||||
# mostly copied from the default systemd service
|
||||
PrivateTmp = true;
|
||||
@ -202,29 +205,38 @@ respectively `0` because NixOS takes care of updating everything.
|
||||
}
|
||||
];
|
||||
|
||||
preStart = ''
|
||||
mkdir -p config
|
||||
rm -f www
|
||||
rm -f config/{*.json,*.config}
|
||||
preStart =
|
||||
let
|
||||
createBotsScript = pkgs.runCommandLocal "ASF-bots" { } ''
|
||||
mkdir -p $out
|
||||
# clean potential removed bots
|
||||
rm -rf $out/*.json
|
||||
for i in ${strings.concatStringsSep " " (lists.map (x: "${getName x},${x}") (attrsets.mapAttrsToList mkBot cfg.bots))}; do IFS=",";
|
||||
set -- $i
|
||||
ln -fs $2 $out/$1
|
||||
done
|
||||
'';
|
||||
replaceSecretBin = "${pkgs.replace-secret}/bin/replace-secret";
|
||||
in
|
||||
''
|
||||
mkdir -p config
|
||||
|
||||
ln -s ${asf-config} config/ASF.json
|
||||
cp --no-preserve=mode ${asf-config} config/ASF.json
|
||||
${replaceSecretBin} '#ipcPassword#' '${cfg.ipcPasswordFile}' config/ASF.json
|
||||
|
||||
${strings.optionalString (cfg.ipcSettings != {}) ''
|
||||
ln -s ${ipc-config} config/IPC.config
|
||||
''}
|
||||
${optionalString (cfg.ipcSettings != {}) ''
|
||||
ln -fs ${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/
|
||||
${optionalString (cfg.ipcSettings != {}) ''
|
||||
ln -fs ${createBotsScript}/* config/
|
||||
''}
|
||||
|
||||
${strings.optionalString cfg.web-ui.enable ''
|
||||
ln -s ${cfg.web-ui.package}/lib/dist www
|
||||
''}
|
||||
'';
|
||||
rm -f www
|
||||
${optionalString cfg.web-ui.enable ''
|
||||
ln -s ${cfg.web-ui.package}/lib/dist www
|
||||
''}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user