nix-darwin
nix-darwin copied to clipboard
Something like homebrew's "cask"
I've mostly moved from Homebrew to nix. So far, so good. I'm missing the ability to install casks, though, for important stuff like Anki, MacTex, and so forth. It seems like these should be some pretty easy expressions to write.
Is this a good channel for them? What should they be called? Where should they go?
nixpkgs is the correct place
All that needs to be done is to place any *.app in $out/Applications as part of the install – a few packages like musecore, terminal-notifier, and sequelpro already do. nix-env links the contents into your ~/.nix-profile/Applications.
One example to play around with is Sequel pro (nox sequel to install), which should show up in spotlight after installation.
Maybe NIXUP can aid with linking them into ~/Applications for discovery in the future
Packages like emacs are actually already linked to ~/Applications when added to systemPackages. I don't know how much work it would be to package things like that with nix. But casks are generally pretty impure making them hard to package.
How would one handle an app that updates itself, thus breaking purity?
If the author of an app decides to self-update it at all cost, even breaking users, we are at no luck. But, as far as I know, the vast majority of apps can disable self-update. In reality, it is still possible to move forward with many apps.
Closing this as DMGs (what casks are under the hood) can be added as packages to nixpkgs and installed by adding them to environment.systemPackages. Alternatively, if you actually need Homebrew Casks, we have a homebrew module you can use
@Enzime Do you have an example showing how DMGs are added as system packages?
@franckrasolo The DMGs end up being packaged as normal Nix packages, take a look at IINA's derivation for example: https://github.com/NixOS/nixpkgs/blob/7e281993bbc6f09832c2018b3838fc4da14b32d6/pkgs/applications/video/iina/default.nix#L4
Here's more examples: https://github.com/search?utf8=%E2%9C%93&q=path%3A*.nix%20repo%3ANixOS%2Fnixpkgs%20undmg&type=Code
@Enzime Thanks for sharing! It's good to know how it's done.
Alas the majority of the Homebrew casks I use aren't in nixpkgs, so I'll stick to the homebrew module for the time being.
It might be interesting to see a separate repository where people worked on packaging Mac apps for Nix. That said, I generally feel that the Nix model doesn't provide too many advantages with the compromises you need to make for macOS (e.g. symlinking apps rather than copying them causes all kinds of issues, and when there is any kind of packaging complexity it's usually imperative (un)installation steps rather than anything Nix particularly helps with). So I personally just use the Homebrew module exclusively for GUI casks (ok, a couple binary-packaged CLI tools too) and would generally recommend that to others.