diff --git a/.github/workflows/scheduled_sync.yml b/.github/workflows/scheduled_sync.yml index 16716c3..5e3a44c 100644 --- a/.github/workflows/scheduled_sync.yml +++ b/.github/workflows/scheduled_sync.yml @@ -12,30 +12,13 @@ jobs: COVER_PDF_PATH: resources/cover.pdf steps: - uses: actions/checkout@v4 - - name: setup python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - architecture: 'x64' - - name: install python dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt + - uses: cachix/install-nix-action@v30 - name: build pdf - run: python main_async.py + run: nix develop --command 'python main_async.py' - name: optimize pdf size run: | - mkdir pdfsizeopt - cd pdfsizeopt - wget -O pdfsizeopt_libexec_linux.tar.gz https://github.com/pts/pdfsizeopt/releases/download/2023-04-18/pdfsizeopt_libexec_linux-v9.tar.gz - tar xzvf pdfsizeopt_libexec_linux.tar.gz - rm -f pdfsizeopt_libexec_linux.tar.gz - wget -O pdfsizeopt.single https://raw.githubusercontent.com/pts/pdfsizeopt/master/pdfsizeopt.single - chmod +x pdfsizeopt.single - ln -s pdfsizeopt.single pdfsizeopt - cd .. mv out/guide.pdf . - ./pdfsizeopt/pdfsizeopt guide.pdf out/guide.pdf + gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -dNOPAUSE -dQUIET -dBATCH -sOutputFile=out/guide.pdf guide.pdf - name: build redirect page run: cp resources/index.html out/index.html - name: upload diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..0cfaf0b --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1733479337, + "narHash": "sha256-MQU+VnrN/L03J/Mq3apkpKUOIryWiDv41FWqNmIknu0=", + "owner": "yoctocell", + "repo": "nixpkgs", + "rev": "d1ae543c98eda497cf0724da2795fcfd3dac029e", + "type": "github" + }, + "original": { + "owner": "yoctocell", + "ref": "add-python-lark-oapi", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..2946327 --- /dev/null +++ b/flake.nix @@ -0,0 +1,24 @@ +{ + description = "ACSSZ guide for new students and scholars"; + + # TODO 使用上游仓库 + inputs.nixpkgs.url = "github:yoctocell/nixpkgs/add-python-lark-oapi"; + + outputs = { self, nixpkgs }: + let pkgs = nixpkgs.legacyPackages.x86_64-linux; + in with pkgs; { + devShell.x86_64-linux = mkShell { + name = "acssz-guide"; + buildInputs = [ + # For compressing pdfs, see + ghostscript + pkgs.python3Packages.pymupdf + (pkgs.python3.withPackages (pp: with pp; [ + requests + websockets + lark-oapi + ])) + ]; + }; + }; +}