-
Notifications
You must be signed in to change notification settings - Fork 122
Refactor setup for generated nix files #1223
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # This file generates the contents of nix/generated/. Use | ||
| # | ||
| # cp -fv $(nix-build generate.nix --no-link)/ generated/ | ||
| # | ||
| # to update | ||
|
|
||
| { pkgs ? import ../nix {} }: | ||
|
|
||
| let | ||
|
|
||
| # `haskellSrc2nixWithDoc` is used to generate `default.nix` files for | ||
| # Haskell packages which are intended to be stored in the repository. | ||
| # | ||
| # The function generates a directory containing a `default.nix` which | ||
| # is the result of running `cabal2nix` with the `extraCabal2nixOptions` | ||
| # on the provided `src`. | ||
| # | ||
| # A header is added to `default.nix` which contains instructions on | ||
| # how to regenerate that file. | ||
| # | ||
| # Finally the `src` attribute in the `default.nix` will be defined as | ||
| # `src_subst` such that it can be pointed to local or niv-managed | ||
| # sources. | ||
| haskellSrc2nixWithDoc = {name, src, src_subst, extraCabal2nixOptions}: | ||
| let | ||
| drv = pkgs.haskellPackages.haskellSrc2nix { | ||
| inherit name extraCabal2nixOptions src; | ||
| }; | ||
| in drv.overrideAttrs (oldAttrs: { | ||
| message = '' | ||
| # THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT EDIT MANUALLY!\ | ||
| # See ./nix/generate.nix for instructions.\ | ||
|
|
||
| ''; | ||
| inherit src_subst; | ||
| installPhase = oldAttrs.installPhase + '' | ||
| sed -i "1i$message;s|src = .*|src = $src_subst;|" $out/default.nix | ||
| # Accept `pkgs` as an argument in case the `src_subst` depends on it. | ||
| sed -i "s|{ mkDerivation|{ mkDerivation, pkgs|" $out/default.nix | ||
| ''; | ||
| }); | ||
|
|
||
| # A variant of `haskellSrc2nixWithDoc` for local Haskell packages. | ||
| localHaskellSrc2nixWithDoc = name: path: extraCabal2nixOptions: | ||
| haskellSrc2nixWithDoc { | ||
| inherit name extraCabal2nixOptions; | ||
| src = import ./gitSource.nix path; | ||
| src_subst = "import ../gitSource.nix \"${path}\""; | ||
| }; | ||
|
|
||
|
|
||
| winter = (haskellSrc2nixWithDoc { | ||
| name = "winter"; | ||
| src = pkgs.sources.winter; | ||
| src_subst = "pkgs.sources.winter"; | ||
| extraCabal2nixOptions = "--no-check"; | ||
| }); | ||
|
|
||
| ic-stub = localHaskellSrc2nixWithDoc "ic-stub" "ic-stub" "--no-check"; | ||
| random = localHaskellSrc2nixWithDoc "qc-motoko" "test/random" ""; | ||
| lsp-int = localHaskellSrc2nixWithDoc "lsp-int" "test/lsp-int" ""; | ||
|
|
||
| allGenerated = pkgs.runCommandNoCC "generated" {} '' | ||
| mkdir -p $out | ||
| cp ${winter}/default.nix $out/winter.nix | ||
| cp ${ic-stub}/default.nix $out/ic-stub.nix | ||
| cp ${random}/default.nix $out/random.nix | ||
| cp ${lsp-int}/default.nix $out/lsp-int.nix | ||
| ''; | ||
| in | ||
| allGenerated | ||
|
|
||
|
|
||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT EDIT MANUALLY! | ||
| # See ./nix/generate.nix for instructions. | ||
|
|
||
| { mkDerivation, pkgs, base, data-default, directory, filepath | ||
| , haskell-lsp-types, hspec, HUnit, lens, lsp-test, stdenv, text | ||
| }: | ||
| mkDerivation { | ||
| pname = "lsp-int"; | ||
| version = "0"; | ||
| src = import ../gitSource.nix "test/lsp-int"; | ||
| isLibrary = false; | ||
| isExecutable = true; | ||
| executableHaskellDepends = [ | ||
| base data-default directory filepath haskell-lsp-types hspec HUnit | ||
| lens lsp-test text | ||
| ]; | ||
| description = "Integration tests for the language server"; | ||
| license = "unknown"; | ||
| hydraPlatforms = stdenv.lib.platforms.none; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
For inexpensive builds like this I would use:
To let CI build this locally instead of shipping inputs and outputs to and from remote builders / cache.
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.
But is it inexpensive? It still depends on
cabal2nix, so you’d have to build that on hydra, rather than the builders… Maybe it is not a concern.The other reason is that we want
cabal2nixetc. to be available on the cache, and this is the derivation that uses it, and the cache is only fed by the builders, isn’t it?