{"id":13440481,"url":"https://github.com/LnL7/nix-darwin","last_synced_at":"2025-03-20T09:33:23.118Z","repository":{"id":39004605,"uuid":"71055474","full_name":"LnL7/nix-darwin","owner":"LnL7","description":"nix modules for darwin","archived":false,"fork":false,"pushed_at":"2025-03-16T23:00:25.000Z","size":7037,"stargazers_count":3741,"open_issues_count":313,"forks_count":505,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-03-18T23:41:26.259Z","etag":null,"topics":["darwin","dotfiles","launchd","nix"],"latest_commit_sha":null,"homepage":"","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LnL7.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["emilazy","Enzime"]}},"created_at":"2016-10-16T14:26:46.000Z","updated_at":"2025-03-18T15:47:14.000Z","dependencies_parsed_at":"2024-01-21T01:22:02.343Z","dependency_job_id":"1e10db5a-c7d0-43f7-955a-ece8d0eba101","html_url":"https://github.com/LnL7/nix-darwin","commit_stats":{"total_commits":1330,"total_committers":208,"mean_commits":6.394230769230769,"dds":0.456390977443609,"last_synced_commit":"21fe31f26473c180390cfa81e3ea81aca0204c80"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LnL7%2Fnix-darwin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LnL7%2Fnix-darwin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LnL7%2Fnix-darwin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LnL7%2Fnix-darwin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LnL7","download_url":"https://codeload.github.com/LnL7/nix-darwin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244586074,"owners_count":20476876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["darwin","dotfiles","launchd","nix"],"created_at":"2024-07-31T03:01:23.158Z","updated_at":"2025-03-20T09:33:23.113Z","avatar_url":"https://github.com/LnL7.png","language":"Nix","funding_links":["https://github.com/sponsors/emilazy","https://github.com/sponsors/Enzime"],"categories":["HarmonyOS","Nix","NixOS Modules","others","nix","Official(公式レポジトリ)"],"sub_categories":["Windows Manager","Zig"],"readme":"[\u003cimg src=\"https://daiderd.com/nix-darwin/images/nix-darwin.png\" width=\"200px\" alt=\"logo\" /\u003e](https://github.com/LnL7/nix-darwin)\n\n# nix-darwin\n\n[![Test](https://github.com/LnL7/nix-darwin/actions/workflows/test.yml/badge.svg)](https://github.com/LnL7/nix-darwin/actions/workflows/test.yml)\n\nNix modules for darwin, `/etc/nixos/configuration.nix` for macOS.\n\nThis project aims to bring the convenience of a declarative system approach to macOS.\nnix-darwin is built up around [Nixpkgs](https://github.com/NixOS/nixpkgs), quite similar to [NixOS](https://nixos.org/).\n\n## Prerequisites\n\nThe only prerequisite is a Nix implementation; both Nix and Lix are supported.\n\nAs the official Nix installer does not include an automated uninstaller, and manual uninstallation on macOS is a complex process, we recommend using one of the following installers instead:\n\n* The [Nix installer from Determinate Systems](https://github.com/DeterminateSystems/nix-installer?tab=readme-ov-file#determinate-nix-installer) is only recommended for use with flake-based setups.\n  It can install one of two distributions of Nix:\n\n  * To install the **recommended** vanilla upstream [Nix](https://nixos.org), you will need to explicitly say `no` when prompted to install `Determinate Nix`.\n\n  * When run with the `--determinate` flag, it will install the [Determinate](https://docs.determinate.systems/) distribution.\n    As Determinate manages the Nix installation itself, you will need to set `nix.enable = false;` in your configuration to disable nix-darwin’s own Nix management.\n    Some nix-darwin functionality that relies on managing the Nix installation, like the `nix.*` options to adjust Nix settings or configure a Linux builder, will be unavailable.\n\n* The [Lix installer](https://lix.systems/install/#on-any-other-linuxmacos-system) supports both flake-based and channel-based setups.\n\n\n\n## Getting started\n\nDespite being an experimental feature in Nix currently, nix-darwin recommends that beginners use flakes to manage their nix-darwin configurations.\n\n\u003cdetails\u003e\n\u003csummary\u003eFlakes (Recommended for beginners)\u003c/summary\u003e\n\n### Step 1. Creating `flake.nix`\n\n\u003cdetails\u003e\n\u003csummary\u003eGetting started from scratch\u003c/summary\u003e\n\u003cp\u003e\u003c/p\u003e\n\nIf you don't have an existing `configuration.nix`, you can run the following commands to generate a basic `flake.nix` inside `/etc/nix-darwin`:\n\n```bash\nsudo mkdir -p /etc/nix-darwin\nsudo chown $(id -nu):$(id -ng) /etc/nix-darwin\ncd /etc/nix-darwin\n\n# To use Nixpkgs unstable:\nnix flake init -t nix-darwin/master\n# To use Nixpkgs 24.11:\nnix flake init -t nix-darwin/nix-darwin-24.11\n\nsed -i '' \"s/simple/$(scutil --get LocalHostName)/\" flake.nix\n```\n\nMake sure to change `nixpkgs.hostPlatform` to `aarch64-darwin` if you are using Apple Silicon.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eMigrating from an existing configuration.nix\u003c/summary\u003e\n\u003cp\u003e\u003c/p\u003e\n\nAdd the following to `flake.nix` in the same folder as `configuration.nix`:\n\n```nix\n{\n  description = \"John's darwin system\";\n\n  inputs = {\n    # Use `github:NixOS/nixpkgs/nixpkgs-24.11-darwin` to use Nixpkgs 24.11.\n    nixpkgs.url = \"github:NixOS/nixpkgs/nixpkgs-unstable\";\n    # Use `github:LnL7/nix-darwin/nix-darwin-24.11` to use Nixpkgs 24.11.\n    nix-darwin.url = \"github:LnL7/nix-darwin/master\";\n    nix-darwin.inputs.nixpkgs.follows = \"nixpkgs\";\n  };\n\n  outputs = inputs@{ self, nix-darwin, nixpkgs }: {\n    darwinConfigurations.\"Johns-MacBook\" = nix-darwin.lib.darwinSystem {\n      modules = [ ./configuration.nix ];\n    };\n  };\n}\n```\n\nMake sure to replace `Johns-MacBook` with your hostname which you can find by running `scutil --get LocalHostName`.\n\nMake sure to set `nixpkgs.hostPlatform` in your `configuration.nix` to either `x86_64-darwin` (Intel) or `aarch64-darwin` (Apple Silicon).\n\n\u003c/details\u003e\n\n### Step 2. Installing `nix-darwin`\n\nUnlike NixOS, `nix-darwin` does not have an installer, you can just run `darwin-rebuild switch` to install nix-darwin. As `darwin-rebuild` won't be installed in your `PATH` yet, you can use the following command:\n\n```bash\n# To use Nixpkgs unstable:\nnix run nix-darwin/master#darwin-rebuild -- switch\n# To use Nixpkgs 24.11:\nnix run nix-darwin/nix-darwin-24.11#darwin-rebuild -- switch\n```\n\n### Step 3. Using `nix-darwin`\n\nAfter installing, you can run `darwin-rebuild` to apply changes to your system:\n\n```bash\ndarwin-rebuild switch\n```\n\n#### Using flake inputs\n\nInputs from the flake can also be passed into `darwinSystem`. These inputs are then\naccessible as an argument `inputs`, similar to `pkgs` and `lib`, inside the configuration.\n\n```nix\n# in flake.nix\nnix-darwin.lib.darwinSystem {\n  modules = [ ./configuration.nix ];\n  specialArgs = { inherit inputs; };\n}\n```\n\n```nix\n# in configuration.nix\n{ pkgs, lib, inputs }:\n# inputs.self, inputs.nix-darwin, and inputs.nixpkgs can be accessed here\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eChannels\u003c/summary\u003e\n\n### Step 1. Creating `configuration.nix`\n\nCopy the [simple](./modules/examples/simple.nix) example to `/etc/nix-darwin/configuration.nix`.\n\n### Step 2. Adding `nix-darwin` channel\n\n```bash\n# If you use Nixpkgs unstable (the default):\nsudo nix-channel --add https://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin\n# If you use Nixpkgs 24.11:\nsudo nix-channel --add https://github.com/LnL7/nix-darwin/archive/nix-darwin-24.11.tar.gz darwin\n\nsudo nix-channel --update\n```\n\n### Step 3. Installing `nix-darwin`\n\nTo install `nix-darwin`, you can just run `darwin-rebuild switch` to install nix-darwin. As `darwin-rebuild` won't be installed in your `PATH` yet, you can use the following command:\n\n```bash\nnix-build '\u003cdarwin\u003e' -A darwin-rebuild\n./result/bin/darwin-rebuild switch -I darwin-config=/etc/nix-darwin/configuration.nix\n```\n\n### Step 4. Using `nix-darwin`\n\nAfter installing, you can run `darwin-rebuild` to apply changes to your system:\n\n```bash\ndarwin-rebuild switch\n```\n\n### Step 5. Updating `nix-darwin`\n\nYou can update Nixpkgs and `nix-darwin` using the following command:\n\n```bash\nsudo nix-channel --update\n```\n\u003c/details\u003e\n\n## Documentation\n\n`darwin-help` will open up a local copy of the reference documentation, it can also be found online [here](https://daiderd.com/nix-darwin/manual/index.html).\n\nThe documentation is also available as manpages by running `man 5 configuration.nix`.\n\n## Uninstalling\n\nTo run the latest version of the uninstaller, you can run the following command:\n\n```\nnix --extra-experimental-features \"nix-command flakes\" run nix-darwin#darwin-uninstaller\n```\n\nIf that command doesn't work for you, you can try the locally installed uninstaller:\n\n```\ndarwin-uninstaller\n```\n\n## Tests\n\nThere are basic tests that run sanity checks for some of the modules,\nyou can run them like this:\n\n```bash\n# run all tests\nnix-build release.nix -A tests\n# or just a subset\nnix-build release.nix -A tests.environment-path\n```\n\n## Contributing\n\nLet's make Nix on macOS awesome!\n\nDon't hesitate to contribute modules or open an issue.\n\nTo build your configuration with local changes you can run this. This\nflag can also be used to override darwin-config or nixpkgs, for more\ninformation on the `-I` flag look at the nix-build [manpage](https://nixos.org/manual/nix/stable/command-ref/nix-build.html).\n\n```bash\ndarwin-rebuild switch -I darwin=.\n```\n\nIf you're adding a module, please add yourself to `meta.maintainers`, for example\n\n```nix\n  meta.maintainers = [\n    lib.maintainers.alice or \"alice\"\n  ];\n\n  options.services.alicebot = # ...\n```\n\nThe `or` operator takes care of graceful degradation when `lib` from Nixpkgs\ngoes out of sync.\n\nAlso feel free to contact me if you have questions,\n- Matrix - @daiderd:matrix.org, you can find me in [#macos:nixos.org](https://matrix.to/#/#macos:nixos.org)\n- @LnL7 on twitter\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLnL7%2Fnix-darwin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLnL7%2Fnix-darwin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLnL7%2Fnix-darwin/lists"}