Managing Darwin with Nix
ICYMI: This page is part of my digital garden (Click to expand)
This page, and others in the garden, may be unfinished or have typos. The information may also be out of date.
These pages are meant as part of a public living notebook to be edited over time.
For more, visit the page explaining the concept of a digital garden.
Installing Nix on macOS isn’t very complicated these days, but graduating from simply building projects using Nix to managing the configuration of your entire macOS install using Nix can be a big step.
- The preferred way is to use nix-darwin (github.com)
- It’s documentation website (nix-darwin.github.io) is extremely useful for figuring out what options are available.
- nix on macOS for new people (stephank.nl)
Improved autocomplete with nixd
in VSCode for nix-darwin
Link to heading
When developing and using nixd (github.com) in VSCode you can use the following configuration for your workspace to get proper autocomplete.
{
"folders": [
{
"path": "."
}
],
"settings": {
"nix.enableLanguageServer": true,
"nix.serverPath": "nixd",
"nix.serverSettings": {
"nixd": {
"formatting": {
"command": ["nixfmt"]
},
"nixpkgs": {
"expr": "import (builtins.getFlake (builtins.toString ./.)).inputs.nixpkgs {}"
},
"options": {
// By default, this entry will be read from `import <nixpkgs> { }`.
// You can write arbitrary Nix expressions here, to produce valid "options" declaration result.
// Tip: for flake-based configuration, utilize `builtins.getFlake`
"nixos": {
"expr": "(builtins.getFlake (builtins.toString ./.)).nixosConfigurations.YOURSYSTEMNAME.options"
}
"nix-darwin": {
"expr": "(builtins.getFlake (builtins.toString ./.)).darwinConfigurations.YOURSYSTEMNAME.options"
}
}
}
}
},
"extensions": {
"recommendations": ["jnoortheen.nix-ide", "bbenoist.nix"]
}
}