Reproducible within Immutable (RWI) <-- Wow, wow, wow - The Hashimoto Way

Folks,
I just wanted to share my experience of the weekend installing NixOS inside Bluefin-DX.

Yesterday I was exploring what was all fuzz about Nix and NixOS. Initially very difficult to understand and digest because almost nobody share practical use cases. Browsing after browsing I finally landed on a page in reddit with a link to an interview to Mitchell Hashimoto. And he is simply b.r.i.l.l.i.a.n.t. He has found a way to create a reproducible development environment by nesting NixOS within a macOS laptop. Link here. NixOS is installed as a VM with Fusion.

He showed a gist of his development workflow and truly is impressively reproducible. He did something on the screen that I couldn’t believe it was possible doing: installing a package, application, or binary is really defined down to the core of the operating system. He had a single file where he defined low level stuff like booting, disk options, desktop manager, audio, etc.; as well what applications will be installed for you ideal OS.

This means three things: (i) the whole operating system is defined with all its applications from the boot instance through a simple script; (ii) since the application, packages and binaries are spelled out in a script the whole development environment is fully reproducible under any Linux or Unix-based operating system; (iii) you share with your team the whole OS definition instead of just a container or image; (iv) your productivity goes to the roof because your operating system is not only stable but reproducible as well, with the additional advantages of being able to create isolated environments via Nix.

But nothing beats a hands-on experience. I downloaded a NixOS ISO with graphical installation and installed it on top of my Bluefin-DX using tools already available: QEMU and Virtual Machine Manager. The installation was painless, NixOS boots quick as a virtual machine. No hiccups there. Once you log in the adventure starts.

Now what? I said. It is just another OS. The thing starts becoming clearer as you start installing applications. Yes, of course, you can install flatpak. But the ground breaking stuff is indicating the packages you need inside /etc/nixos/configuration.nix, then update, and reboot. Then, all the applications come alive in your dock.

Specifying applications
image

I made the experiment installing Firefox, Brave, Edge, Gnome Tweaks, and the extension Dash-to-Dock. It is flawless. All these applications, binaries and services live in repositories.

Specifying extensions

So, if I want to share my whole OS with you, I just sent you a script. That’s it!
If I make a mistake during the installation or settings, just revert to the previous version.
And this is just the OS I am talking about. On top of NixOS we have the reproducible packages, flakes and whatnot.

Bluefin-DX, and NixOS as a VM, make an amazing combination. Reproducible within Immutable.

Disclaimer: I am not a professional developer or programmer; maybe your occasional data scientist applying machine learning and profoundly enthusiast AI engineer. I am seeking for the holy grail of a fully reproducible development environment for artificial intelligence that includes from machine learning to natural language processing, object recognition, robotics. knowledge expert systems up to decision making, logic and planning.

NixOS desktop via Virtual Manager

Time at which Mitchell starts talking about his NixOS VM

5 Likes

Have you tried using Nix for ephemeral local development environments? (on non-NixOS hosts, like your lovely Bluefin host)

I think you will like it:

2 Likes

Thanks for sharing!
I watched the two videos.

Yes. I am familiar with these nix-shell environments. It was the first thing that I learned about Nix.

Now, I am exploring what how other developers are doing with immutable or atomic operating systems. That is how I found the video on Mitchel Hashimoto.

1 Like

I dunno why he uses a vm and not a container. I guess if he’s working alone it might work out but he’s got a very opinionated setup. I like to keep the repo clean with branches for devcontainers, etc. very rarely do I not have a monorepo or multi repo with dependencies on each other. Like I have a build whose output runs an api another app consumes. I cannot control these things.

My current build setup tries to be agnostic to nix, vms or containers. Build out branches so if one team can’t use a vm or nix or a container they can checkout code and it propagates to different “dev branches” via CI integration. Or sucks but mostly works and is reality of co development.

Otherwise you have lawyers looking at every license.

Large corporate environments need a little love. I want devs to check in code into whatever works and have it propagate to other branches, with checks in the background.

Also this sounds stupid but if this project had an enterprise paid model that’d men past a lot.

That is a good question.

From watching the video I could tell that he very much likes -and needs - the Apple ecosystem. That explains the Mac. Why a VM and not a container? I guess because with a VM he gets a complete development environment with a light window manager (i3), editor (neovim), the operating system NixOS, and the Nix tools. I think the containers come after or during development on individual Nix shells, flakes, or packages. Nix can generate Docker containers as well. From what he manifests during the interview he very much likes the fact that he can spin the same OS environment from a script, over an over, and that he can version via git his dotfiles, and changes he performs over the VM. If he loses the OS VM for any reason, he can be up and running again in 10 minutes. The Fusion VM is his preference, maybe because of the Mac integration. I was reading yesterday that Nix can create a QEMU machines from a declarative script. I haven’t tested this yet. Everything else I have been able to reproduce, including the NixOS with i3. My main or core OS is Bluefin-DX. So, pretty much indestructible.

EDIT: There is one more reason he uses NixOS as a VM on top of the Mac. He wanted consistency “… Linux does this, Mac does it this other way …”. And Linux has a pretty good consistent set of tools for development.

I yet have to watch the video! (I haven’t found the time to sit calmly and make the most out of it).

Maybe a reason is that running containerized workflows in macOS is tricky, as they run in a VM handled by Docker Desktop (which I would presume is what he is using).

If that’s the case, managing a VM with Vagrant + Fusion is a great choice IMO.

1 Like

Actually, containers are much better in orbstack than Docker Desktop, and it has OCI and Docker compatibility among other things. Its main weakness though is poor memory management, but it’s faster than Docker on Mac. (Linux is still unmatched for containers though.)

Thanks for the heads up (I quit using macOS a few years ago, so I lost track of what’s happening there).

Orbstack GUI reminds me of Podman Desktop, which, frankly, is a great GUI app.

1 Like