35 ms·
I switched my primary dev environment to NixOS in a graphical VM on macOS towards the end of 2020 and I love it: https://twitter.com/mitchellh/status/1346136404
by mitchellh 5y ago
I switched my primary dev environment to NixOS in a graphical VM on macOS towards the end of 2020 and I love it: https://twitter.com/mitchellh/status/1346136404682625024?s=21 https://twitter.com/mitchellh/status/1346136404682625024?s=2...
Previously, I used Nix on Mac (as this blog post suggests) but I had enough “gotchas” with Nix on Mac that I decided to go full NixOS.
For those who ask why a VM or why I keep Mac around at all: I like macOS for everything else besides dev work. I use iMessages heavily, I like the Mac App ecosystem such as calendars, mail clients, etc. This gives me the best of both worlds.
I usually run this on an iMac Pro but also have a MacBook Pro. It runs great on either. It’s also really nice with Nix to update one machine and the other is just one command away from being equivalent.
I recognize this is a “weird” setup but wanted to point it out since it seems relevant to this post.
- cyberpunk 5y agoWhat hypervisor/vm software are you using? I’m running some Linux vms under parallels on a m1 and the graphics performance could be better..
- Gaelan 5y agoLooks like VMWare from the tweet they linked.
- mitchellh 5y agoVMware Fusion. I don’t use an M1 Mac right now (I have one for testing but not primary dev work).
- reddit_clone 5y ago> VMware Fusion Does it work? When I upgraded to BigSur and Fusion 12 the networking just stopped working. VMs dont work with NAT at all. In Bridged mode, it partially works. Completely stops if I get the Mac host in to company VPN. All of this used to work prior version of Mac OSX and Fusion 11.
- mitchellh 5y agoWorks for me. Note that networking changed a ton in Big Sur because Apple doesn't allow kernel extensions anymore (or, its too user hostile for vendors to do it). The VMware networking stack switched completely to HyperVisor.framework's networking stuff, which doesn't support a bunch of "advanced" features. I only use it for a hostonly network + NAT and this works fine.
- saagarjha 5y agoKernel extension are still allowed on Big Sur (and Monterey).
- ulzeraj 5y ago> I’m running some Linux vms under parallels on a m1 and the graphics performance could be better. Not GP but I'm using UTM, which is Qemu based. I need Windows to connect to my work so I've setup an ARM Windows 10 VM. Graphic performance is indeed terrible but I've found out that RDP works just fine with whatever resolution your physical computer supports.
- smoldesu 5y agoI envy your patience. I had to drop MacOS altogether out of frustration that there were no good package managers, and VMs simply don't cut it for me. Nowadays, I run an inverse setup: I do pretty much everything in Arch, with a few Wine prefixes to solve Windows compatibility, and a healthy combination of Darling and QEMU to spin up MacOS instances.
- Svetlitski 5y agoGenuinely curious, what didn’t you like Homebrew (assuming you tried it)?
- heavyset_go 5y agoAnother HN user did a write up on Homebrew[1] that I agree with. My main gripe is that Homebrew would regularly break my Python virtualenvs with linking errors. Meanwhile on Linux, I have virtualenvs that I created 9 years ago that still just work. These days you might be able to sidestep that issue by not using Python from Homebrew at all, but installing and managing it with Pyenv instead. [1] https://saagarjha.com/blog/2019/04/26/thoughts-on-macos-package-managers/#to-sudo-or-not-to-sudo https://saagarjha.com/blog/2019/04/26/thoughts-on-macos-pack...
- Groxx 5y ago`brew pin python` and it'll stop that from happening. but yeah, this is a constant source of pain, and I end up helping people at work fix it probably on a weekly basis (or more often). python bin-envs are such a hassle.
- heavyset_go 5y agoI need to run the latest Python versions, including alphas and betas, though, and have everything just work even if the system and local Python versions change under me. Pinning Python would make it difficult to contribute to CPython, or make sure my libraries work with new Python alpha/beta releases before stable versions are released. Virtualenvs based on Pyenv's local Python installs on Linux works well, and virtualenvs that were based on old system Python versions still work even when I upgrade the system Python. This is where I'd get linking errors with Homebrew that I don't get with Linux.
- heavyset_go 5y agoI run the opposite of this, and run Linux with Nix on a Mac, and run macOS in VM with VFIO passthrough for macOS development. I've found that native Linux makes for an excellent dev environment.
- philsnow 5y agoYou're running linux (with nix installed) on the bare metal of a mac, and then a VM on top of that running macos (with VFIO passthrough so it's not dog-slow?), is that right? Performance is pretty reasonable? APFS works fine in this setup? No gotchas with drive encryption? ... actually, if your machine does use drive encryption, which is doing it, linux or mac? I don't know enough about mac hardware to know if there is some mac boot environment that handles encryption and then hands off to the OS (be it macos or linux).
- heavyset_go 5y ago> You're running linux (with nix installed) on the bare metal of a mac, and then a VM on top of that running macos (with VFIO passthrough so it's not dog-slow?), is that right? You got it. > Performance is pretty reasonable? APFS works fine in this setup? Works well enough for my use cases. It's certainly less slow and fragile than running Linux in a VM via macOS. APFS works fine in the VM, but I use HFS+ just because there are more mature tools to poke at HFS+ images than APFS, right now. The APFS FUSE drivers work well and support reading and writing[1]. There's a closed source driver that supports writing and encryption, though[2]. > No gotchas with drive encryption? ... actually, if your machine does use drive encryption, which is doing it, linux or mac? I don't know enough about mac hardware to know if there is some mac boot environment that handles encryption and then hands off to the OS (be it macos or linux). I don't use T2 disk encryption, I just let Linux handle partition encryption. Apparently there's support here[3] for it, though. [1] https://github.com/sgan81/apfs-fuse https://github.com/sgan81/apfs-fuse [2] https://www.paragon-software.com/us/business/apfs-linux/ https://www.paragon-software.com/us/business/apfs-linux/ [3] https://wiki.t2linux.org/ https://wiki.t2linux.org/
- sureglymop 5y agoI've had a vfio setup for a year now, passing various hardware to Windows and Linux VMs but finally I just converted it to a regular dual boot setup. I figured since I am passing through all this hardware anyway it might as well all directly access it. Now with SR-IOV that would be an entirely different story.
- numbsafari 5y agoIt's really not weird at all, IMHO. If you look at ChromeOS, it's actually relatively mainstream. Most of us need a locked down desktop environment more than we realize. The UNIX/POSIX shell environment works really well for our specific kind of work (writing software), but it's full of security holes and gotchas. A lot of people talk about Apple as wanting to "own" everything, but the trend in securing consumer OS environments is clearly trending in this direction. Starting with research examples like Qubes, and all the mainstream security efforts in Windows, and ChromeOS. Working with a VM that you can torch and rebuild is ultimately the best of both worlds. What would be really cool is a Mac OS app for managing Vagrant... Basically a competitor for Docker Desktop for Mac that used VMs instead of Docker.
- circularfoyers 5y agoFedora Silverblue is potentially where the future of the Linux desktop might end up. It improves on security significantly, where the system is read only, similar to macOS, and all user programs are sandboxed within flatpaks (migrated from the preexisting RPMs of these programs).
- jcastro 5y agoHave you been able to get nix working in silverblue? The read-only fs makes making a `/nix` not very straightforward.
- jamesgeck0 5y agoYou’ll probably want to install it in a Toolbox [1] container. This is the recommended way to set up development tools; you’ll generally want as little as possible layered on the OSTree file system. 1. https://github.com/containers/toolbox https://github.com/containers/toolbox
- jamesgeck0 5y agoopenSUSE MicroOS Desktop is another distribution exploring this space. It’s a neat idea, but the SUSE folks are still working out a lot of quirks (the firewall had to be disabled in recent builds, for example). How mature is Silverblue? Can it be used as a daily driver with minimal fuss?
- fnord123 5y ago> I like the Mac App ecosystem such as calendars Does Calendar actually work for you?
- borski 5y agoYes, it’s fine. I’ve since moved to fantastical but the stock calendar app was fine.
- DenverCode 5y agoI use the stock app and it have not had any issues as well.
- sigjuice 5y agoDoes copy/paste work between the host and the VM?
- mitchellh 5y agoYes (via VMware Tools)
- gigatexal 5y agoI tried a graphical VM on my Mac but it was too slow. How are you getting around that?
- rphln 5y agoOut of curiosity, have you experimented with accessing the VM through SSH? If so, what was it like? I could see myself using a similar setup down the line, but having two graphical environments seems like it'd be somewhat distracting or fussy.
- mikepurvis 5y agoI do a similar setup to this on Windows (WSL) and previously on a Mac (Parallels + Ubuntu). In both cases it's exclusively SSH access using an outer-system terminal, and as far as editors, a mix of screen/vim/whatever in the terminal, and VSCode with remote editing.
- suction 5y agoWould it be possible as an alternative to remote editing to use the VM's "Shared folder" functionality? Running an heavy IDE like IntelliJ inside a VM when you could also run it in the outer OS seems like stretching this setup beyond what is meant for.
- LinXitoW 5y agoWhen I tried something like this, write heavy activities were pretty slow. Extreme example was running something like "npm install" (write many small files) on the host. That took about 10x time compared to doing it in WSL. I've had similar slow performance with shared folders in things like Vagrant. Disclaimer: I did this 2-ish years ago, it may have changed by now.
- mekster 5y agoWhy run npm on the wrong OS? It can easily break building a binary for a wrong platform.
- mikepurvis 5y agoNot sure exactly what the situation was here, but if it was an NTFS folder from Windows shared into the VM/WSL, then you are indeed running the npm operation in the inner system but paying the cost of writing thousands of tiny files across that translation layer.
- rubiquity 5y agoI went down this route as well and am the happiest I've been when it comes to managing dependencies and creating builds. I ended up taking it one step further because Apple kept breaking my hypervisor (xhyve) with every new macOS release. I built a new workstation that runs NixOS and wayland/sway. I still have my MacBook Pro for when I need macOS comforts or if I don't feel like being at my desk I can just SSH into the workstation.
- res0nat0r 5y agoAnother cool thing is you can copy an entire nix closure to another host if you want to replicate it exactly somewhere else. https://nixos.org/manual/nix/unstable/command-ref/nix-copy-closure.html https://nixos.org/manual/nix/unstable/command-ref/nix-copy-c...
- Scarbutt 5y agoYour setup is normal, the weird part is running a GUI in the linux VM. Simpler, why not just use ssh? (since you are vim user and all)
- exdsq 5y agoI think it's becoming more common. I do the same with a Pixelbook as my main computer nowadays!
- Tempest1981 5y agoDo you run git in the VM too? Or on macOS?
- subsection1h 5y agoI love how your reply (which mentions that you use NixOS) is at the top because it indirectly confirms my experience with Nix. I tried Nix on Debian only a couple of weeks ago, and the main issue I had with Nix was that whenever I searched for an answer or other info relating to Nix, most of what I found was written by users of NixOS, not standalone Nix. It seemed that the overwhelming majority of people sharing info about Nix are users of NixOS. For example, notice how there are 4-5 times as many results when searching the web for "configuration.nix" (which is used with NixOS) than there are when searching for "config.nix" (which is used with standalone Nix): https://www.google.com/search?q=%22configuration.nix%22 https://www.google.com/search?q=%22configuration.nix%22 https://www.google.com/search?q=%22config.nix%22 https://www.google.com/search?q=%22config.nix%22 I got bored of wading through irrelevant search results, so I uninstalled Nix. (My experience with Guix was even worse, but in a different way.) When I want software that isn't in Debian's repos, I'll stick to installing it from source like I've been doing forever.
- takeda 5y agoYes, the name is unfortunate. I search things by looking for nixpkgs. The nix on its own isn't really that complex, it is really the nixpkgs that is built on top of it and then NixOS that is built on top of nixpkgs.
- jonringer117 5y agoOutside of configuring your system, almost everything from NixOS is applicable to other distro's. The only notable exception I can think of are video drivers, and you will need nixGL for that. Otherwise, I would recommend looking at home-manager, it's essentially NixOS but for any linux distro, or even darwin with nix-darwin. https://github.com/nix-community/home-manager https://github.com/nix-community/home-manager
- aaronchall 5y agoI used nix on Ubuntu as my daily driver for nearly a year before installing Nixos. I also installed it on a server and multiple desktops before that. My main pain point with nix on Ubuntu was gui stuff didn't work. But as a build tool it worked amazingly well. Using nix as an ad hoc package manager worked for non GUI stuff, though, but that wasn't all that interesting. Except it let me have the latest Python and haskell and so forth...
- IggleSniggle 5y agoShare your nix setup/config? Your workflow looks like it matches my desires exactly
- bjcy 5y agoHe included a link to this gist on one of the Twitter replies: https://gist.github.com/mitchellh/8aa0b76d42e6f6f12ffe34914e7efe4d https://gist.github.com/mitchellh/8aa0b76d42e6f6f12ffe34914e...
- pkulak 5y agoI did that for about a year. It's a gateway drug. You'll be running a Thinkpad shortly. ;)
- MuffinFlavored 5y ago> in a graphical VM qemu? VirtualBox? VMWare? Parallels?
- takeda 5y agoFrom the video he is showing in his tweet[1] it's VMWare Fusion, but NixOS should work on all of these. [1] https://twitter.com/mitchellh/status/1346141887996915712 https://twitter.com/mitchellh/status/1346141887996915712
- MuffinFlavored 5y ago> We don’t plan to support installing or running x86 VMs on Macs with Apple silicon. https://blogs.vmware.com/teamfusion/2021/04/fusion-on-apple-silicon-progress-update.html https://blogs.vmware.com/teamfusion/2021/04/fusion-on-apple-... Interesting.
- takeda 5y agoFor what is worth, NixOS seem to also come in aarch64 flavor.
- suction 5y agoDo with Docker available for ARM architecture, that means it will work with no emulation layer needed. Or am I missing something?
- heavyset_go 5y agoLinux still needs to run in VMs to use Docker on a Mac.
- deleted 5y ago[deleted]
- fouc 5y agoThere are definitely times when I think about just running linux in a VM and using that as my primary dev environment. I did that before when I was briefly forced to use a PC laptop for a couple of months, and it worked great. Also homebrew has so many drawbacks that I'm increasingly planning on boycotting it fully.
- ramesh31 5y agoIf you're running a full VM, why not just use debian images?
- elbear 5y agoI assume it's because they want to take advantage of Nix at the OS level, which you can only do through NixOS.
- kohlerm 5y agoNot that weird of a setup. A few years ago I was responsible for dev environments for >500 developers. I wasn't aware of Nix at that point in time, so we provided prebuilt Linux VMs for local and remote use,which we would update with Chef scripts. In the meantime I also use Nix for setting things up for my personal dev environment. Currently trying to use WSL2, not sure yet whether that is really better than a VM. I can recommend using the nix Home-Manager for combined dot file management and tools installation. With direnv and nix you can set it up such that when you enter a directory you get the exact version of the tools you want for that project. Being able to easily manage different versions of the same package easily is IMHO the killer feature of Nix.
- kohlerm 5y agoI forgot. ATM I use Ubuntu with the nix package manager, not Nix OS. The reason being that in case a package is not available on Nix, or is not working out if the box. I found for example that Visual Studio remote support does not work out of the box on Nix OS.
- stjohnswarts 5y agomac is extremely common in the developer world I don't know why you would think that it's "weird"
- arvinsim 5y agoI know that WSL2 is a good development environment for Windows but I am interested to see if a Nix VM might be better.
- Wintereise 5y agoProbably unlikely. The only way it might be better (for now) is if you need to use something that uses the GUI. But with native x forwarding coming soon to WSL2, you'll get the same experience soon enough (given that WSL2 is a separate VM running in Hyper-V already).
- NaN1352 5y agoI used to work like this with virtualbox Ubuntu on Windows host for front end dev. It worked great. Even had a AHK script that makes the vm fullscreen borderless, bar the win 10 taskbar below, clean and super usable. The issue is I got an M1 mini mac for development, and I’d rather have the superior fonts and gui of Sublime, MacVim, etc. Granted they look pretty good already on Ubuntu. I feel like Docker container is the middle way here, you can keep the host clean from complex installs, and you can use evetything on the host to edit your code, since it’s so easy to map folders with Docker. I don’t really see a downside, although it is super convenient as well with a graphical vm, that you can archive and backup your entire vm, along with all your os preferences, editor settings, terminal settings etc. edit: I guess I could also use Macvim etc. on the host with shared folders but those shared folders are slower and have all kind of permission issues afaik, I think Docker mapped folders work better. Last time I heard Docker on Mac uses virtualization under the hood so it’s about the same as virtualbox (unlike os supported "containers" on linux host), but I don’t know if that is still true for M1?
- heavyset_go 5y ago> Last time I heard Docker on Mac uses virtualization under the hood so it’s about the same as virtualbox (unlike os supported "containers" on linux host), but I don’t know if that is still true for M1? Docker runs Linux in VMs on Intel and M1 Macs.