darwin.installApplication + unpkg + unxar: init#147567
darwin.installApplication + unpkg + unxar: init#147567spease wants to merge 3 commits intoNixOS:masterfrom
Conversation
c835d68 to
0a8c91e
Compare
| xar --dump-header -f "${curSrc}" | grep -q "^magic:\s\+[0-9a-z]\+\s\+(OK)$" | ||
| [ $? -ne 0 ] && return 1 |
There was a problem hiding this comment.
Shouldn't set -e be set in the stdenv and this cleanly fail?
| xar --dump-header -f "${curSrc}" | grep -q "^magic:\s\+[0-9a-z]\+\s\+(OK)$" | |
| [ $? -ne 0 ] && return 1 | |
| xar --dump-header -f "${curSrc}" | grep -q "^magic:\s\+[0-9a-z]\+\s\+(OK)$" | |
| ret=$? | |
| [ $ret -ne 0 ] && return $ret |
I think we should preserve the exit code.
|
|
||
| installPhase = '' | ||
| mkdir -p $out/bin | ||
| ln -s $(command -v xar) $out/bin/xar |
There was a problem hiding this comment.
| ln -s $(command -v xar) $out/bin/xar | |
| ln -s ${xar}/bin/xar $out/bin/xar |
| dir="$(mktemp -d)" | ||
| xar -xf "${curSrc}" -C "${dir}" | ||
| zcat ${dir}/*/Payload | cpio -idm --no-absolute-filenames | ||
| rm -rf --preserve-root "${dir}" |
There was a problem hiding this comment.
| rm -rf --preserve-root "${dir}" | |
| rm -rf "$dir" |
This should be the default and also mktemp should never output /.
|
|
||
| installPhase = '' | ||
| mkdir -p $out/bin | ||
| ln -s $(command -v xar) $out/bin/xar |
There was a problem hiding this comment.
| ln -s $(command -v xar) $out/bin/xar | |
| ln -s ${xar}/bin/xar $out/bin/xar |
| description = description; | ||
| homepage = homepage; | ||
| license = licenses."${license}"; | ||
| maintainers = forEach maintainers (x: maintainers."${maintainer}"); |
There was a problem hiding this comment.
This is not how this is normally done. Normally meta is just inherited as is or the inputs override some defaults.
| phases = [ "unpackPhase" "installPhase" ]; | ||
|
|
There was a problem hiding this comment.
| phases = [ "unpackPhase" "installPhase" ]; |
Please disable unwanted phases with dontBuild = true;.
| app=( ./*.app ) | ||
| if [ ! -z "$app" ]; then | ||
| mkdir -p $out/Applications | ||
| mv -n "$app" $out/Applications/ |
There was a problem hiding this comment.
If I read this bash correctly, then app=( ./*.app ) creates an array of all application bundles, while mv -n "$app" $out/Applications/ will move just the first one over to $out/Applications
Motivation for this change
Greatly improve ease-of-use for developing nix derivations on macOS, particularly with regards to desktop applications packaged in the typical conventions expected for non-store installation. This is intended to be an "easy path" that's as simple and minimal as possible - if someone wants to get fancy and deal with a nonstandard or more complex application, that is outside the scope of this.
This is intended to get used by as many packages as possible to rapidly increase the number of native macOS applications available under nix, perhaps even by nix newbies, so please be as critical as possible. Once merged, the interface and behavior should remain as static as possible, as later changes could require multiple packages to be refactored.
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notesExample of usage