Skip to content
6 changes: 6 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20753,6 +20753,12 @@
name = "n-hass";
keys = [ { fingerprint = "FDEE 6116 DBA7 8840 7323 4466 A371 5973 2728 A6A6"; } ];
};
n0099 = {
email = "nixpkgs@n0099.com";
github = "n0099";
githubId = 13030387;
name = "n0099";
};
n00b0ss = {
email = "nixpkgs@n00b0ss.de";
github = "n00b0ss";
Expand Down
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2611.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@

- [MinusPod](https://github.com/ttlequals0/MinusPod), a self-hosted server that removes ads from podcasts before you ever hit play. Available as [services.minuspod](#opt-services.minuspod.enable).

- [freqtrade](https://github.com/freqtrade/freqtrade), a free and open source crypto trading bot written in Python. It is designed to support all major exchanges and be controlled via Telegram or webUI. It contains backtesting, plotting and money management tools as well as strategy optimization by machine learning. Available as [services.freqtrade](#opt-services.freqtrade.enable).

- [Stump](https://www.stumpapp.dev/), a free and open source comics, manga and digital book server with OPDS support. Available as [services.stump](#opt-services.stump.enable).

- [P2Pool](https://github.com/SChernykh/p2pool), a decentralized mining pool for Monero. Available as [services.p2pool](#opt-services.p2pool.enable).
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@
./services/display-managers/sddm.nix
./services/editors/emacs.nix
./services/editors/infinoted.nix
./services/finance/freqtrade.nix
./services/finance/libeufin/bank.nix
./services/finance/libeufin/module.nix
./services/finance/libeufin/nexus.nix
Expand Down
222 changes: 222 additions & 0 deletions nixos/modules/services/finance/freqtrade.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
{
config,
pkgs,
lib,
...
}:

let
cfg = config.services.freqtrade;
settingsFormat = pkgs.formats.json { };
in
{
options.services.freqtrade =
with {
inherit (lib) mkOption mkEnableOption;
inherit (lib.types)
str
bool
port
submodule
lazyAttrsOf
nullOr
listOf
path
externalPath
;
};
let
genCommonOptions = type: cfg: parentCfg: {
settings = mkOption {
description =
let
prefix = lib.optionalString (type == "root") "Global ";
object =
if type == "root" then
"all bots and webserver that get merged with [`lib.recursiveUpdate`](https://nixos.org/manual/nixpkgs/unstable/#function-library-lib.attrsets.recursiveUpdate)"
else
"the ${type}";
in
"${prefix}Freqtrade config for ${object}. See [Freqtrade documentation](https://www.freqtrade.io/en/stable/configuration/) for possible key and vaules.";
type = submodule (
{ name, config, ... }:

let
getSetting = key: config.${key} or cfg.settings.${key} or parentCfg.settings.${key};
in
{
freeformType = settingsFormat.type;
options =
let
genCfgAttrPath = rec {
cfg =
optionAttrPath:
let
nonRootAttrPath =
lib.optionalString (type != "root")
".${
if type == "bot" then
"bot.${name}"
else if type == "webserver" then
type
else
throw "Unknown type."
}";
in
"config.services.freqtrade${nonRootAttrPath}.${optionAttrPath}";
parentCfg =
operator: optionAttrPath:
lib.optionalString (type != "root") " ${operator} config.services.freqtrade.${optionAttrPath}";
cfgOperatorParent =
optionAttrPath: operator: cfg optionAttrPath + parentCfg operator optionAttrPath;
};
in
{
dry_run = mkOption {
description =
let
object = if type == "root" then "all bots and webserver" else type;
suffix = lib.optionalString (type == "root") " by default";
in
"Define if ${object} must be in Dry Run or production mode${suffix}.";
type = bool;
default = parentCfg.settings.dry_run or true;
defaultText = lib.literalExpression (
lib.optionalString (type != "root") "config.services.freqtrade.settings.dry_run or " + "true"
);
};
add_config_files = mkOption {
description = "Additional config files. These files will be merged with the nix config using merge strategy like the nix [update operator `//`](https://nix.dev/manual/nix/2.34/language/operators#update).";
type = listOf path;
default = cfg.extraConfigFiles ++ parentCfg.extraConfigFiles or [ ];
defaultText = lib.literalExpression (genCfgAttrPath.cfgOperatorParent "extraConfigFiles" "++");
};
user_data_dir = mkOption {
description = "Directory containing user data.";
type = externalPath;
default =
let
result = lib.tryEval cfg.userDataDir;
in
if result.success then result.value else parentCfg.userDataDir;
defaultText = lib.literalExpression (genCfgAttrPath.cfgOperatorParent "userDataDir" "or");
};
db_url =
let
prefix = if config ? bot_name then "bot-${config.bot_name}" else "tradesv3";
suffix = lib.optionalString (getSetting "dry_run") ".dryrun";
in
mkOption {
description = "Declares database URL to use.";
type = str;
default = "sqlite://${getSetting "user_data_dir"}/db/${prefix}${suffix}.sqlite";
defaultText =
let
userDataDir = genCfgAttrPath.cfgOperatorParent "settings.user_data_dir" "or";
prefix =
if type == "bot" then
''''${${genCfgAttrPath.cfg "settings.bot_name"} or "tradesv3"}''
else
"tradesv3";
suffix = ''lib.optionalString (${genCfgAttrPath.cfgOperatorParent "settings.dry_run" "or"}) ".dryrun"'';
in
lib.literalExpression "sqlite://\${${userDataDir}}/db/${prefix}\${${suffix}}.sqlite";
};
};
}
);
default = { };
apply = value: lib.recursiveUpdate (parentCfg.settings or { }) value;
};
extraConfigFiles = mkOption {
description = "Additional config files. These files will be merged with the nix config using merge strategy like the nix update operator `//`.";
type = listOf path;
default = [ ];
};
userDataDir = mkOption {
description = "Directory containing user data.";
type = externalPath;
};
};
in
{
enable = mkEnableOption "Freqtrade, a free and open source crypto trading bot written in Python";
bot = mkOption {
description = "Instances of Freqtrade. For requirements about set multiple bots see [Running multiple instances of Freqtrade](https://www.freqtrade.io/en/stable/advanced-setup/#running-multiple-instances-of-freqtrade).";
type = lazyAttrsOf (
submodule (
{ name, config, ... }: {
options = genCommonOptions "bot" config cfg;
config.settings.bot_name = lib.mkDefault name;
}
)
);
};
webserver = {
enable = mkEnableOption "Freqtrade webserver, which using [FreqUI](https://www.freqtrade.io/en/stable/freq-ui/#webserver-mode) to download historical data, test pairlists, run backtesting and other commands";
listen = {
addr = mkOption {
description = "Bind IP address. See the [API Server documentation](https://www.freqtrade.io/en/stable/rest-api/) for more details.";
type = str;
};
port = mkOption {
description = "Bind port. See the [API Server documentation](https://www.freqtrade.io/en/stable/rest-api/) for more details.";
type = port;
};
};
}
// genCommonOptions "webserver" cfg.webserver cfg;
}
// genCommonOptions "root" cfg { };
config =
let
genSystemdService = command: settingsJSON: {
wantedBy = [ "multi-user.target" ];
serviceConfig.ExecStart = "${lib.getExe pkgs.freqtrade} ${command} --config ${settingsJSON}";
};
commonSystemdService = id: {
# https://github.com/freqtrade/freqtrade/blob/6fa470939cc74bf0672e0e348a4d9b293072e43c/freqtrade.service.watchdog
after = [ "network.target" ];
serviceConfig = {
# not using `Notify` and passing `--sd-notify` in `ExecStart` to prevent deadlock
# due to `multi-user.target` of the container waits this unit
# `ExecStart` of this unit waits for internet access before send `sd_notify()`: https://github.com/freqtrade/freqtrade/blob/158eac5609f13d5fdbd2b09106589a786ae9fcf9/freqtrade/worker.py#L67
# and `ExecStartPost` of the host unit `container@.service` that setup `ip route` on the host side: https://github.com/NixOS/nixpkgs/blob/667d5cf1c59585031d743c78b394b0a647537c35/nixos/modules/virtualisation/nixos-containers.nix#L297
# waits `multi-user.target` in the container as `systemd-nspawn` in `ExecStart` waits it: https://github.com/NixOS/nixpkgs/blob/667d5cf1c59585031d743c78b394b0a647537c35/nixos/modules/virtualisation/nixos-containers.nix#L198
Type = "exec";
Restart = "on-failure";
SyslogIdentifier = "freqtrade-${id}";
SuccessExitStatus = 130; # https://github.com/freqtrade/freqtrade/blob/f3ec9796fbfa333625be451fd8c03e0dad8869b7/freqtrade/main.py#L66
};
};
in
lib.mkIf cfg.enable {
services.freqtrade.webserver.settings.api_server = with cfg.webserver.listen; {
enabled = true;
listen_ip_address = addr;
listen_port = port;
};
systemd.services = {
"freqtrade@" = commonSystemdService "bot-%I";
freqtrade-webserver = lib.mkIf cfg.webserver.enable (
lib.mkMerge [
(lib.pipe cfg.webserver.settings [
(settingsFormat.generate "freqtrade-webserver-settings.json")
(genSystemdService "webserver")
])
(commonSystemdService "webserver")
]
);
}
// lib.concatMapAttrs (name: botCfg: {
"freqtrade@${name}" =
(lib.pipe botCfg.settings [
(settingsFormat.generate "freqtrade-bot-${name}-settings.json")
(genSystemdService "trade")
])
// {
overrideStrategy = "asDropin"; # https://github.com/NixOS/nixpkgs/issues/80933#issuecomment-1295396500
};
}) cfg.bot;
};
}
36 changes: 36 additions & 0 deletions pkgs/by-name/fr/freqtrade/client.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
lib,
fetchFromGitHub,
buildPythonPackage,
setuptools,
wheel,
python-rapidjson,
ccxt,
}:

buildPythonPackage (finalAttrs: {
pname = "freqtrade-client";
version = "2026.10";
src = fetchFromGitHub {
owner = "freqtrade";
repo = "freqtrade";
tag = finalAttrs.version;
hash = "sha256-L/iZC4kKsQjgKw3X3uK7ZeMsjsS/Y9miJfj5dy1jfWA=";
rootDir = "ft_client";
};
pyproject = true;
build-system = [
setuptools
wheel
];
dependencies = [
ccxt.pinnedDeps.requests
python-rapidjson
];
meta = {
description = "Provides a minimal rest client for the freqtrade rest api.";
homepage = "https://github.com/freqtrade/freqtrade/tree/develop/ft_client";
license = lib.licenses.gpl3;
maintainers = with lib.maintainers; [ n0099 ];
};
})
48 changes: 48 additions & 0 deletions pkgs/by-name/fr/freqtrade/frequi.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
lib,
stdenv,
fetchFromGitHub,
git,
nodejs,
dart-sass,
pnpm_12,
pnpmConfigHook,
fetchPnpmDeps,
}:

stdenv.mkDerivation (finalAttrs: {
pname = "frequi";
version = "3.2.1";
src = fetchFromGitHub {
owner = "freqtrade";
repo = "frequi";
tag = finalAttrs.version;
hash = "sha256-Z3gW8+rPYM/THdS2jgo44xCW1XUIj5TDAEFqsa31mC4=";
};
pnpmDeps = fetchPnpmDeps {
inherit (finalAttrs) pname version src;
pnpm = pnpm_12; # https://github.com/freqtrade/frequi/blob/fc11114c1ba6d6d412137bc4f6f60c7ad7cd1ab7/package.json#L68
fetcherVersion = 4;
hash = "sha256-ltrRILUNgyBzg5U6RLGq5fZ0K34dnynDFxmpBUPdMiQ=";
};
nativeBuildInputs = [
git # https://github.com/freqtrade/frequi/blob/7d8a81c1022fa39dffbcd69f45a01767259dd4de/vite.config.ts#L12
nodejs
pnpm_12
pnpmConfigHook
];
buildPhase = ''
# https://github.com/sass/embedded-host-node/issues/334
substituteInPlace node_modules/sass-embedded/dist/lib/src/compiler-path.js \
--replace-fail 'compilerCommand = (() => {' 'compilerCommand = (() => { return ["${lib.getExe dart-sass}"];'
mkdir $out
pnpm run build --outDir $out
'';
meta = {
description = "Freqtrade UI - Frontend for Freqtrade";
homepage = "https://github.com/freqtrade/frequi";
changelog = "https://github.com/freqtrade/frequi/releases/tag/${finalAttrs.src.rev}";
license = lib.licenses.gpl3;
maintainers = with lib.maintainers; [ n0099 ];
};
})
46 changes: 46 additions & 0 deletions pkgs/by-name/fr/freqtrade/ft-pandas-ta.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
lib,
fetchFromGitHub,
buildPythonPackage,
setuptools,
fetchPypi,
wheel,
numpy,
pandas,
}:

buildPythonPackage (finalAttrs: {
pname = "ft-pandas-ta";
version = "0.3.16";
src = fetchFromGitHub {
owner = "freqtrade";
repo = "pandas-ta";
tag = finalAttrs.version;
hash = "sha256-xT8/42BU27ZEGjQsfXF/5N2N+NrAJZrAQ2MM1hcetvc=";
};
pyproject = true;
build-system = [
(setuptools.overridePythonAttrs rec {
# https://github.com/freqtrade/pandas-ta/commit/cf1b52b2de85525c299654d8f1e6dd607f4acaa1
# https://github.com/freqtrade/pandas-ta/commit/9d7218ed6a120804bd56e3e0381a58a9c2b52720
version = "75.6.0";
src = fetchPypi {
pname = "setuptools";
inherit version;
hash = "sha256-gZkiJVjffIYhavT4TDDps0ph2LoZNmzJFEJM29KCUvY=";
};
})
wheel
];
dependencies = [
numpy
pandas
];
meta = {
description = "An easy to use Python 3 Pandas Extension with 130+ Technical Analysis Indicators.";
homepage = "https://github.com/freqtrade/pandas-ta";
changelog = "https://github.com/freqtrade/pandas-ta/releases/tag/${finalAttrs.src.rev}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ n0099 ];
};
})
Loading
Loading