freetube: add module

This commit is contained in:
Vonixxx 2024-04-21 13:12:43 +02:00 committed by Robert Helgesson
parent f8e6694eda
commit 3c0df2a7e4
No known key found for this signature in database
GPG Key ID: 96E745BD17AA17ED
7 changed files with 112 additions and 0 deletions

View File

@ -1561,6 +1561,17 @@ in {
https://github.com/ErikReider/SwayNotificationCenter for more.
'';
}
{
time = "2024-04-30T18:28:28+00:00";
message = ''
A new module is available: 'programs.freetube'.
FreeTube is a YouTube client built around using YouTube more
privately. You can enjoy your favorite content and creators without
your habits being tracked. See https://freetubeapp.io/ for more.
'';
}
];
};
}

View File

@ -92,6 +92,7 @@ let
./programs/firefox.nix
./programs/fish.nix
./programs/foot.nix
./programs/freetube.nix
./programs/fuzzel.nix
./programs/fzf.nix
./programs/gallery-dl.nix

View File

@ -0,0 +1,60 @@
{ lib, pkgs, config, ... }:
let
inherit (lib)
concatStringsSep mapAttrsToList mkIf mkEnableOption mkPackageOption mkOption
literalExpression;
cfg = config.programs.freetube;
settings = settings:
let
convertSetting = name: value:
builtins.toJSON {
"_id" = name;
"value" = value;
};
in concatStringsSep "\n" (mapAttrsToList convertSetting settings) + "\n";
in {
meta.maintainers = with lib.maintainers; [ vonixxx ];
options.programs.freetube = {
enable = mkEnableOption "FreeTube, a YT client for Windows, Mac, and Linux";
package = mkPackageOption pkgs "freetube" { };
settings = mkOption {
type = lib.types.attrs;
default = { };
example = literalExpression ''
{
allowDashAv1Formats = true;
checkForUpdates = false;
defaultQuality = "1080";
baseTheme = "catppuccinMocha";
}
'';
description = ''
Configuration settings for FreeTube.
All configurable options can be deduced by enabling them through the
GUI and observing the changes in {file}`settings.db`.
'';
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."FreeTube/hm_settings.db" = {
source = pkgs.writeText "hm_settings.db" (settings cfg.settings);
onChange = let
hmSettingsDb = "${config.xdg.configHome}/FreeTube/hm_settings.db";
settingsDb = "${config.xdg.configHome}/FreeTube/settings.db";
in ''
run install -Dm644 $VERBOSE_ARG '${hmSettingsDb}' '${settingsDb}'
'';
};
};
}

View File

@ -190,6 +190,7 @@ in import nmtSrc {
./modules/programs/boxxy
./modules/programs/firefox
./modules/programs/foot
./modules/programs/freetube
./modules/programs/fuzzel
./modules/programs/getmail
./modules/programs/gnome-terminal

View File

@ -0,0 +1,8 @@
{"_id":"allowDashAv1Formats","value":true}
{"_id":"checkForBlogPosts","value":false}
{"_id":"checkForUpdates","value":false}
{"_id":"commentAutoLoadEnabled","value":true}
{"_id":"defaultQuality","value":"1080"}
{"_id":"hideHeaderLogo","value":true}
{"_id":"listType","value":"list"}
{"_id":"useRssFeeds","value":true}

View File

@ -0,0 +1,30 @@
{ config, pkgs, ... }:
{
programs.freetube = {
enable = true;
settings = {
useRssFeeds = true;
hideHeaderLogo = true;
allowDashAv1Formats = true;
commentAutoLoadEnabled = true;
checkForUpdates = false;
checkForBlogPosts = false;
listType = "list";
defaultQuality = "1080";
};
};
test.stubs.freetube = { };
nmt.script = ''
assertFileExists home-files/.config/FreeTube/hm_settings.db
assertFileContent home-files/.config/FreeTube/hm_settings.db \
${./basic-configuration.db}
assertFileContains activate \
"install -Dm644 \$VERBOSE_ARG '/home/hm-user/.config/FreeTube/hm_settings.db' '/home/hm-user/.config/FreeTube/settings.db'"
'';
}

View File

@ -0,0 +1 @@
{ freetube-basic-configuration = ./basic-configuration.nix; }