{ inputs = { nixpkgs.url = "nixpkgs/nixos-22.11"; yokutango = { url = "git+https://git.nani.wtf/h7x4/yokutango?ref=master"; flake = false; }; noto-cjk-jp-otf-regular = { url = "https://github.com/notofonts/noto-cjk/raw/main/Sans/OTF/Japanese/NotoSansCJKjp-Regular.otf"; flake = false; }; }; outputs = { self, nixpkgs, yokutango, noto-cjk-jp-otf-regular }: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; inherit (pkgs) lib; nativeBuildInputs = with pkgs; [ self.packages.${system}.yokutango2tex texlive.combined.scheme-full ]; FONTCONFIG_FILE = pkgs.makeFontsConf { fontDirectories = with pkgs; [ noto-fonts self.packages.${system}.noto-sans-cjk-jp ]; }; in { devshells.default = { inherit nativeBuildInputs FONTCONFIG_FILE; }; packages.${system} = { default = self.packages.${system}.yokutango-pdf; noto-sans-cjk-jp = pkgs.runCommandLocal "noto-sans-cjk-jp" {} '' mkdir -p $out/share/fonts/opentype/noto-cjk ln -s ${noto-cjk-jp-otf-regular} $out/share/fonts/opentype/noto-cjk/NotoSansCJKjp-Regular.otf ''; yokutango-json = pkgs.runCommandLocal "yokutango-json" {} '' ln -s ${yokutango}/json $out ''; yokutango2tex = pkgs.writers.writeHaskellBin "yokutango2tex" { libraries = with pkgs.haskellPackages; [ aeson bytestring ]; } (lib.fileContents ./yokutango2tex.hs); yokutango-pdf = let template = lib.fileContents ./template.tex; y2t-output-d = pkgs.runCommand "yokutango2tex-output" {} '' ${self.packages.${system}.yokutango2tex}/bin/yokutango2tex ${self.packages.${system}.yokutango-json} > $out ''; y2t-output = lib.fileContents y2t-output-d; combined = pkgs.writeText ''yokutango.tex'' (builtins.replaceStrings ["% --- %"] [y2t-output] template); in pkgs.runCommand "yokutango-pdf" { inherit nativeBuildInputs FONTCONFIG_FILE; } '' mkdir $out ln -s ${combined} yokutango.tex ln -s ${combined} $out/yokutango.tex xelatex yokutango.tex mv yokutango.pdf $out ''; yokutango-test = let template = lib.fileContents ./template.tex; body = lib.fileContents ./testContent.tex; combined = pkgs.writeText ''yokutango-test.tex'' (builtins.replaceStrings ["% --- %"] [body] template); in pkgs.runCommand "yokutango-pdf" { inherit nativeBuildInputs FONTCONFIG_FILE; } '' mkdir $out ln -s ${combined} yokutango-test.tex ln -s ${combined} $out/yokutango-test.tex xelatex yokutango-test.tex mv yokutango-test.pdf $out ''; }; }; }