Skip to content

undmg-hdiutil: init#416666

Draft
Prince213 wants to merge 6 commits intoNixOS:masterfrom
Prince213:push-wrkmvnnzqxoo
Draft

undmg-hdiutil: init#416666
Prince213 wants to merge 6 commits intoNixOS:masterfrom
Prince213:push-wrkmvnnzqxoo

Conversation

@Prince213
Copy link
Member

@Prince213 Prince213 commented Jun 14, 2025

undmg doesn't support extracting .dmg files using APFS, so we need hdiutil to extract.

Upstream issue: matthewbauer/undmg#4

Implementation is adapted from

unpackCmd = ''
echo "Creating temp directory"
mnt=$(TMPDIR=/tmp mktemp -d -t nix-XXXXXXXXXX)
function finish {
echo "Ejecting temp directory"
/usr/bin/hdiutil detach $mnt -force
rm -rf $mnt
}
# Detach volume when receiving SIG "0"
trap finish EXIT
# Mount DMG file
echo "Mounting DMG file into \"$mnt\""
/usr/bin/hdiutil attach -nobrowse -mountpoint $mnt $curSrc
# Copy content to local dir for later use
echo 'Copying extracted content into "sourceRoot"'
cp -a $mnt/Insomnia.app $PWD/
'';

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other contributing documentation in corresponding paths.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Jun 14, 2025
@Prince213 Prince213 marked this pull request as ready for review June 14, 2025 11:49
@nix-owners nix-owners bot requested a review from stepbrobd June 14, 2025 11:54
@github-actions github-actions bot removed the 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. label Jun 14, 2025
@nix-owners nix-owners bot requested review from DataHearth and emilytrau June 14, 2025 11:54
@Prince213 Prince213 mentioned this pull request Jun 14, 2025
13 tasks
@Prince213 Prince213 added 0.kind: enhancement Add something new or improve an existing system. 8.has: package (new) This PR adds a new package 8.has: clean-up This PR removes packages or removes other cruft 6.topic: darwin Running or building packages on Darwin labels Jun 14, 2025
@wegank
Copy link
Member

wegank commented Jun 14, 2025

I guess I'm not endorsing this, as calling /usr/bin/hdiutil during the build seems much worse than using 7zz ...

# LM Studio ships Scripts inside the App Bundle, which may be messed up by standard fixups
dontFixup = true;

# undmg doesn't support APFS and 7zz does break the xattr. Took that approach from https://github.com/NixOS/nixpkgs/blob/a3c6ed7ad2649c1a55ffd94f7747e3176053b833/pkgs/by-name/in/insomnia/package.nix#L52
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wegank We should probably avoid 7zz because of this. Also we can't cross compile to darwin anyway so this shouldn't make things worse.

Copy link
Contributor

@reckenrode reckenrode Jun 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross-compiling to Darwin is a stretch goal for 25.11 (see #405893). What is the issue with xattrs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @Prince213 meant #372738 (comment), although that doesn't really justify switching to hdiutil in airbuddy, aldente, or wechat in #416709.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait a sec, it seems that lmstudio does work with _7zz on my machine?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @Prince213 meant #372738 (comment), although that doesn't really justify switching to hdiutil in airbuddy, aldente, or wechat in #416709.

Yes I'm worried about the xattrs issue.

I think it may be better if we have this in fetchzip as nativeBuildInputs.
If we allow networking for FODs it should also be okay to allow relaxed sandbox.

What do you think @reckenrode and @wegank?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But with fetchurl I would probably call /usr/bin/hdiutil in a normal derivation, I guess?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't feel right. It's not really part of the build process, just part of the unpackPhase.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Nix store does not support xattrs so I don't think workarounds to keep them are a good idea. They will fundamentally break in cached NARs etc. That would need fixing on the Nix end.

Copy link
Contributor

@reckenrode reckenrode Jun 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think @reckenrode and @wegank?

As @emilazy notes, the store doesn’t support xattrs. While a local build may be able to preserve them, a cached download from Hydra won’t have them.

The problem here is upstream apparently signed everything in their app bundle, including non-binaries. macOS supports that; the signatures are stored in xattrs. Unfortunately, the store doesn’t support xattrs. 🫤

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wegank wegank mentioned this pull request Jun 14, 2025
13 tasks
@Prince213 Prince213 marked this pull request as draft June 15, 2025 06:54
@nixpkgs-ci nixpkgs-ci bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.kind: enhancement Add something new or improve an existing system. 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: darwin Running or building packages on Darwin 8.has: clean-up This PR removes packages or removes other cruft 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants