Giter Club home page Giter Club logo

cache-install's Introduction

Cache install Nix packages

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.

Inputs

  • key - An explicit key for restoring and saving the cache
  • nix_version - Nix version, defaults to nixos-unstable
  • nix_file - Nix file, defaults to default.nix

Example workflow

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
]

cache-install's People

Contributors

cohencyril avatar rikhuijzer avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.