Skip to content

Commit

Permalink
feat: nix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryolitia committed Apr 8, 2024
1 parent 9080eb3 commit 7599e39
Show file tree
Hide file tree
Showing 4 changed files with 229 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ book
.vitepress/cache
.vitepress/dist
node_modules
result
130 changes: 130 additions & 0 deletions flake.lock

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

97 changes: 97 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
description = "Transky-book's Nix flake";
nixConfig =
{
experimental-features = [ "nix-command" "flakes" ];
substituters = [
# "https://mirrors.cernet.edu.cn/nix-channels/store"
# "https://mirrors.bfsu.edu.cn/nix-channels/store"
"https://cache.nixos.org/"
];
extra-substituters = [
"https://cryolitia.cachix.org"
];
extra-trusted-public-keys = [
"cryolitia.cachix.org-1:/RUeJIs3lEUX4X/oOco/eIcysKZEMxZNjqiMgXVItQ8="
];
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

nur-cryolitia = {
url = "github:Cryolitia/nur-packages";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, nur-cryolitia }:
{
packages.x86_64-linux.default =
let
pkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [
(final: prev: {
nur-cryolitia = nur-cryolitia.packages."${prev.system}";
})
];
};
in
pkgs.callPackage (
{ lib
, stdenvNoCC
, calibre
, mdbook
, mdbook-epub
, nur-cryolitia
, source-han-serif
}:

stdenvNoCC.mkDerivation
rec {
pname = "transky-book";
version = "unstable";

src = ./.;

nativeBuildInputs = [
calibre
mdbook
mdbook-epub
nur-cryolitia.mdbook-typst-pdf
source-han-serif
];

buildPhase = ''
runHook preBuild
find src/ -type f -name "*.md" ! -path "src/index.md" -exec \
sed -i "/^---$/,/^---$/d" {} \;
mdbook build
mkdir -p book/mobi
ebook-convert book/epub/药娘的天空.epub book/mobi/药娘的天空.mobi
runHook postBuild
'';

installPhase = ''
runHook preInstall
mkdir -p $out/share/transky-book
cp -r book $out/share/transky-book/
runHook postInstall
'';

meta = with lib; {
description = "药娘的天空";
homepage = "https://github.com/transky-book/transky";
license = licenses.cc-by-nc-sa-40;
maintainers = with maintainers; [ Cryolitia ];
};
}
) {};
};
}
9 changes: 1 addition & 8 deletions theme/template.typ
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
#set text(
lang: "zh",
font: (
"Noto Sans",
"Noto Sans SC",
"Noto Sans KR",
"Noto Sans Thai",
"Noto Sans Arabic",
"Noto Sans Hebrew",
"Noto Sans Devanagari",
"Noto Emoji",
"Source Han Serif",
),
)

Expand Down

0 comments on commit 7599e39

Please sign in to comment.