From b8596c1b2352cd31b34173001d8502c304f130c3 Mon Sep 17 00:00:00 2001 From: Aguirre Matteo Date: Thu, 18 Sep 2025 14:05:09 -0300 Subject: [PATCH] acd-cli: add module --- modules/programs/acd-cli.nix | 120 ++++++++++++++++++ tests/modules/programs/acd-cli/acd_cli.ini | 6 + tests/modules/programs/acd-cli/acd_client.ini | 10 ++ tests/modules/programs/acd-cli/cache.ini | 4 + tests/modules/programs/acd-cli/default.nix | 1 + .../programs/acd-cli/example-config.nix | 65 ++++++++++ tests/modules/programs/acd-cli/fuse.ini | 9 ++ 7 files changed, 215 insertions(+) create mode 100644 modules/programs/acd-cli.nix create mode 100644 tests/modules/programs/acd-cli/acd_cli.ini create mode 100644 tests/modules/programs/acd-cli/acd_client.ini create mode 100644 tests/modules/programs/acd-cli/cache.ini create mode 100644 tests/modules/programs/acd-cli/default.nix create mode 100644 tests/modules/programs/acd-cli/example-config.nix create mode 100644 tests/modules/programs/acd-cli/fuse.ini diff --git a/modules/programs/acd-cli.nix b/modules/programs/acd-cli.nix new file mode 100644 index 000000000..3549a7824 --- /dev/null +++ b/modules/programs/acd-cli.nix @@ -0,0 +1,120 @@ +{ + lib, + pkgs, + config, + ... +}: +let + inherit (lib) + mkIf + mkEnableOption + mkPackageOption + mkOption + ; + + cfg = config.programs.acd-cli; + iniFormat = pkgs.formats.ini { }; +in +{ + meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ]; + options.programs.acd-cli = { + enable = mkEnableOption "acd-cli"; + package = mkPackageOption pkgs "acd-cli" { nullable = true; }; + cliSettings = mkOption { + inherit (iniFormat) type; + default = { }; + example = { + download = { + keep_corrupt = false; + keep_incomplete = true; + }; + + upload = { + timeout_wait = 10; + }; + }; + description = '' + CLI configuration settings for acd-cli. All the available options can be found here: + . + ''; + }; + + clientSettings = mkOption { + inherit (iniFormat) type; + default = { }; + example = { + endpoints = { + filename = "endpoint_data"; + validity_duration = 259200; + }; + + transfer = { + fs_chunk_size = 131072; + dl_chunk_size = 524288000; + chunk_retries = 1; + connection_timeout = 30; + idle_timeout = 60; + }; + }; + description = '' + Client configuration settings for acd-cli. All the available options can be found here: + . + ''; + }; + + cacheSettings = mkOption { + inherit (iniFormat) type; + default = { }; + example = { + sqlite = { + filename = "nodes.db"; + busy_timeout = 30000; + journal_mode = "wal"; + }; + + blacklist = { + folders = [ ]; + }; + }; + description = '' + Cache configuration settings for acd-cli. All the available options can be found here: + . + ''; + }; + + fuseSettings = mkOption { + inherit (iniFormat) type; + default = { }; + example = { + fs.block_size = 512; + read.open_chunk_limit = 10; + write = { + buffer_size = 32; + timeout = 30; + }; + }; + description = '' + FUSE configuration settings for acd-cli. All the available options can be found here: + . + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = mkIf (cfg.package != null) [ cfg.package ]; + xdg.configFile = { + "acd_cli/acd_cli.ini" = mkIf (cfg.cliSettings != { }) { + source = iniFormat.generate "acd_cli.ini" cfg.cliSettings; + }; + "acd_cli/acd_client.ini" = mkIf (cfg.clientSettings != { }) { + source = iniFormat.generate "acd_client.ini" cfg.clientSettings; + }; + "acd_cli/cache.ini" = mkIf (cfg.cacheSettings != { }) { + source = iniFormat.generate "acd_cli_cache.ini" cfg.cacheSettings; + }; + "acd_cli/fuse.ini" = mkIf (cfg.fuseSettings != { }) { + source = iniFormat.generate "acd_cli_fuse.ini" cfg.fuseSettings; + }; + }; + }; +} diff --git a/tests/modules/programs/acd-cli/acd_cli.ini b/tests/modules/programs/acd-cli/acd_cli.ini new file mode 100644 index 000000000..f2fc4242e --- /dev/null +++ b/tests/modules/programs/acd-cli/acd_cli.ini @@ -0,0 +1,6 @@ +[download] +keep_corrupt=false +keep_incomplete=true + +[upload] +timeout_wait=10 diff --git a/tests/modules/programs/acd-cli/acd_client.ini b/tests/modules/programs/acd-cli/acd_client.ini new file mode 100644 index 000000000..4b6275d1d --- /dev/null +++ b/tests/modules/programs/acd-cli/acd_client.ini @@ -0,0 +1,10 @@ +[endpoints] +filename=endpoint_data +validity_duration=259200 + +[transfer] +chunk_retries=1 +connection_timeout=30 +dl_chunk_size=524288000 +fs_chunk_size=131072 +idle_timeout=60 diff --git a/tests/modules/programs/acd-cli/cache.ini b/tests/modules/programs/acd-cli/cache.ini new file mode 100644 index 000000000..52f2e12c6 --- /dev/null +++ b/tests/modules/programs/acd-cli/cache.ini @@ -0,0 +1,4 @@ +[sqlite] +busy_timeout=30000 +filename=nodes.db +journal_mode=wal diff --git a/tests/modules/programs/acd-cli/default.nix b/tests/modules/programs/acd-cli/default.nix new file mode 100644 index 000000000..b175365f8 --- /dev/null +++ b/tests/modules/programs/acd-cli/default.nix @@ -0,0 +1 @@ +{ acd-cli-example-config = ./example-config.nix; } diff --git a/tests/modules/programs/acd-cli/example-config.nix b/tests/modules/programs/acd-cli/example-config.nix new file mode 100644 index 000000000..d78eb7b1e --- /dev/null +++ b/tests/modules/programs/acd-cli/example-config.nix @@ -0,0 +1,65 @@ +{ + programs.acd-cli = { + enable = true; + cliSettings = { + download = { + keep_corrupt = false; + keep_incomplete = true; + }; + + upload = { + timeout_wait = 10; + }; + }; + + clientSettings = { + endpoints = { + filename = "endpoint_data"; + validity_duration = 259200; + }; + + transfer = { + fs_chunk_size = 131072; + dl_chunk_size = 524288000; + chunk_retries = 1; + connection_timeout = 30; + idle_timeout = 60; + }; + }; + + cacheSettings = { + sqlite = { + filename = "nodes.db"; + busy_timeout = 30000; + journal_mode = "wal"; + }; + }; + + fuseSettings = { + fs.block_size = 512; + read.open_chunk_limit = 10; + write = { + buffer_size = 32; + timeout = 30; + }; + }; + }; + + nmt.script = '' + assertFileExists home-files/.config/acd_cli/acd_cli.ini + assertFileContent home-files/.config/acd_cli/acd_cli.ini \ + ${./acd_cli.ini} + + assertFileExists home-files/.config/acd_cli/acd_client.ini + assertFileContent home-files/.config/acd_cli/acd_client.ini \ + ${./acd_client.ini} + + assertFileExists home-files/.config/acd_cli/cache.ini + assertFileContent home-files/.config/acd_cli/cache.ini \ + ${./cache.ini} + + assertFileExists home-files/.config/acd_cli/fuse.ini + assertFileContent home-files/.config/acd_cli/fuse.ini \ + ${./fuse.ini} + ''; +} diff --git a/tests/modules/programs/acd-cli/fuse.ini b/tests/modules/programs/acd-cli/fuse.ini new file mode 100644 index 000000000..67bfa2057 --- /dev/null +++ b/tests/modules/programs/acd-cli/fuse.ini @@ -0,0 +1,9 @@ +[fs] +block_size=512 + +[read] +open_chunk_limit=10 + +[write] +buffer_size=32 +timeout=30