-
Notifications
You must be signed in to change notification settings - Fork 38
fix(modules.symlinkScript): substitute replace-literal with sd #525
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
Open
Elias-Graf
wants to merge
1
commit into
BirdeeHub:main
Choose a base branch
from
Elias-Graf:substitute-replace-sd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+55
−27
Open
Changes from all commits
Commits
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
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.
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.
@BirdeeHub I'm fairly sure that this also works for binaries, although I would like to test it. Do we have any?
If not, we should probably use something like
substituteInPlaceinstead.If yes, we should probably add a check for binaries in
checks/filesToPatch.nix.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.
we do not have any that we are patching in this repo, but a derivation could have a binary in it, they often do, and filesToPatch should be able to replace strings in it.
We should add a test yes. Maybe add a test where you replace something in the main binary of some program? Like, compile a binary with a drv path from its own drv, and then try to search and replace that drv path with one in the final derivation?
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.
@BirdeeHub Sorry! I'm afraid I need a little pointer here. Let's say I have the following dummy package:
This "package" references itself to "print its path".
Now making a wrapper with:
Given:
I get:
The file that gets patched by saying:
filesToPatch = [ "bin/dummy-app" ];is:Which is just the wrapper generated by this library:
What I actually would want to patch is the derivation referenced inside this wrapper:
Am I doing/understanding something incorrectly? Is the binary we're calling ever inside "our" derivation? Can we even patch that?
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.
Ah
So, if the binary you want to patch is in a place we already overwrite, then yeah thats not gonna work...
You would want to wrap pkgs.hello the old fashioned way with pkgs.makeBinaryWrapper, and put into
--greeting${placeholder "out"}, which will refer to THAT derivation. And tell it to create that binary somewhere in the drv that isnt going to be overwritten.Then you would pass that to config.package, and you should be able to use filesToPatch to patch the placeholder out path in the binary you created to point to the new wrapper derivation instead of the location inside the config.package drv
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.
I'm not sure if I totally understood everything. Given that we're always replacing the main binary, there would not be any simple way to patch that, no?
If the idea was to "move" the main binary to a different place, have our package be in the original place, and call the moved one, I would have to further look into how to do that.
But simply creating a second binary will solve the issue about it getting overwritten if we only care about that.
I've validated that the tests pass with
replace-literal, withsd, and I've validated that the tests fail when usingsubstitutebecause the binary file contains null bytes.