{"id":184,"date":"2020-05-10T12:15:00","date_gmt":"2020-05-10T17:15:00","guid":{"rendered":"http:\/\/sycured.127.0.0.1.sslip.io\/?p=184"},"modified":"2024-01-13T16:56:07","modified_gmt":"2024-01-13T21:56:07","slug":"nix-on-macos-catalina","status":"publish","type":"post","link":"http:\/\/10.42.0.68:8080\/blog\/nix-on-macos-catalina","title":{"rendered":"Nix on macOS Catalina"},"content":{"rendered":"\n

Installing Nix<\/a> on macOS Catalina isn’t hard if you know a little about APFS.<\/p>\n\n\n\n

I’m the only user on my MacBook Pro so I don’t install using daemon mode, you can easily custom it (last step).<\/p>\n\n\n\n\n\n\n\n

Step 1: synthetic.conf<\/h2>\n\n\n\n

It’s the way to create a folder in \/<\/p>\n\n\n\n

echo 'nix' | sudo tee -a \/etc\/synthetic.conf<\/code><\/pre>\n\n\n\n

Step 2: reboot<\/h2>\n\n\n\n

We need to reboot to apply the change about synthetic.<\/p>\n\n\n\n

After reboot, you have \/nix created<\/p>\n\n\n\n

Step 3: creating a new volume<\/h2>\n\n\n\n

It’s the magic about APFS and attaches it to \/nix<\/p>\n\n\n\n

sudo diskutil apfs addVolume disk1 APFSX Nix -mountpoint \/nix<\/code><\/pre>\n\n\n\n

I’m the owner of the new volume<\/p>\n\n\n\n

sudo diskutil enableOwnership \/nix<\/code><\/pre>\n\n\n\n

We hide \/nix and auto-mount the new volume to \/nix at boot<\/p>\n\n\n\n

echo \"LABEL=Nix \/nix apfs rw\" | sudo tee -a \/etc\/fstab<\/code><\/pre>\n\n\n\n

Disable spotlight (indexing) on \/nix<\/p>\n\n\n\n

sudo mdutil -i off \/nix<\/code><\/pre>\n\n\n\n

Step 4: install<\/h2>\n\n\n\n
curl -L https:\/\/nixos.org\/nix\/install | sh<\/code><\/pre>\n\n\n\n

Step 5: user config<\/h2>\n\n\n\n

We can replace and standardize each nix-env -i pkg_name<\/code> with a config file: $HOME\/.config\/nixpkgs\/config.nix<\/code><\/p>\n\n\n\n

An example:<\/p>\n\n\n\n

{\n    allowUnfree = true;\n\n    packageOverrides = pkgs: with pkgs; {\n        all = pkgs.buildEnv {\n            name = \"all\";\n            paths = [\n                ansible\n                ansible-lint\n                cloc\n                colordiff\n                dos2unix\n                ffmpeg-full\n                htop\n                httpie\n                jq\n                mtr\n                pwgen\n                silver-searcher\n                tmux\n                tree\n                watch\n                wget\n                whois\n                yq\n                zsh\n                zstd\n            ];\n        };\n    };\n}<\/code><\/pre>\n\n\n\n

And to apply this config file: nix-env -i all<\/code><\/p>\n\n\n\n

Step 6: my alias to upgrade and clean the old version<\/h2>\n\n\n\n
nixupgrade='nix-channel --update && nix-env -u && nix-collect-garbage -d'<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"

Installing Nix on macOS Catalina isn’t hard if you know a little about APFS. I’m the only user on my MacBook Pro so I don’t install using daemon mode, you can easily custom it (last step).<\/p>\n","protected":false},"author":1,"featured_media":100,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"saved_in_kubio":false,"footnotes":""},"categories":[13],"tags":[27],"_links":{"self":[{"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/posts\/184"}],"collection":[{"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/comments?post=184"}],"version-history":[{"count":1,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/posts\/184\/revisions"}],"predecessor-version":[{"id":185,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/posts\/184\/revisions\/185"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/media\/100"}],"wp:attachment":[{"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/media?parent=184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/categories?post=184"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/tags?post=184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}