Skip to content

Commit

Permalink
Add Nix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
siraben committed Mar 31, 2022
1 parent d972b5e commit f487968
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,6 @@ dmypy.json
\.idea/

swaglyrics/unsupported.txt

# Flake
result
9 changes: 9 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash; }
) {
src = ./.;
}).defaultNix
60 changes: 60 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
description = "Swaglyrics for Spotify";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};

outputs = { self, nixpkgs, utils, ... }:
utils.lib.eachDefaultSystem (system:
with import nixpkgs { inherit system; }; {
defaultPackage = callPackage ./package.nix {};
}
);
}
47 changes: 47 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{ lib, python3, fetchFromGitHub, ncurses }:

python3.pkgs.buildPythonApplication rec {
pname = "swaglyrics";
version = "unstable-2021-06-17";

src = fetchFromGitHub {
owner = "SwagLyrics";
repo = "SwagLyrics-For-Spotify";
rev = "99fe764a9e45cac6cb9fcdf724c7d2f8cb4524fb";
sha256 = "sha256-O48T1WsUIVnNQb8gmzSkFFHTOiFOKVSAEYhF9zUqZz0=";
};

propagatedBuildInputs = with python3.pkgs; [
unidecode colorama beautifulsoup4 flask requests swspotify
];

preConfigure = ''
substituteInPlace setup.py \
--replace 'beautifulsoup4==4.9.3' 'beautifulsoup4>=4.9.3' \
--replace 'unidecode==1.2.0' 'unidecode>=1.2.0' \
--replace 'flask==2.0.1' 'flask>=2.0.1'
'';

preBuild = "export HOME=$NIX_BUILD_TOP";

# disable tests which touch network
disabledTests = [
"test_database_for_unsupported_song"
"test_that_lyrics_works_for_unsupported_songs"
"test_that_get_lyrics_works"
"test_lyrics_are_shown_in_tab"
"test_songchanged_can_raise_songplaying"
];

checkInputs = with python3.pkgs;
[ blinker swspotify pytestCheckHook flask mock flask_testing ]
++ [ ncurses ];

meta = with lib; {
description = "Lyrics fetcher for currently playing Spotify song";
homepage = "https://github.com/SwagLyrics/SwagLyrics-For-Spotify";
license = licenses.mit;
maintainers = with maintainers; [ siraben ];
platforms = platforms.unix;
};
}

0 comments on commit f487968

Please sign in to comment.