This actions allows caching of installations done via the Nix package manager to improve workflow execution time.
Installing packages via the Nix package manager is generally quite quick.
However, sometimes the packages take a long time to compile or to download from their original sources.
For example, this occurs with R packages and LaTeX which are downloaded from respectively CRAN
and math.utah.edu
.
This GitHub Action speeds up the installation by simply caching the Nix store and the symlinks to the packages in the store in the GitHub Actions cache.
So, the installed packages are restored from the cache by copying back /nix/store
, the symlinks to /nix/store/*
and some paths for the PATH environment variable.
key
- An explicit key for restoring and saving the cachenix_version
- Nix version, defaults tonixos-unstable
nix_file
- Nix file, defaults todefault.nix
name: latex
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache install Nix packages
uses: rikhuijzer/cache-install@v1
with:
key: nix-${{ hashFiles('mypackages.nix') }}
nix_file: 'mypackages.nix'
- name: Calculate some things
run: julia -e 'using MyPackage; MyPackage.calculate()'
- name: Build LaTeX
run: latexmk -f -pdf example.tex
- name: Build website
run: hugo --gc --minify
where the file mypackages.nix
contains
let
# Pinning explicitly to 20.03.
rev = "5272327b81ed355bbed5659b8d303cf2979b6953";
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
pkgs = import nixpkgs {};
myTex = with pkgs; texlive.combine {
inherit (texlive) scheme-medium pdfcrop;
};
in with pkgs; [
hugo
julia
myTex
]