Skip to content

Commit

Permalink
feat(pkgs): improve calibre packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
wrvsrx committed Feb 18, 2024
1 parent 0f6be5c commit 421d359
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 139 deletions.
6 changes: 3 additions & 3 deletions pkgs/to-override-packages/calibre/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ stdenv.mkDerivation (finalAttrs: {
})
(fetchpatch {
name = "build-from-git-without-internet";
url = "https://github.com/kovidgoyal/calibre/compare/86471d3a030b6aa9d6a421d147bfdd95add523ef...c58d4a129952f9b5ab841472e9fd7e6d54a30652.patch";
hash = "sha256-3x66nFFh9ovD0QCibSmLXvTqF42Tr9zY2z5d3SC/t5Q=";
url = "https://github.com/kovidgoyal/calibre/commit/4b7c79f71821e9d13edff5d04249c5decf1093a0.patch";
hash = "sha256-1czbc5Z5BsvtyVWnQwFH3Wsn+31RfahjulwtXHJVQKA=";
})
]
++ lib.optional (!unrarSupport) ./dont_build_unrar_plugin.patch;
Expand Down Expand Up @@ -199,7 +199,7 @@ stdenv.mkDerivation (finalAttrs: {
# this is get from https://code.calibre-ebook.com/ua-popularity
# It's not reproducible, so we have to pack it in repo
# this file can be generated using `python fetch-ua.py`
UA_POPULARITY = "${./ua-popularity.json}";
UA_POPULARITY = "${./ua-popularity.txt}";
};

buildPhase = ''
Expand Down
13 changes: 8 additions & 5 deletions pkgs/to-override-packages/calibre/fetch-ua.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import json

subprocess.check_call(['nix', 'build', '.#calibre.src'])
from result.setup.browser_data import get_data
data = get_data()
with open('ua-popularity.json', 'w', encoding='utf-8') as f:
json.dump(data, f, indent=2, ensure_ascii=False, sort_keys=True)
# to pass nixpkgs eol check
from result.setup.browser_data import download_from_calibre_server

raw = download_from_calibre_server(
'https://code.calibre-ebook.com/ua-popularity')
content = bz2.decompress(raw).decode('utf-8')
with open('ua-popularity.txt', 'w') as f:
f.write(content)
# to pass nixpkgs newline check
f.write('\n')
subprocess.check_call(['rm', 'result'])
113 changes: 0 additions & 113 deletions pkgs/to-override-packages/calibre/ua-popularity.json

This file was deleted.

Loading

0 comments on commit 421d359

Please sign in to comment.