darwin: installBinaryPackage init and refactoring of darwin apps#293498
darwin: installBinaryPackage init and refactoring of darwin apps#293498afh wants to merge 4 commits intoNixOS:masterfrom
Conversation
There was a problem hiding this comment.
- Is this the best way to set sensible defaults, but allow customisation for packages that need it?
- Are there any other
dont*flags that are relevant here?
There was a problem hiding this comment.
Does this implementation allow for enough flexibility for uncommon use-cases (see karabiner-elements) while still making "good" assumptions about the general layout/content of DMGs and PKGs, e.g. unpack any Payload* using bsdtar contained in a .pkg file?
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
|
I like the abstraction made by the dynamic unpack hook for DMG and PKG. Package complexity will drop (IMO) and package's lines reduced by a good margin. But I think we should make sure every possible option is covered. As for some specific behavior, this might even add more complexity inside the package and possibly inside the hook. If this solution is chosen, we should create a detailed documentation to avoid looking everywhere to find options, default behaviors, etc. Love it 👍 |
|
Thank you for taking the time to have a look at this and your comment, @DataHearth, very much appreciated! In your mind what is a good way to ensure that "every possible option is covered"? My first approach would be to refactor the packages in Where would be a good place for such documentation? Somewhere in |
|
Looking at |
38620a5 to
9dd6490
Compare
|
I love the idea of having a unified way to package binaries for MacOS. Regarding the treewide change,
|
|
Thanks for your input, @ShamrockLee, much appreciated!
Any opinion or advice you may have on the "💭 A Few Thoughts" I listed in the initial description? |
|
Hey! Regarding creating a fetcher, I'm not a big fan of. As the "universal" way seems to fetch then unpack for most scenarios, I would keep it as a new package helper. I think the best way to find out if you missed something, it's to check other packages which are using an unpack like I agree with @ShamrockLee , I think this would me much easier to review for a code maintainer with only 1 or 2 packages as examples. |
|
Thanks for the feedback, @DataHearth, that's helpful. I'll do some code level analysis and prepare some notes. In addition to that I'll split this PR into two: one for the install binary package changes and one for the treewide package changes (with a possible follow-up). |
9dd6490 to
c424494
Compare
|
As requested this PR now affects fewer files and the majority of the actual package rewrites to use the changes proposed in this PR will be in #293961. |
| }@args: | ||
|
|
||
| let | ||
| unpackDmgPkg = makeSetupHook { |
There was a problem hiding this comment.
Also why not using undmg to un-package dmgs and then creating a separate hook like unpkg that use the both hooks? This would give more flexibility if a user wanted to use outside of install-binary-package.
There was a problem hiding this comment.
You probably should look into #147567 this had the implementation of unpkg.
There was a problem hiding this comment.
Would be easy to use passthru to expose this. I kind of like the fact this is not spread all over nixpgks.
|
Also isn't this a copy of #147567 |
|
Thanks for taking a look at this, @Eveeifyeve, I've lost some context since last working on this, but I remember this PR going beyond what #147567 did, if I remember correctly Happy to have another look at #147567 to combine the best of the two. |
4619d35 to
4bb4370
Compare
4429904 to
b13ef19
Compare
| pushd "${2:-$pname}" | ||
| # Extract files from Payload or Payload~ file contained in given pkg if any | ||
| # Depending on how apps are packaged maxdepth might need to be adjusted | ||
| # or made adjustable | ||
| find . -name 'Payload*' -maxdepth 2 -print0 | xargs -0 -t -I % bsdtar -xf % | ||
| popd |
There was a problem hiding this comment.
I kind of would like to use a sub shell with cd ... here to avoid leaking a directory change in case of errors`
b13ef19 to
cf947e4
Compare
|
I really like this approach and have started to try and write some nixos tests based on this pull request #441396 to a. better understand how this would work and This seems especially relevant to me, as Still, more is probably not required to make binary installers on macOS / Darwin much easier to create and maintain. Some further developments I would like:
All of these should probably happen in their own pull request later on, perhaps except the docs on. how we want this to evolve. |
|
@afh I would like to add something like this to make it easier to debug why a build is failing: diff --git a/pkgs/os-specific/darwin/install-binary-package/default.nix b/pkgs/os-specific/darwin/install-binary-package/default.nix
index d1c9b2a8f238..339a464187ec 100644
--- a/pkgs/os-specific/darwin/install-binary-package/default.nix
+++ b/pkgs/os-specific/darwin/install-binary-package/default.nix
@@ -43,6 +43,14 @@ stdenvNoCC.mkDerivation (
runHook preInstall
mkdir -p $out/Applications
+
+ if [ ! -d "${appName}" ]; then
+ echo "ERROR: Application '${appName}' not found in the current directory"
+ echo "Contents of the current directory:"
+ find .
+ exit 1
+ fi
+
cp -R "${appName}" $out/Applications
runHook postInstallWhat do you think, is that too un nix like to spit out so much information on a build failure? |
|
At first glance this feels more suitable for the checkPhase and either if What do you think? |
Both sounds great. Just a bit of output to get an orientation what's going on and why it is failing. |
1c87ea9 to
c8aaa30
Compare
|
@afh and me had a bit of a conversation thinking about wether an alternative approach would be to provide |
that would be really good, however, how do we deal with maintaining notarization though? as fixup can break many packages |
9591326 to
8eecaf5
Compare
|
@auscyber I just had a talk with @afh and the preliminary conclusion is, that we probably want both, fetchers and install |
8eecaf5 to
7a473d3
Compare
Description of changes
ℹ️ In order to tackle this work @dwt and I decided to split the work between this PR introducing the
darwin.installBinaryPackagefunction and packages making use of it, see #440894darwin.installBinaryPackageunifying and simplifying how binary darwin applications are installed.darwin.installBinaryPackagepre- andpost-hooks are runNOTA BENE: This is a draft PR to get the conversation going on whether this is headed into the right direction and folks see this as beneficial and helpful.
💭 A Few Thoughts
../os-specific/darwin/packages declared inpkgs/top-level/all-packages.nixdo folks agree that these are better declared inpkgs/top-level/darwin-packages.nix?os-specific/darwinpackages fromall-packages.nixtodarwin-packages.nixif the general sentiment is positive on the previous question.grep os-specific/darwin pkgs/top-level/all-packages.nix | awk -F'[=]' '/ *#/{next} {print $1}'undmgor_7zzas theirnativeBuildInputto unpack a prebuilt darwin binary, if this PR is generally viewed positively.nix run nixpkgs#silver-searcher -- -G '\.nix' -l '(undmg|_7zz)' | rev | cut -d/ -f2 | revdarwin.installBinaryPackageand learn about its details?pkgs/os-specific/install-binary-package/*ℹ️ All
treewide: refactor to use darwin.installBinaryPackage*commits will be squashed into one. For now it's easier for me to work on this with individual commits.Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.