How to deal with `requireFile` on continuous integration?

Hello,

I’m currently working with LaTeX document at work and I created EC Fonts, a flake that provide the corporate font.

Along with code.europa.eu, we are also using Github as mirror but also to benefit of the CI and we build documents through it. For example, this presentation is built on Github action.

I wish I could add the EC Fonts to it, but since it requires to download an archive manually, it’s not possible to use it in the CI.

Therefore, what are the options?
Would it be possible to alter EC Fonts and do nothing when the zip file is not available?

I wish I could add the EC Fonts to it, but since it requires to download an archive manually, it’s not possible to use it in the CI.

From Files · main · Pol Dellaiera / EC Fonts · GitLab

Therefore, in order to use the font, you must accept the terms and conditions at EU Login and download it from: Sorry. Once the file is downloaded, rename it to ${name} and then add it to the Nix store with the following command: nix-prefetch-url file:///path/to/${name}

Is there something preventing you from doing these steps in CI? Or are you saying that you explicitly don’t want to do this in CI?

Would it be possible to alter EC Fonts and do nothing when the zip file is not available?

I feel like it would be easier to remove the dependency on EC Fonts from whatever derivation is depending on it. Is there something in your Nix code base that would make this too difficult?

Since our workflows and work is open source, there’s no way for me to do that.

I have the feeling that this is the best solution indeed. I was just wondering if there would be a way to check the following… if the zip is in the store, use it, if not, do not throw an error, but a warning and continue.

Unless restrict-eval or pure-eval are active you can generally inspect the file system including the store, this of course introduces a (desired) impurity into your Nix expressions, e.g.:

let
  haveRequiredFiles =builtins.pathExists
    (builtins.unsafeDiscardStringContext myRequireFileDrv.outPath);
in

if haveRequiredFiles
then /* … */
else lib.warn "Missing files: …" (
  /* … */
)
2 Likes

I ended up doing a Nix package for this: GitHub - loophp/ci-detector: To detect whether we are in a CI or not

This is how I use it: https://github.com/ecphp/session--nix-at-european-commission--summer-of-nix/blob/main/flake.nix#L29

1 Like