cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
4.04k stars 303 forks source link

Extending devenv module #968

Open MrFoxPro opened 7 months ago

MrFoxPro commented 7 months ago

I want to make all my scripts run from flake root, like this:

scripts.hello.exec = "pushd ${devenv.root}; hello; popd"

How can I iterate over all my scripts and wrap them into pushd ... popd?

domenkozar commented 7 months ago
let 
  withRoot = script: ''
    pushd ${devenv.root}
    ${script}
    popd
  '';
in {
  scripts.hello.exec = withRoot "hello";
}
MrFoxPro commented 7 months ago
let 
  withRoot = script: ''
    pushd ${devenv.root}
    ${script}
    popd
  '';
in {
  scripts.hello.exec = withRoot "hello";
}

I mean I have 17 scripts in my monorepository splitted across multiple devenv modules, so I need to apply it to a lot of commands. When using Nix, I would prefer to implement it via expression, but I can't understand how can I extend devenv module to achieve it