Skip to content

/nix will not be writable on macOS Catalina #2925

Description

@mroi

This is not a short term bug, but it will become an issue when macOS Catalina is released this fall. macOS is now split across two volumes (system and data) with a read-only system volume. This means that /nix will no longer be writable.

Some more information can be found in the related WWDC talk and some session notes people took from a Q&A.

Summary: the system volume, which is mounted at / will become non-writable. Some directories that need to be writable are connected via firmlinks (an Apple invention) to the data volume. /nix is not among these locations, so with the release of macOS Catalina, this location is no longer an option.

I see two possible solutions:

  1. I could try and file a bug to convince Apple to pre-install /nix as a firmlink to a writable location. I think this has limited success and Nix would then depend on Apple to not drop this link in a future release.
  2. We could move Nix on macOS to a different default location. Possible locations are those that Apple chooses to pre-install as links to writable locations. Two examples are /usr/local and /opt, so we could move to /usr/local/nix or /opt/nix. I would hope that these locations are common enough so that Apple would not drop them in the future.

I wanted to raise this issue early, before it becomes a problem for users. If this issue tracker is not the right place, please feel free to move this discussion elsewhere. I would also be available for testing any potential solution, since I have access to a macOS Catalina beta.

Activity

  1. edolstra commented on Jun 6, 2019

    @edolstra
    Member

    Realistically, this may force us to drop support for macOS. Using a different store location for macOS would require a separate binary cache and a separate Hydra instance, and there would be no guarantee that the new location wouldn't break in the future.

    I did notice in the talk that it's still possible to make the system volume writable, though not in a persistent way.

  2. mroi commented on Jun 6, 2019

    @mroi
    Author

    Speaking for myself: I would be quite sad if macOS support would go away.
    I will file a bug with Apple and see what happens. Cannot hurt.

    Yes, you can jump through hoops and get a writable system volume, but only until the next reboot, so this is not a useful option.

  3. jwiegley commented on Jun 6, 2019

    @jwiegley

    @edolstra Before canceling support, we can ask the community if it's willing to host its own binary cache and Hydra instance, just as we've enlisted a host of volunteers to keep nixpkgs at near parity on Darwin. Having the answer be, "This doesn't easily fit our model so we won't support Mac" would be an unfortunate response.

  4. mroi commented on Jun 6, 2019

    @mroi
    Author

    I think no such decision should be made lightly, but it is definitely a drastic change on Apple’s part.

  5. edolstra commented on Jun 6, 2019

    @edolstra
    Member

    Yes, you can jump through hoops and get a writable system volume, but only until the next reboot, so this is not a useful option.

    Maybe you can use this to create a /nix symlink to another volume, which would hopefully persist across reboots?

  6. mroi commented on Jun 6, 2019

    @mroi
    Author

    That was my first try to get it temporarily working again. But nix-env complains then:

    error: cannot open connection to remote store 'daemon': the path '/nix' is a symlink; this is not allowed for the Nix store and its parent directories

    If that error can be safely ignored, I think this would be a workaround worth exploring. The way I understand things, anything you place in the root folder would persist until the next system update.

  7. LnL7 commented on Jun 6, 2019

    @LnL7
    Member

    There's no real reason for the nix store to be on the system volume, with apfs it's easy to create a separate volume and mount it to /nix. But perhaps there's something I'm missing because I don't understand the need for these firmlinks, the equivalent is possible with mounts similar to how the store is mounted readonly on NixOS.

  8. edolstra commented on Jun 6, 2019

    @edolstra
    Member

    @mroi You can set NIX_IGNORE_SYMLINK_STORE=1 to disable that check. (This should probably be turned into a nix.conf option.)

  9. jwiegley commented on Jun 6, 2019

    @jwiegley

    @edolstra Great idea, added #2926.

  10. mroi commented on Jun 6, 2019

    @mroi
    Author

    @edolstra Thanks for the tip, this is a useful workaround.

    But future Nix-users on macOS still need to find a reliable way to inject this symlink into the read-only root directory. This probably involves some advanced steps like rebooting into recovery mode after every system upgrade.

    @LnL7 The same would be true for /nix as a mount point, because we would need to create this directory on the read-only volume.

  11. LnL7 commented on Jun 6, 2019

    @LnL7
    Member

    Sure but if Apple doesn't want to provide some sort of solution for one of these cases there will be no alternative to changing the default prefix. Which is arguably is not worth it for a secondary platform that's continuously moving further away from UNIX.

    Is there an overview of the full volume layout somewhere? /usr/local and /Users are used as examples but I can't imagine that's everything.

  12. kevingriffin commented on Jun 7, 2019

    @kevingriffin

    @mroi How have you been testing this? In my testing, I was able to install nix, but I assumed it was due to the comment in the presentation that "system volume is writeable in the developer preview". I'd also like to help test, but was able to get nix installed:

    kevingriffin@KevinnoiMac /nix % uname -a
    Darwin KevinnoiMac.local 19.0.0 Darwin Kernel Version 19.0.0: Fri May 24 17:36:10 PDT 2019; root:xnu-6041.0.0.111.5~1/RELEASE_X86_64 x86_64
    kevingriffin@KevinnoiMac /nix % ls /nix
    store	var
    kevingriffin@KevinnoiMac /nix % nix-env -iA nixpkgs.hello
    installing 'hello-2.10'
    these paths will be fetched (0.02 MiB download, 0.07 MiB unpacked):
      /nix/store/c4w9z1kzzkdsgvgr6cy9ggl39s2yzn70-hello-2.10
    copying path '/nix/store/c4w9z1kzzkdsgvgr6cy9ggl39s2yzn70-hello-2.10' from 'https://cache.nixos.org'...
    building '/nix/store/iwcsfsh5hxyzpymnkp1r54nb3zzpd7mg-user-environment.drv'...
    created 2 symlinks in user environment```
    
  13. matthewbauer commented on Jun 7, 2019

    @matthewbauer
    Member

    It looks like you can still access the /nix directory after the update, it's just in /System/Volumes/Data/nix. Too bad there's no chroot equivalent on macOS.

  14. matthewbauer commented on Jun 7, 2019

    @matthewbauer
    Member

    sudo mount -uw / && sudo ln -s /System/Volumes/Data/nix /nix works for me! This is on SIP even! Having the installer handle this might work.

  15. 323 remaining items

  16. wmertens commented on May 8, 2020

    @wmertens
    Contributor

    @samuela macOS does not allow simply creating /nix. So that needs to be configured in some way, not really a "hack".

    The easiest way to have Nix on macOS would be if Nix used /opt/nix or /usr/local/nix instead of /nix.

  17. samuela commented on May 8, 2020

    @samuela
    Member

    So what is the problem with /opt/nix or /usr/local/nix/ instead of /nix? This seems like a real showstopper bug...

  18. wmertens commented on May 8, 2020

    @wmertens
    Contributor

    @samuela it means either doubling the storage for Hydra, or changing ALL the Nix installs everywhere.

    One hacky option is to rewrite store paths as they get downloaded. So any mention of /nix/store/...name would be rewritten in the file to /opt/nix/...(name-4chars). This would work for most of the files, but still needs support in nix-store and all over nixpkgs where /nix is hardcoded

  19. alper commented on May 8, 2020

    @alper

    @wmertens How much storage would get doubled?

  20. wmertens commented on May 8, 2020

    @wmertens
    Contributor

    @alper any package that Hydra produces would have to be produced twice, once for /nix and once for /opt/nix.

    It's not quite a doubling, because not all packages are built for Darwin and files that don't reference store paths would likely be the same and can be hardlinked.

    I don't know how big the Hydra storage is.

  21. samuela commented on May 8, 2020

    @samuela
    Member

    Seeing as this issue has been open since 2019, it seems as though macOS is no longer a supported platform. Is that true? Or is there a roadmap to fixing this?

  22. alper commented on May 8, 2020

    @alper

    Because shouldn’t storage be a non-issue at this point in history?

  23. grahamc commented on May 8, 2020

    @grahamc
    Member

    I'm going to lock this until we're able to get a fix out. Thanks for everybody's contributions and help in figuring out this problem, hopefully it is soon.

  24. locked as too heated and limited conversation to collaborators on May 8, 2020
  25. edolstra commented on May 8, 2020

    @edolstra
    Member

    @wmertens We wouldn't need to produce packages twice, since we'd have one Hydra instance (and binary cache) for macOS (using the /opt prefix) and another instance for all other platforms.

    The main consequence of using a separate prefix for macOS is that you can't have Hydra jobsets anymore containing jobs for macOS and Linux. It would also make it harder to deploy from macOS to Linux.

  26. pinned this issue on May 19, 2020
  27. domenkozar commented on May 26, 2020

    @domenkozar
    Member

    Documentation for installation of Nix on Catalina is available.

    Note that until Nix 2.3.5 release is out, the instructions won't work. PR

  28. domenkozar commented on May 27, 2020

    @domenkozar
    Member

    Nix 2.3.5 has been released with Catalina fix!

  29. unpinned this issue on May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    installermacosNix on macOS, aka OS X, aka darwin

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions