From 84bbcdfa4b5c0d658fadb8d0442e67cc3076cfcc Mon Sep 17 00:00:00 2001 From: Jordan Holt Date: Sat, 1 Feb 2025 14:10:05 +0000 Subject: [PATCH] home-assistant: remove duplicate floorplan resource --- hosts/odyssey/default.nix | 9 ++- .../home-assistant/floorplan/default.nix | 6 -- ...-the-default-config-file-is-writable.patch | 25 ++++++ pkgs/streamrip/package.nix | 78 +++++++++++++++++++ 4 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 pkgs/streamrip/ensure-the-default-config-file-is-writable.patch create mode 100644 pkgs/streamrip/package.nix diff --git a/hosts/odyssey/default.nix b/hosts/odyssey/default.nix index 90b75d2..260b66f 100644 --- a/hosts/odyssey/default.nix +++ b/hosts/odyssey/default.nix @@ -1,5 +1,8 @@ -{ config, ... }: +{ config, pkgs, ... }: +let + streamrip = pkgs.callPackage ../../pkgs/streamrip/package.nix { }; +in { imports = [ ./hardware-configuration.nix @@ -53,6 +56,10 @@ }; }; + environment.systemPackages = [ + streamrip + ]; + modules = { programs = { dev = { diff --git a/modules/nixos/services/home-assistant/floorplan/default.nix b/modules/nixos/services/home-assistant/floorplan/default.nix index 48153f9..9ef247b 100644 --- a/modules/nixos/services/home-assistant/floorplan/default.nix +++ b/modules/nixos/services/home-assistant/floorplan/default.nix @@ -11,12 +11,6 @@ in { config = lib.mkIf cfg.enable { services.home-assistant = { - config.lovelace.resources = [ - { - url = "/local/nixos-lovelace-modules/floorplan.js"; - type = "module"; - } - ]; customLovelaceModules = [ pkgs.lovelace-floorplan ]; diff --git a/pkgs/streamrip/ensure-the-default-config-file-is-writable.patch b/pkgs/streamrip/ensure-the-default-config-file-is-writable.patch new file mode 100644 index 0000000..9479eed --- /dev/null +++ b/pkgs/streamrip/ensure-the-default-config-file-is-writable.patch @@ -0,0 +1,25 @@ +From 18efb9b5c8e562b169425f6ba79977e52e8b91b9 Mon Sep 17 00:00:00 2001 +From: Pavel Sobolev +Date: Sat, 13 Jan 2024 12:49:45 +0000 +Subject: [PATCH] Ensure the default config file is writable. + +--- + streamrip/config.py | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/streamrip/config.py b/streamrip/config.py +index 7ee2f57..88a5fef 100644 +--- a/streamrip/config.py ++++ b/streamrip/config.py +@@ -378,6 +378,9 @@ def set_user_defaults(path: str, /): + """Update the TOML file at the path with user-specific default values.""" + shutil.copy(BLANK_CONFIG_PATH, path) + ++ # Ensure the default config file is writable ++ os.chmod(path, 0o644) ++ + with open(path) as f: + toml = parse(f.read()) + toml["downloads"]["folder"] = DEFAULT_DOWNLOADS_FOLDER # type: ignore +-- +2.42.0 diff --git a/pkgs/streamrip/package.nix b/pkgs/streamrip/package.nix new file mode 100644 index 0000000..07eabb7 --- /dev/null +++ b/pkgs/streamrip/package.nix @@ -0,0 +1,78 @@ +{ + lib, + python3Packages, + fetchFromGitHub, + + ffmpeg, +}: + +python3Packages.buildPythonApplication { + pname = "streamrip"; + version = "2.0.7"; + pyproject = true; + + src = fetchFromGitHub { + owner = "nathom"; + repo = "streamrip"; + rev = "46b570dbb6f81d604cbaa3bfa379463e0a20a841"; + hash = "sha256-LD99OjguaBnrQxCwmCeHvmBMq5aOfobwnMd5/aCRZW8="; + }; + + patches = [ + ./ensure-the-default-config-file-is-writable.patch + ]; + + nativeBuildInputs = with python3Packages; [ + poetry-core + ]; + + propagatedBuildInputs = with python3Packages; [ + aiodns + aiofiles + aiohttp + aiolimiter + appdirs + cleo + click-help-colors + deezer-py + m3u8 + mutagen + pathvalidate + pillow + pycryptodomex + pytest-asyncio + pytest-mock + rich + simple-term-menu + tomlkit + tqdm + ]; + + nativeCheckInputs = with python3Packages; [ + pytestCheckHook + ]; + + prePatch = '' + sed -i 's#aiofiles = ".*"#aiofiles = "*"#' pyproject.toml + sed -i 's#deezer-py = ".*"#deezer-py = "*"#' pyproject.toml + sed -i 's#m3u8 = ".*"#m3u8 = "*"#' pyproject.toml + sed -i 's#pathvalidate = ".*"#pathvalidate = "*"#' pyproject.toml + sed -i 's#Pillow = ".*"#Pillow = "*"#' pyproject.toml + sed -i 's#pytest-asyncio = ".*"#pytest-asyncio = "*"#' pyproject.toml + sed -i 's#tomlkit = ".*"#tomlkit = "*"#' pyproject.toml + + sed -i 's#"ffmpeg"#"${lib.getBin ffmpeg}/bin/ffmpeg"#g' streamrip/client/downloadable.py + ''; + + preCheck = '' + export HOME=$(mktemp -d) + ''; + + meta = with lib; { + description = "Scriptable music downloader for Qobuz, Tidal, SoundCloud, and Deezer"; + homepage = "https://github.com/nathom/streamrip"; + license = licenses.gpl3Only; + maintainers = with maintainers; [ paveloom ]; + mainProgram = "rip"; + }; +}