Now Reading
Organising Nix on macOS

Organising Nix on macOS

2024-01-15 13:10:34


January 15, 2024

by Jacek Galowicz

title image of blog post


I not too long ago purchased a Macbook as a result of an increasing number of individuals are asking me methods to
use Nix in sure conditions underneath MacOS.
On this article, we stroll by putting in Nix on MacOS and see how nice
the expertise is nowadays.
After that, we present methods to go declarative on MacOS with nix-darwin to allow
compilation for Linux and Intel Macs, in addition to another good options.

🤷 Why would one wish to have Nix on a Mac?

There are a number of causes:

Along with that, we’re taking a look at nix-darwin on this article, which provides
the next causes on high:

  • Declarative configuration of all of your macOS system settings
  • Set up of packages and configuration of these
  • Seamless integration into launchd
    for configuration of extra daemons
  • Painless administration of native Linux builder VMs

This text is about two steps and supplies more information for every:

  1. Set up Nix
  2. Bootstrap nix-darwin

On each new Mac, it’s simply two command-line invocations in case your nix-darwin
configuration is already ready.

🌱 Step 1: Putting in Nix on macOS

There are a number of methods to put in Nix.
The presumably most blatant manner (at the least on GNU/Linux) is to make use of one other package deal
supervisor to put in Nix.
Typically, don’t do this.

Particularly on macOS, three other ways work effectively:

  1. Official Nix installer from nixos.org
  2. Determinate System’s Nix Installer for the shell
  3. Determinate Systems’s graphical installer for macOS

The determinate methods installers have a couple of benefits over the unique Nix
installer:

  • It supplies a nicer overview of the set up steps
  • It’s designed to outlive macOS upgrades
  • Nix Flakes are enabled by default
  • The set up and configuration may be personalized

The graphical installer has two extra perks:

The Determinate Systems Graphical Nix Installer in action

I selected to make use of Determinate System’s shell installer, which is a one-liner
as described in
their GitHub repository
(unfold over a number of strains right here to extend readability):

Nix cheat sheet.
It’ll provide the very best overview of the instructions obtainable!

🛫 Step 2: Going declarative with nix-darwin

With Nix put in, now we have all of the Nix shell magic (utilizing nix develop,
nix shell) at our disposal and may construct and run (utilizing nix construct and
nix run) random initiatives/packages from the web, which is nice.

Nonetheless, if we think about having to put in packages utilizing
nix profile set up ... on each different Mac, we’re not significantly better off than
with classical package deal administration.
Additionally, this doesn’t handle our configurations and companies, which is precisely
what we’re used to from NixOS.

The final concept is that we wish to have one massive configuration file
(presumably scattered over a number of recordsdata for higher construction and composability)
that units our system up as we would like it with one single command.

That is the place nix-darwin enters the
scene:
Because the venture description says, this venture goals to convey the comfort of a
declarative system method to macOS.

The nix-darwin logo

Ranging from zero, we are able to initialize a brand new nix-darwin configuration file in
some configuration folder:

nix-darwin configuration options Documentation
which lists and describes all of the obtainable choices.
This overview is a goldmine – there’s something for everybody.

Let’s take a look at a couple of good examples:

Unlocking sudo by way of fingerprint

If now we have a Mac with Touch ID, we are able to
unlock sudo instructions with our fingerprint as an alternative of typing the password.
That is after all not unique to nix-darwin customers, however these have it
notably simple to allow it.

Merely add the next line to the brand new config:

Rosetta, which allows the
system to run binaries for Intel CPUs transparently.

The set up nonetheless must be completed manually within the terminal with this
command:

nixpkgs documentation.

📲 Updating the System

Updating the system includes two steps:

  1. Updating the Nix flake inputs
  2. Rebuilding the system

mail or schedule a
quick call ! 💪

Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top