Skip to content

Allow MathCATRulesDir to override the rules directory without code changes #771

Description

@moritz-gross

Originally posted by @theCapypara in #749

No, just adding the Cargo.lock is enough for us in that regard. Just tested your PR, builds fine! Thanks!

I just noticed Orca actually vendors MathCAT itself and provides its own Cargo.lock we can use. While I'll use that for Orca, I'll probably still package MathCAT for NixOS as a standalone package, because why not :).

The only other somewhat annoying thing for that is the way that the path to the rules directory is currently somewhat hardcoded and the MathCATRulesDir env variable only being read when a code change is made.

For various reasons we need to provide a custom path to MathCAT.

This requires us to do these patches to make it work:

{
  postPatch = ''
    substituteInPlace src/main.rs \
      --replace-fail 'set_rules_dir(get_rules_dir())' 'set_rules_dir("".to_string())'
    substituteInPlace tests/common/mod.rs \
      --replace-fail 'set_rules_dir(abs_rules_dir_path())' 'set_rules_dir("".to_string())'
  '';

  preCheck = ''
    export MathCATRulesDir="$src/Rules"
  '';

  postInstall = ''
    install -dm755 "$out/rules"
    cp -a ./Rules "$out/rules"
    wrapProgram $out/bin/mathcat --set MathCATRulesDir "$out/rules"
  '';
}
  • The "postPatch" section here replaces set_rules_dir(get_rules_dir()) with set_rules_dir("".to_string()) (and does the same for the tests)
  • In "preCheck" we make sure the tests see the rules
  • In "postInstall" we install the rules and make sure the final mathcat binary actually sees them

Ideally for us, the "postPatch" section would not be needed.

Originally posted by @theCapypara in #749

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions