-
Notifications
You must be signed in to change notification settings - Fork 97
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
nix/haskell-packages: replace IFD with importing generated files #1220
Conversation
3e5a156
to
6c5b5ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn I hate the Nix haskell infrastructure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice solution!
I wonder if it would be nicer to keep the generated files all in
./nix/generated/
(e.g. ./nix/generated/winter.nix
), have one command to update all generated files, and only one check, and not require an essentially empty winter/
directory. But probably overkill.
Maybe add a section in Building.md
about Updating Haskell dependencies
?
I opted for keeping the
Good idea. Done. |
Replace IFD calls to callCabal2nix with importing generated `default.nix` files. The generated `default.nix` files are stored in the repository and contain instructions on how to regenerate them. The generation of the `default.nix` files is done using the `haskellSrc2nixWithDoc` function which generates a directory containing a `default.nix` which is the result of running `cabal2nix` with the `extraCabal2nixOptions` on the provided `src`. A header is then added to the `default.nix` which contains instructions on how to regenerate that file. Finally the new jobs are added which check that the stored `default.nix` matches the expected `default.nix`. So whenever the `.cabal` files are updated and don't match the stored `default.nix` anymore CI will complain.
6b482cc
to
ff94efb
Compare
Ugh, now I get this. Any idea?
|
Ah, it somehow broke the proper use of |
is of course wrong. Will refactor… |
the reiterates on #1220. The motivation for the refactoring was that the generated files were not using `gitSource`, so I would get cache misses and dirty files in the repo. Fixing this was easier if all generated nix files are in one place, so I did the following changes: * All generated nix files are in `nix/generated`. This de-pollutes the normal working area with generated files, and keeps them out from sources (more precise derivations). * The local generated files now use `gitSource`. * The generator is now `nix/generate.nix`. * I moved complex logic from `nix/default.nix` to `nix/generate.nix`, this means everything is in one place, instead of spread over several nix files. * There is now only a single check to check if the generated files are upto date, and a single command to update the files. * This check is no longer marked `allowSubstitutes = false`. The check isn’t cheap (it requires `cabal2nix`) and we want the check to happen on builders, not hydra itself, so that the cache has `cabal2nix`. * The check is now included in `all-systems-go`.
the reiterates on #1220. The motivation for the refactoring was that the generated files were not using `gitSource`, so I would get cache misses and dirty files in the repo. Fixing this was easier if all generated nix files are in one place, so I did the following changes: * All generated nix files are in `nix/generated`. This de-pollutes the normal working area with generated files, and keeps them out from sources (more precise derivations). * The local generated files now use `gitSource`. * The generator is now `nix/generate.nix`. * I moved complex logic from `nix/default.nix` to `nix/generate.nix`, this means everything is in one place, instead of spread over several nix files. * There is now only a single check to check if the generated files are upto date, and a single command to update the files. * This check is no longer marked `allowSubstitutes = false`. The check isn’t cheap (it requires `cabal2nix`) and we want the check to happen on builders, not hydra itself, so that the cache has `cabal2nix`. * The check is now included in `all-systems-go`.
https://dfinity.atlassian.net/browse/INF-1002
Replace IFD calls to callCabal2nix with importing generated
default.nix
files.The generated
default.nix
files are stored in the repository and contain instructions on how to regenerate them.The generation of the
default.nix
files is done using thehaskellSrc2nixWithDoc
function which generates a directory containing adefault.nix
which is the result of runningcabal2nix
with the
extraCabal2nixOptions
on the providedsrc
. A header is then added to thedefault.nix
which contains instructions on how to regenerate that file.Finally the new jobs are added which check that the stored
default.nix
matches the expecteddefault.nix
. So whenever the.cabal
files are updated and don't match the storeddefault.nix
anymore CI will complain.