-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
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
darwin: installBinaryPackage init and refactoring of darwin apps #293498
base: master
Are you sure you want to change the base?
Changes from all commits
b111053
82f3b31
d9329f5
6aa67d0
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,44 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ lib, stdenvNoCC, makeSetupHook, _7zz, libarchive }: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ appName ? "." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
, nativeBuildInputs ? [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
, sourceRoot ? "." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
, ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}@args: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
unpackDmgPkg = makeSetupHook { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name = "unpack-dmg-pkg"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
propagatedBuildInputs = [ _7zz libarchive ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} ./unpack-dmg-pkg.sh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stdenvNoCC.mkDerivation (args // { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+3
to
+15
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.
Suggested change
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. Thanks for this, @ShamrockLee, I've included your suggestion locally, but need to refactor the treewide changes before pushing an update on this. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dontMakeSourcesWritable = args.dontMakeSourcesWritable or true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dontPatch = args.dontPatch or true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dontConfigure = args.dontConfigure or true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dontBuild = args.dontBuild or true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dontStrip = args.dontStrip or true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dontFixup = args.dontFixup or true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dontCheck = args.dontCheck or true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Suggested change
The attribute is called If we do need
to guarentee its availability. Attempt to determine if an attribute is available in 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. For some reason I thought both existed, @ShamrockLee. Grep'ing through the packages around 80 use 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. @afh This comment slipped out of my radar. Thank you for your patience.
After some keyword searching inside VSCode, it seems most of the Searching with 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. Once again an excellent analysis from you, @ShamrockLee 😃👍
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.
The proof turns out to be quite simple:
It would be helpful for people who use and maintain these packages. That said, I wonder whether those packages really need their install checks disabled if they build fine without. Feel free to tag the package maintainers in the PR description. 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. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
doInstallCheck = args.doInstallCheck or false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+16
to
+23
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.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sourceRoot = "${args.pname}/${sourceRoot}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Suggested change
Just give it a sensible default. (Replace 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. I think this might be a bit more involved than it seems and possibly a more elegant way exists to solve what the current approach solves. Most of the binary sources unpack multiple files, a directory, or a one or more archive files (often named So my idea was to simple put all unpacked files into a directory named Have I been able to explain my thinking around this well? ──────────── 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.
That makes sense. Then, how about setting The current implementation will result in developer setting From the search result inside the Nixpkgs code base with regular expression I could only express my point of view instead of requesting a change, as I'm nither a committer nor a Darwin user. The design choice will be made by you and the committers. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
nativeBuildInputs = [ unpackDmgPkg ] ++ nativeBuildInputs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
installPhase = args.installPhase or '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
runHook preInstall | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
mkdir -p $out/Applications | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cp -R "${appName}" $out/Applications | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
runHook postInstall | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
installCheckPhase = args.installCheckPhase or null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
meta = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
platforms = lib.platforms.darwin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} // (args.meta or {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# shellcheck shell=bash | ||
unpackCmdHooks+=(unpackDmgPkg) | ||
unpackDmgPkg() { | ||
case "$curSrc" in | ||
*.dmg) unpackDmg "$curSrc";; | ||
*.pkg) unpackPkg "$curSrc";; | ||
*) return 1 | ||
esac | ||
} | ||
|
||
unpackDmg() { | ||
_unpack "$1" "${2:-$pname}" | ||
} | ||
|
||
unpackPkg() { | ||
_unpack "$1" "${2:-$pname}" | ||
pushd "${2:-$pname}" | ||
# Extract files from Payload or Payload~ file contained in given pkg if any | ||
find . -name 'Payload*' -maxdepth 1 -print0 | xargs -0 -t -I % bsdtar -xf % | ||
popd | ||
} | ||
|
||
_unpack() { | ||
# Exclude */Applications files from extraction as they may | ||
# contain a dangerous link path, causing 7zz to error. | ||
# Exclude *com.apple.provenance xattr files from extraction as they | ||
# break the an application's signature and notarization. | ||
7zz x -bd -o"$2" -xr'!*/Applications' -xr'!*com.apple.provenance' "$1" | ||
} |
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.
If we do want one, it could be called
subSourceRoot
or something.