-
Notifications
You must be signed in to change notification settings - Fork 2
From-source nix-built artifacts without the "nix" Extra Attribute #31
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
Changes from all commits
d3f05e6
4d630f8
7ac1563
630c28f
d43d071
b8bb800
117a8ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,6 +102,11 @@ let | |
| concatStringsSep "\n" (["mkdir -p $out"] ++ concatLists (map copyTemplate templates)) | ||
| ); | ||
|
|
||
| copyFile = name: input: | ||
| runCommand name { inherit input; } '' | ||
| cp -a $input $out | ||
| ''; | ||
|
|
||
| in rec { | ||
| mkRepo = name: artifacts: localBuildsRepo: runCommand name {} | ||
| (let | ||
|
|
@@ -110,23 +115,28 @@ in rec { | |
| linkArtifact = outputPath: urlAttrs: | ||
| let | ||
| artifact = | ||
| (if builtins.substring 0 5 urlAttrs.url == "file:" then | ||
| if urlAttrs.type or null == "built" then | ||
| if localBuildsRepo == "" then | ||
| abort "'sbtixBuildInputs' parameter missing from 'buildSbtProgram'/'buildSbtLibrary', but local dependencies found." | ||
|
roberth marked this conversation as resolved.
|
||
| else | ||
| # replace the nix store path prefix to make sure | ||
| # a repo.nix generated with a different version of | ||
| # nixpkgs but the same dependencies will still work: | ||
| localBuildsRepo + "/" + (lib.strings.concatStringsSep "/" (lib.lists.drop 4 (lib.strings.splitString "/" urlAttrs.url))) | ||
| # Unlike fetched JARs which are content addressed derivations by virtue of being fixed-output, | ||
| # these copies are not content addressed, because ca-derivations is still experimental. | ||
| # This is unfortunate, because it will create duplication in the store during builds and development, | ||
| # but at least these can be GC-ed and allow the end result to only reference the single JARs that | ||
| # result from this copying operation. | ||
| copyFile (baseNameOf urlAttrs.path) (localBuildsRepo + "/" + urlAttrs.path) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I see how this is an improvement in some cases, though indeed not in others. I'm OK with leaving it like this for now and perhaps fine-tuning further in the future. |
||
| else | ||
| fetchurl urlAttrs | ||
| ); | ||
| fetchurl urlAttrs; | ||
| hashBash = | ||
| if urlAttrs.type or null == "built" | ||
| then ''$(sha256sum "${artifact}" | cut -c -64)'' | ||
| else ''$(echo ${toLower urlAttrs.sha256} | tr / _)''; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @raboof We could use Refs #20 (comment)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possible hash format conversion primops
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using the |
||
| in | ||
| [ ''mkdir -p "$out/${parentDirs outputPath}"'' | ||
| ''ln -fsn "${artifact}" "$out/${outputPath}"'' | ||
| # TODO: include the executable bit as a suffix of the hash. | ||
| # Shouldn't matter in our use case though. | ||
| ''ln -fsn "${artifact}" "$out/cas/$(echo ${toLower urlAttrs.sha256} | tr / _)"'' | ||
| ''ln -fsn "${artifact}" "$out/cas/${hashBash}"'' | ||
| ]; | ||
| in | ||
| '' | ||
|
|
@@ -232,6 +242,17 @@ in rec { | |
| runHook postDist | ||
| ''; | ||
|
|
||
| # These inputs are only meant for the build process. If they stick | ||
| # around in the outputs, they'd just bloat the user package for no | ||
| # good reason. | ||
| disallowedReferences = [ | ||
| combinedCas | ||
| sbtixRepos | ||
| nixrepo | ||
| ] | ||
|
roberth marked this conversation as resolved.
|
||
| ++ lib.optional (localBuildsRepo != "") [ | ||
| localBuildsRepo | ||
| ]; | ||
| } // args // { | ||
| repo = null; | ||
| buildInputs = [ makeWrapper jdk sbt ] ++ buildInputs; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.