Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argparser and file options #41

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

Profpatsch
Copy link

Contains #40

This fixes a downstream problem we have in a company project, where in order to run spago2nix in a temporary directory we need to jump through hoops to copy the .spago2nix and spago.dhall files around instead of just passing them as arguments.

I took the chance to switch to an optparse library, which simplifies adding new flags by a lot (until now it was only positional arguments, but optional stuff like flags is not so easy to parse adhoc-ly.

Alternatively, we could keep the argparser as it is and stub the files with environment variables.

Updates the package set from 0.13.0 to 0.13.3, which is the closest
release that contains optparse.
Preparing to add flags to generate, so we can pass the spago.dhall
file and cache directory.

The resulting parser should be more or less the same, apart from a
slight difference in the usage text. I tried keeping it as similar as
possible.
And a bit of shuffling to import the sources in the right way.

default.nix should have the same interface than before, I make sure
the existing args are still there.

Originally created with niv, but removed all the bs.
The default of `./.spago2nix` not super helpful when running spago2nix
from a script that should run in a temporary directory but still use
the existing cache directory.
Similarly to the `--cache-dir` option, when running `spago2nix` from a
script the current working dir is often a tempdir outside of our
source directory, thus we need a way to pass the path to
`spago.dhall`.

Since dhall handles relative imports based on file location,
just passing the “entry point” `spago.dhall` is enough.
If somebody passes e.g. `--spago-dhall=`, that would mean they
reference `.`, which is dumb.
Previously we just parsed argv, but the optparse library recognizes
`-*` as options now, so the rest of the argv needs to be splitt off
with `--`, as customary.

This is a breaking change.
Add a CHANGELOG file and document the breaking change to the nix argv.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant