419 Commits
Author SHA1 Message Date
Domen KožarandGitHub 57a3171f94 programs/devenv: init module (#1834) 2026-07-19 22:34:20 +00:00
Anish Pallati c1403be257 programs/devenv: init module
Signed-off-by: Anish Pallati <i@anish.land>
2026-07-19 00:17:39 -04:00
SamandGitHub b4cccbd4bc darwin-rebuild: add flake options to zsh completions (#1669) 2026-07-18 08:19:57 +00:00
Angel J 1543ae0852 darwin-rebuild: add flake options to zsh completions
Signed-off-by: Angel J <78835633+Iamanaws@users.noreply.github.com>
2026-07-17 22:20:27 -07:00
Michael HoangandGitHub a4cf1d1085 mas: add module for Mac App Store management (#1668) 2026-07-15 13:58:56 +00:00
SamandGitHub d5bd9cd77a bump nixpkgs to fix manual/website builds (#1822) 2026-07-07 03:45:56 +00:00
zowoq b2217f8051 flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/8c3cede7ddc26bd659d2d383b5610efbd2c7a16e?narHash=sha256-rppURzHviaQN131F%2BnLiLdGfcb0uCd9gGP0E5%2Biw9MI%3D' (2026-06-08)
  → 'github:NixOS/nixpkgs/f205b5574fd0cb7da5b702a2da51507b7f4fdd1b?narHash=sha256-/NAkDSsve%2BGNM0Bt6tleJdCGfsTlK89nPjkVOzZMo0s%3D' (2026-07-05)
2026-07-07 13:03:24 +10:00
SamandGitHub 08920bcfd1 manualHTML: adopt to nixos/nixpkgs#537810 (#1818) 2026-07-07 01:06:54 +00:00
Yifei Sun 320cbf535b manualHTML: adopt to nixos/nixpkgs#537810 2026-07-04 12:51:44 +02:00
Angel J deadc7204c mas: add module for Mac App Store management
Signed-off-by: Angel J <78835633+Iamanaws@users.noreply.github.com>
2026-06-25 18:43:32 -07:00
SamandGitHub a1fa429e94 homebrew: pass extraEnv to cleanup checks (#1804) 2026-06-18 05:49:52 +00:00
Bryan Lai d8a6661f78 homebrew: use brewBundleCmd also for system.checks 2026-06-18 11:00:29 +08:00
Bryan Lai 5138eaf896 homebrew: mv PATH & sudo setup to brewBundleCmd
This should be a trivial refactor, which enables us to reuse
`brewBundleCmd` in the future for `brew bundle cleanup` as well.
2026-06-18 09:35:18 +08:00
Bryan Lai e636bf1664 homebrew: pass onActivation.extraEnv to checks
When onActivation.cleanup == "check", a separate `brew bundle cleanup`
command is run in the system.checks phase before the actual activation.

This `brew bundle cleanup` invocation should use the same `extraEnv`
as the main `brew bundle [install]` command, for consistency.

For example, when $XDG_CONFIG_HOME is set in `extraEnv`, it should also
be picked up by `brew bundle cleanup` in the system.checks phase.
2026-06-18 09:35:18 +08:00
SamandGitHub ee9c7b96c9 homebrew: address new CLI flag requirements (#1789) 2026-06-17 16:57:21 +00:00
Yifei Sun cd7cf09aa3 homebrew: set trusted flag in Brewfile directly
Suggested-by: Austin Horstman <khaneliman12@gmail.com>
Reviewed-by: Sam <30577766+Samasaur1@users.noreply.github.com>
2026-06-17 18:23:19 +02:00
SamandGitHub ee20edc445 users: realpath home dirs before comparison (#1803) 2026-06-17 16:21:08 +00:00
Yifei Sun bb9c29c193 homebrew: address bundle command new CLI flag requirements 2026-06-17 18:15:07 +02:00
Ihar Hrachyshka 08278afff6 users: realpath home dirs before comparison
When we create users with homedir under /var, they end up with
NFSHomeDirectory under /private/var because /var is a symlink. This
breaks consequent activations and requires that user overrides their
home dir attribute with /private/var/... to pass the activation
precheck.

`realpath` should normalize the discrepancy.
2026-06-14 20:54:47 -10:00
SamandGitHub aabb2037ed flake.lock: update nixpkgs (#1799) 2026-06-12 05:33:53 +00:00
SamandGitHub 0bddd7a5ed time: remove double condition (#1800) 2026-06-12 05:32:59 +00:00
SandroandGitHub 9f8122dd2b time: remove double condition 2026-06-11 20:52:34 +02:00
ben 818b88b75f flake.lock: update nixpkgs 2026-06-11 10:06:13 -07:00
SamandGitHub d0d0978f34 Fix typo (#1798) 2026-06-11 16:43:09 +00:00
SandroandGitHub ace757665e Fix typo 2026-06-11 17:58:55 +02:00
SamandGitHub d9ffa378a6 github-runner: remove node20 runtime from defaults (#1796) 2026-06-11 15:00:05 +00:00
Yuriy Taraday b317d77bbf github-runner: remove node20 runtime from defaults
It's marked as insecure starting with 26.05, and now github-runner package defaults to supporting only node24
See https://github.com/NixOS/nixpkgs/pull/524856
2026-06-11 14:02:39 +02:00
SamandGitHub f73cbf1f65 (feature) Add swapEscapeAndCapsLock and swapRightCommandAndRightOption (#1706) 2026-06-11 06:46:22 +00:00
SamandGitHub 958c16ba9a spacebar: add default package (#1786) 2026-06-11 05:59:41 +00:00
Ethan Carter Edwards 4bcdd687ca spacebar: add default package
Upstream should be the default.

Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
2026-06-08 11:41:05 -07:00
Gaetan Lepage 3f0f0ece39 feat(keyboard): add swapRightCommandAndRightOption 2026-06-08 10:42:29 +02:00
Gaetan Lepage 57ff7cbd20 feat(keyboard): add swapCapsLockAndEscape 2026-06-08 10:42:29 +02:00
SamandGitHub 6a771120d6 version: bump to 26.11 (#1782) 2026-06-07 01:23:23 +00:00
Sam f8531f95fe tests/github-runners: limit to supported node runtimes 2026-05-26 08:50:22 -07:00
Sam 7c3d11b160 modules/terminfo: update list of packages with terminfo 2026-05-26 08:29:42 -07:00
Sam 8073b91aa3 scripts/release: init
This script has not yet been tested in its entirety, but the file
editing operations were used for #1781 and #1782
2026-05-26 08:29:18 -07:00
Sam ae3e2b18d3 flake.lock: update
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/af84f9d270d404c17699522fab95bbf928a2d92f' (2025-12-17)
  → 'github:NixOS/nixpkgs/d849bb215dcdf71bce3e686839ccdb4219e84b2f' (2026-05-24)
2026-05-25 13:16:30 -07:00
Sam 82325d90a1 version: bump to 26.11 2026-05-25 13:08:31 -07:00
SamandGitHub 56c666e108 nixpkgs.config: Add allowUnfreePackages option (#1742) 2026-05-17 16:55:09 +00:00
SamandGitHub 3fe4b4fb3c darwin-rebuild: support --log-format (#1675) 2026-05-17 15:23:44 +00:00
SamandGitHub 426b6e8f02 tmux: update key binding (#1681) 2026-05-17 15:23:31 +00:00
Bryan 905fe60936 add reverseSplitBindings option 2026-05-17 22:44:37 +08:00
BryanandBryan 4ec530e8b5 tmux: update key binding 2026-05-17 22:44:37 +08:00
Michael HoangandGitHub 1e107a7b92 Revert "tests/aerospace: adapt to new toml generator" (#1773) 2026-05-17 07:31:14 +00:00
SamandGitHub 09b3575c2d Revert "tests/aerospace: adapt to new toml generator" 2026-05-16 20:11:00 -07:00
SamandGitHub 8c62fba085 homebrew: add onActivation.extraEnv option (#1745) 2026-05-03 03:57:46 +00:00
Michael HoangandGitHub d0e2383e3f tests/aerospace: adapt to new toml generator (#1756) 2026-05-03 03:07:42 +00:00
Sam b1737791a9 tests/aerospace: adapt to new toml generator
See https://github.com/NixOS/nixpkgs/commit/e23ad3bd2739af8ac41d5338fb389029f551cde9
2026-04-27 21:34:25 -07:00
isabel 1e2d8fbb37 darwin-rebuild: support --log-format 2026-04-21 01:41:39 +01:00
mmenanno 3510d049d3 homebrew: replace envHints/analytics/updateReportNew with onActivation.extraEnv
Per review feedback on #1745: rather than adding one boolean option per
HOMEBREW_NO_* env var, expose a generic onActivation.extraEnv attrset that
is prepended to brewBundleCmd alongside HOMEBREW_NO_AUTO_UPDATE=1. This
covers the same use case and the long tail of other HOMEBREW_NO_* vars
without tying the module to Homebrew's naming choices.

The global-scope booleans are dropped with no replacement — users who want
these variables set globally can write them directly into
environment.variables, so a global.extraEnv would be pure sugar.
2026-04-14 12:31:00 -05:00
mmenanno 8f6396c0dc homebrew: add envHints, analytics, and updateReportNew options
Add options to control Homebrew environment variable hints, analytics
notices, and new formulae/casks reports during system activation and
manual brew commands.

These follow the existing autoUpdate pattern: boolean options that
default to true (preserving current behavior) and set the corresponding
HOMEBREW_NO_* environment variable when disabled.

onActivation options affect brew bundle during darwin-rebuild switch.
global options affect interactive brew commands via environment.variables.
2026-04-06 19:20:06 -04:00
Martin Häcker a0a51c56f0 nixpkgs.config: Add allowUnfreePackages option
Also make sure it merges correctly and verify with a test.

This was added in nixpkgs some time ago and is quite a nice addition as
it merges additively (in contrast to allowUnfreePredicate) thus allowing
to localize allowUnfreePackage specifications to all the locations in
your local config where unfree packages are added.
2026-04-01 21:03:30 +02:00
SamandGitHub 06648f4902 etc: support Lix 2.95.1 (#1731) 2026-04-01 09:53:30 +00:00
SamandGitHub ec2e2c72e7 prometheus-node-exporter: separate extra flags with a space (#1739) 2026-04-01 09:26:30 +00:00
SamandGitHub 5176e2f4b4 etc: support lix-installer 3.95.0 (#1730) 2026-04-01 06:12:18 +00:00
Ihar Hrachyshka df49e56fd6 prometheus-node-exporter: separate extra flags with a space 2026-03-31 22:07:04 -04:00
Martin Woo 2fec379474 Add Lix 2.95.1 nix.custom.conf. 2026-03-23 05:52:19 +01:00
Martin Woo c1d952849a etc: support Lix 2.95.1 2026-03-22 13:53:32 +01:00
Sam 2fa8900609 etc: support lix-installer 3.95.0 2026-03-21 11:23:28 -07:00
Michael HoangandGitHub da529ac9e4 services/openssh: manage host keys (#1701) 2026-03-08 20:03:47 +00:00
Michael HoangandGitHub 52d0615161 nix: add nix 2.33 to auto-optimise-store assertion (#1551) 2026-03-01 15:40:24 +00:00
Michael Hoang e6efc7c131 services/openssh: manage host keys 2026-02-27 15:42:59 +01:00
SamandGitHub 3bfa436c19 README: Update instructions for 25.11 (#1712) 2026-02-25 04:16:36 +00:00
Sean Gilligan 72a7e97c84 README: Update instructions for 25.11
Replace all references of `25.05` with `25.11`
2026-02-24 14:04:09 -08:00
SamandGitHub 6a7fdcd583 readme: Use bullet-list for documentation location (#1703) 2026-02-19 17:08:02 +00:00
Sean Gilligan ebe39ab3fa readme: Use bullet-list for documentation location
This will make it much easier to find the online documentation at
a quick glance, as well as making it easier to see the commands
for viewing locally.
2026-02-17 18:03:42 -08:00
SamandGitHub aff4c008ce etc: support experimental official Nix installer (#1702) 2026-02-17 23:45:16 +00:00
Michael Hoang 6d789c5a41 etc: support experimental official Nix installer 2026-02-17 23:53:32 +01:00
SamandGitHub 6c5a56295d modules/homebrew: comprehensive module refresh (#1692) 2026-02-12 19:01:55 +00:00
Malo Bourgon a43b4091db modules/homebrew: add CHANGELOG entry for module refresh 2026-02-12 10:24:39 -08:00
Malo Bourgon e0ffd55e7a modules/homebrew: fix typos and improve option descriptions 2026-02-12 10:24:39 -08:00
Malo Bourgon c68f5d1387 modules/homebrew: add onActivation.cleanup "check" mode
Closes #1032

Add `"check"` to the `onActivation.cleanup` enum. When set, nix-darwin runs
`brew bundle cleanup` during system checks to detect Homebrew packages that
are installed but not present in the generated Brewfile. If extra packages
are found, activation fails with a list of them and remediation steps.

Unlike `"uninstall"` and `"zap"`, the `"check"` mode never removes packages
-- it only reports. This runs during both `darwin-rebuild check` and
`darwin-rebuild switch`, matching the behavior of all other system checks.
2026-02-12 10:24:39 -08:00
Malo Bourgon ca6f8609c3 modules/homebrew: add shell integration options
Add `enableBashIntegration`, `enableFishIntegration`, and
`enableZshIntegration` options that evaluate `brew shellenv` to set up
Homebrew's environment and shell completions. This automates the
boilerplate that every nix-darwin Homebrew user currently writes manually.

All three shells use `interactiveShellInit`, consistent with direnv and
home-manager conventions. Fish additionally sets up completions paths in
the same hook.
2026-02-12 10:24:39 -08:00
Malo Bourgon 8c29e146dd modules/homebrew: replace brewPrefix with prefix
Closes #596

`homebrew.brewPrefix` defaulted to the bin directory (`/opt/homebrew/bin`),
not the actual Homebrew prefix (`/opt/homebrew`). This misled users into
writing `${config.homebrew.brewPrefix}/bin`, producing the broken path
`/opt/homebrew/bin/bin`.

Replace it with `homebrew.prefix`, which has correct semantics matching
`brew --prefix`. The old `brewPrefix` option is removed using
`mkRemovedOptionModule`, which catches both users who set the option and
users who read it in custom code. A warning also fires if the new `prefix`
value ends with `/bin`, catching users who copy the old value verbatim.
2026-02-10 09:26:54 -08:00
Malo Bourgon 24531016d8 modules/homebrew: deprecate homebrew.global.lockfiles
Homebrew Bundle removed lockfile support in Homebrew 4.4.0 (Oct 2024):
the `--no-lock` CLI flag, the `HOMEBREW_BUNDLE_NO_LOCK` env var, and
the `no_lock` parameter in `installer.rb` are all dead code. Setting
`homebrew.global.lockfiles` has had no effect on current Homebrew
versions.

- Replace the `lockfiles` option with a hidden stub (matching `noLock`)
- Replace the `noLock` hard assertion with a shared deprecation warning
  for both options
- Stop setting `HOMEBREW_BUNDLE_NO_LOCK` in `environment.variables`
- Remove the lockfiles paragraph from the `brewfile` option description
2026-02-10 09:26:54 -08:00
Malo Bourgon 65cfcebaa2 modules/homebrew: remove homebrew.whalebrews option
Whalebrew support was fully removed from Homebrew Bundle in
Homebrew 4.7.0 (Nov 2025). A `whalebrew` entry in a Brewfile now
raises `RuntimeError: Invalid Brewfile: undefined method 'whalebrew'`,
breaking the entire `brew bundle` invocation.

Use `mkRemovedOptionModule` so that existing configs get a clear
warning instead of an undefined-option error. Also removes the
auto-addition of `"whalebrew"` to `homebrew.brews` and the Brewfile
generation for Docker containers.
2026-02-10 09:26:54 -08:00
Malo Bourgon 3479b795aa modules/homebrew: add homebrew.cargoPackages option
Add support for `cargo "pkg"` entries in the generated Brewfile. Homebrew
Bundle supports installing Rust crates via `cargo install`; the `rust`
formula is automatically installed if not already present.
2026-02-10 09:24:45 -08:00
Malo Bourgon cbe4a600d4 modules/homebrew: add homebrew.goPackages option
Add support for `go "pkg"` entries in the generated Brewfile. Homebrew
Bundle supports installing Go packages via `go install`; the `go`
formula is automatically installed if not already present.
2026-02-10 09:24:17 -08:00
Malo Bourgon c65c24c87c modules/homebrew: add postinstall option for brews and casks
Both `brew bundle` formula and cask installers support a `postinstall`
option -- a shell command to run after the package is installed or
upgraded. The command only executes when the package actually changed,
not on every `brew bundle` run.

Examples from the Homebrew docs added to the `homebrew.brews` and
`homebrew.casks` option examples and tests.
2026-02-10 09:22:16 -08:00
Malo Bourgon a3fd89f1bb modules/homebrew: add link: :overwrite support
Homebrew supports `link: :overwrite` which runs `brew link --overwrite`,
force-overwriting existing symlinks. Extract the existing
`restart_service` special-case logic into a reusable helper
(`mkBrewfileLineBoolOrSymbolString`) for options that can be either a
bool or a Ruby symbol in the Brewfile.
2026-02-10 09:22:15 -08:00
Malo Bourgon 36815b4852 modules/homebrew: add restart_service "always" support
Homebrew supports restart_service: :always which restarts the service
on every brew bundle run, even if the formula wasn't changed.
2026-02-10 09:22:15 -08:00
Michael HoangandGitHub 7c952d9a52 Add support for installing vscode extensions via brew (#1222) 2026-02-10 15:13:34 +00:00
Frank Chiarulli Jr. fdbfb1dc1b add support for installing vscode extensions via brew 2026-02-09 21:59:25 -05:00
SamandGitHub 0d7874ef7e modules/homebrew: remove duplicates from brewfile (#1689) 2026-02-04 05:49:06 +00:00
Josh GibbsandGitHub 53dd29f381 remove duplicates from brewfile 2026-02-03 21:22:21 -08:00
zowoq 131e68e07e nix: add nix 2.33 to auto-optimise-store assertion 2026-01-23 19:28:06 +10:00
SamandGitHub 0fc4e7ac67 networking: add dhcpClientId option to set DHCP Client ID (#1562) 2026-01-18 19:31:43 +00:00
Ihar Hrachyshka 05a5979906 networking: add dhcpClientId option to set DHCP Client ID 2026-01-18 14:10:56 -05:00
Michael HoangandGitHub 8b720b9662 programs/direnv: add enable[shell]Integration options (#1680) 2026-01-16 11:11:07 +00:00
Radek Pietruszewski 6d323f4ffd programs/direnv: add enable*Integration options
Ability to disable shell hook is needed to use alternative shell hooks - e.g. direnv-instant. These options mirror NixOS's exactly.
2026-01-16 10:14:43 +01:00
Michael HoangandGitHub 7b1d394e7d feat(screencapture): add save-selections (#1677) 2026-01-12 12:21:49 +00:00
vaaski 48124872b6 fix(screencapture): move test location 2026-01-10 23:37:15 +01:00
Michael HoangandGitHub 9f48ffaca1 Add flake-parts module (#1670) 2026-01-06 16:55:03 +00:00
Manuel Mendez 3ab1648f50 Add flake-parts module 2026-01-06 10:20:38 -05:00
vaaski e5e7b6e878 feat(screencapture): add save-selections 2026-01-06 15:41:11 +01:00
SamandGitHub c31afa6e76 fix(modules): fixed typos in various modules (#1672) 2025-12-29 17:10:40 +00:00
Nikita Lenyk 8cecf9c5c5 fix(modules): fixed typos in various modules 2025-12-29 18:31:13 +02:00
Michael HoangandGitHub f0c8e1f6fe feat(gnupg): add configurable package option and install it (#1667) 2025-12-26 21:26:36 +00:00
Angel J d70b24c2a8 test(gnupg): add tests for gnupg agent configuration
Signed-off-by: Angel J <78835633+Iamanaws@users.noreply.github.com>
2025-12-26 07:44:43 -08:00
angel 0b53d57d3a feat(gnupg): add configurable package option and install it
Signed-off-by: Angel J <78835633+Iamanaws@users.noreply.github.com>
2025-12-26 07:42:37 -08:00
SamandGitHub c2b36207f2 readme: recommend only the Lix installer (#1659) 2025-12-23 21:20:13 +00:00
Sam eb05ef6d65 readme: recommend only the Lix installer 2025-12-23 15:57:16 -05:00
Michael HoangandGitHub adc6bed3ad modules/examples/lnl: drop qes (#1666) 2025-12-23 20:15:52 +00:00
Sam c496b15409 modules/examples/lnl: drop qes
See:
- https://github.com/NixOS/nixpkgs/issues/371202
- https://github.com/NixOS/nixpkgs/pull/473109
- https://github.com/astratagem/dotfield/issues/1
- https://github.com/asmvik/skhd/issues/44

Looks like it was merged into skhd pre-2020 and was only in nixpkgs in a
cached state. Based on that last link the cached version may not even
work on newer versions of macOS?

Regardless, this is causing tests to fail.
2025-12-23 14:09:41 -05:00
Michael HoangandGitHub 5fb45ece61 Update nixpkgs (#1658) 2025-12-18 06:13:12 +00:00
Hleb Shauchenka bfe00257dc Update nixpkgs 2025-12-17 15:48:28 +01:00
Michael HoangandGitHub 9b628e171b github-runner: fix authentication with actions/checkout@v6 (#1655) 2025-12-14 03:47:29 +00:00
Louis Opter a58dd30d2b github-runner: canonicalizes workDir to fix actions/checkout@v6
We ran into this issue wherein GitHub's `actions/checkout` would fail
because `git-config` would fail to include additional configuration.

The symptom was:

```
Error: fatal: could not read Username for 'https://github.com': terminal prompts disabled
```

And is caused by `git config --local includeIf.gitdir:/var/lib/github-runners/_work/…`.

Wherein `git` apparently resolves (canonicalizes) the current repository
path which then does not match the argument for `includeIf.gitdir` which
then means the configuration that `actions/checkout` is trying to apply
does not get pulled in, which then prevents git from authenticating with
GitHub and fails the build.

Ngl, gemini 3 found that out for me.

We could prefix `/private` everywhere, but changing the user's home
directory is going to [be tricky], not sure what do to about that.

[be tricky]: https://github.com/nix-darwin/nix-darwin/blob/7e22bf538aa3e0937effcb1cee73d5f1bcc26f79/modules/users/default.nix#L208
2025-12-12 20:52:37 +00:00
Louis Opter 8393ede275 github-runner: fix warnings from nixd" 2025-12-12 20:52:33 +00:00
SamandGitHub 7e22bf538a version: bump to 26.05 (#1649) 2025-12-06 23:50:51 +00:00
Sam 000ec99b5a version: bump to 26.05 2025-11-30 21:11:37 -07:00
Michael HoangandGitHub e95de00a47 fold -> foldr (#1646) 2025-11-26 12:44:44 +00:00
zowoq 36fed93cf5 fold -> foldr
deprecated in https://github.com/NixOS/nixpkgs/commit/f4d36941eba6c290a1f839b77f85d9579f087c22
2025-11-26 19:41:19 +10:00
SamandGitHub 3bda9f6b14 zsh: allow configuring history (#1635) 2025-11-18 22:37:57 +00:00
Michael HoangandGitHub c00da4e0a4 readme: update determinate installer instructions (#1642) 2025-11-18 19:02:47 +00:00
Sam e9bf5c5232 readme: update determinate installer instructions
The `--prefer-upstream-nix` flag is only guaranteed to be supported
until January 1st, but what's described now doesn't work at all, so this
is still an improvement.
2025-11-18 08:43:48 -07:00
Michael HoangandGitHub 973db96394 applications: change pathsToLink to a list (#1636) 2025-11-14 16:13:24 +00:00
zowoq 31e3a75444 applications: change pathsToLink to a list
https://github.com/NixOS/nixpkgs/commit/fbe214434a678004f8631a8f893d5c089e534db9
2025-11-14 09:54:32 +10:00
Bryan Lai 454d8d95c6 zsh: allow configuring history 2025-11-13 14:54:56 +08:00
Bryan Lai 7d5e904fb2 chore: ignore .DS_Store 2025-11-13 14:39:29 +08:00
SamandGitHub 5125a3cd41 fix: zsh-fast-syntax-highlighting path (#1624) 2025-11-08 18:51:26 +00:00
Michael HoangandGitHub e2b82ebd0f Add system.defaults.finder._FXEnableColumnAutoSizing (#1626) 2025-11-07 07:42:06 +00:00
Yiyu Zhou 7451154694 Add system.defaults.finder._FXEnableColumnAutoSizing 2025-11-06 14:29:09 -08:00
XYenon 54802bec7c fix: zsh-fast-syntax-highlighting path
https://github.com/NixOS/nixpkgs/pull/101007
2025-11-05 15:41:07 +08:00
Michael HoangandGitHub b8c7ac0302 Adapt to a Vim package rename/replacement in Nixpkgs (#1623) 2025-11-05 01:01:20 +00:00
Josh Tilles 89abe5ba46 Adapt to a vim pkg rename/replacement in Nixpkgs
Addresses an error like the following:
```sh-session
$ sudo darwin-rebuild --verbose --print-build-logs switch
building the system configuration...
fetching git input 'git+file:///private/etc/nix-darwin'
error:
       … while evaluating an expression to select 'drvPath' on it
         at «internal»:1:552:
       … while evaluating strict
         at «internal»:1:552:
       (stack trace truncated; use '--show-trace' to show the full trace)

       error: 'vim_configurable' has been renamed to/replaced by 'vim-full'
```

See <https://github.com/NixOS/nixpkgs/commit/853d9f31ea6206e86b72db1ba221a12cb503510f>

Fixes nix-darwin/nix-darwin#1622
2025-11-04 17:31:53 -05:00
Michael HoangandGitHub 69921864a7 dnsmasq: make the daemon wait for the nix store to be mounted (#1620) 2025-11-03 16:12:48 +00:00
Wigger Boelens 682de76b1e dnsmasq: make the daemon wait for the nix store to be mounted
This resolves the issue of the daemon not starting because the nix store is not yet mounted

Signed-off-by: Wigger Boelens <me@wigger.email>
2025-11-03 15:54:39 +01:00
SamandGitHub c3c8c9f2a5 feat(trackpad): add additional trackpad and gesture support (#1591) 2025-11-01 23:27:41 +00:00
SamandGitHub fc4e3dbe40 feat: make persistent-others similar to the new persistent-apps (#1431) 2025-11-01 18:33:40 +00:00
Michael HoangandGitHub 7cd9aac79e networking: modify firewall settings only if explicitly set (#1614) 2025-10-24 21:06:27 +00:00
Ryan Cao a4ecab1763 networking: modify firewall settings only if explicitly set 2025-10-24 14:23:07 +01:00
Michael HoangandGitHub c3211fcd0c dnsmasq: add servers option for upstream DNS configuration (#1611) 2025-10-17 17:14:42 +00:00
Wigger Boelens 1204e79a1e dnsmasq: add servers option for upstream DNS configuration
Adds a new `services.dnsmasq.servers` option to configure upstream DNS servers. This allows users to specify which DNS servers dnsmasq should forward queries to, supporting domain-specific routing and custom ports.
When empty (default), dnsmasq uses servers from /etc/resolv.conf.

Signed-off-by: Wigger Boelens <me@wigger.email>
2025-10-17 13:05:13 +02:00
Michael HoangandGitHub 9a9ab01072 #1608: aerospace: add option for colemak key-mapping (#1609) 2025-10-13 06:56:23 +00:00
Nelson TamandGitHub a9f953b682 aerospace: add option for colemak key-mapping 2025-10-13 17:02:03 +11:00
Michael HoangandGitHub c48e963a55 telegraf: set HOME to avoid crash at startup (#1598) 2025-09-25 13:02:32 +00:00
Jörg Thalheim 49eedd3d2a telegraf: set HOME to avoid crash at startup
https://github.com/nix-community/infra/pull/1982
2025-09-25 09:14:03 +02:00
Michael HoangandGitHub 25381509d5 Correct enum values for system.defaults.NSGlobalDomain.AppleIconAppearanceTheme (#1596) 2025-09-21 09:44:43 +00:00
Quintus CardozoandGitHub 5206a9fd30 Correct enum values for system.defaults.NSGlobalDomain.AppleIconAppearanceTheme 2025-09-21 13:59:38 +10:00
Michael HoangandGitHub 7be9c1b136 Add system.defaults.NSGlobalDomain.AppleIconAppearanceTheme (#1593) 2025-09-20 16:52:53 +00:00
Quintus Cardozo 5eb53f6003 Add test for system.defaults.NSGlobalDomain.AppleIconAppearanceTheme 2025-09-21 02:12:35 +10:00
Quintus CardozoandGitHub 3c7396a09c Add system.defaults.NSGlobalDomain.AppleIconAppearanceTheme 2025-09-19 13:58:48 +10:00
Dusty Pomerleau d55543d033 feat(trackpad): add additional trackpad and gesture support:
To `system.defaults.trackpad`, add:

```
ActuateDetents
DragLock
ForceSuppressed
TrackpadCornerSecondaryClick
TrackpadFourFingerHorizSwipeGesture
TrackpadFourFingerPinchGesture
TrackpadFourFingerVertSwipeGesture
TrackpadMomentumScroll
TrackpadPinch
TrackpadRotate
TrackpadThreeFingerHorizSwipeGesture
TrackpadThreeFingerTapGesture
TrackpadThreeFingerVertSwipeGesture
TrackpadTwoFingerDoubleTapGesture
TrackpadTwoFingerFromRightEdgeSwipeGesture
```

To `system.defaults.dock` add:

```
showAppExposeGestureEnabled
showDesktopGestureEnabled
showLaunchpadGestureEnabled
showMissionControlGestureEnabled
```
2025-09-18 11:36:57 +10:00
SamandGitHub ebd0bfc11f defaults: add NSGlobalDomain.NSStatusItem{Spacing,SelectionPadding} (#1310) 2025-09-17 09:55:40 +00:00
ac7999d72d Add NSStatusItemSpacing and NSStatusItemSelectionPadding
Add `NSStatusItemSpacing` and `NSStatusItemSelectionPadding` to `NSGlobalDomain`
options.

These options control the spacing between and padding inside status icons in the
menu bar. With these options, it's possible to squeeze more items on the menu
bar, something that's especially useful on machines with a notch.

This is a copy of #872, which was closed without being merged.

Co-Authored-By: Rob Harrop <rob@robharrop.dev>
2025-09-17 09:51:34 +02:00
Michael HoangandGitHub 830b3f0b50 Fix typo in Nix module (#1585) 2025-09-09 15:02:04 +00:00
Luc Perkins 55106a887e Fix typo in Nix module 2025-09-09 16:38:50 +02:00
Michael HoangandGitHub 15f067638e github-runner: fix the nodeRuntimes option (#1582) 2025-09-06 03:54:02 +00:00
Michael HoangandGitHub d7c9b35913 github-runner: add support for node24 (#1573) 2025-09-06 03:51:15 +00:00
SamandGitHub eaacfa1101 apply should return null if the argument is not a list (#1581) 2025-09-04 19:58:58 +00:00
Nathan Henrie 349b2c66a9 apply should return null if the argument is not a list
Fixes https://github.com/nix-darwin/nix-darwin/issues/1578
2025-09-04 13:34:55 -06:00
Sander 165ff3069d tests: remove placeholder package override in github-runner test 2025-08-29 13:34:15 +02:00
Sander f910ac37b6 github-runner: fix the nodeRuntimes option
The conditional override was intended to be backwards-compatible with older runner packages without the `nodeRuntimes` argument.
However, `override` doesn't yield default arguments, so the override was never applied.

This commit removes the conditional entirely since `nodeRuntimes` was added back in 24.05.
2025-08-28 12:51:30 +02:00
SamandGitHub 8df64f8196 Application 'linking' done right (#1396) 2025-08-22 01:17:29 +00:00
SamandGitHub 3a0a38a1e7 launchd+defaults: Escape XML generated by toPlist (#1529) 2025-08-21 04:49:33 +00:00
Sander 7d6644bdb6 github-runner: add support for node24 2025-08-18 16:45:51 +02:00
SamandGitHub 7220b01d67 programs/fish: add shellAbbrs config (#1563) 2025-08-15 16:23:30 +00:00
SamandGitHub f5ad8e3e76 ci: bump macOS version (13 -> 14) (#1569) 2025-08-15 15:57:17 +00:00
Sam 585cd058e8 ci: bump macOS version (13 -> 14)
The runners from macOS 14 on default to aarch64, so this will also
transition us away from x86_64
2025-08-14 20:53:51 -07:00
ElliotandSam 6f24595362 fish: add shellAbbrs config
Co-authored-by: Sam <30577766+Samasaur1@users.noreply.github.com>
2025-08-14 14:56:43 +08:00
Linnnus f0b44d6854 Add eval warning 2025-08-09 17:39:49 +02:00
Linnnus 23acc59c99 Update tests
Tests that search for specific commands in the generated activation
script obviously need updating.
2025-07-01 21:05:30 +02:00
Linnnus 66911b7d16 Remove manual escaping 2025-07-01 21:04:57 +02:00
Linnnus 423929a533 Escape XML generated by toPlist 2025-07-01 18:50:11 +02:00
SamandGitHub e04a388232 readme: bump nixpkgs stable version; update flake guide (#1521) 2025-06-30 20:05:18 +00:00
iLillie a79b28f2fa readme: update flake guide 2025-06-30 17:12:57 +02:00
iLillie b866fbb28b readme: bump nix stable version 2025-06-30 17:12:14 +02:00
SamandGitHub 425c929e20 github-runner/service.nix: fix missing argument in workDir assertion (#1526) 2025-06-30 07:55:51 +00:00
ed9w2in6 8828770125 fix: add test cases and expected output 2025-06-30 05:57:03 +08:00
ed9w2in6 44c5d10416 fix: prevent example of persistent-others from evaluating 2025-06-30 05:40:34 +08:00
ed9w2in6 5875113d74 feat: make persistent-others similar to the new persistent-apps
This is backward compatible via convertion function provided for
coercedTo.

Fixes: #968, #982, #1398
2025-06-30 05:40:34 +08:00
Tom McLaughlin 7f9694a4be github-runner/service.nix: fix missing argument in workDir assertion 2025-06-29 13:43:52 -07:00
SamandGitHub 1dd19f19e4 nix.nixPath: Do not use environment.darwinConfig if set to null (#1469) 2025-06-22 18:56:08 +00:00
EmilyandGitHub bffbd4a6c4 networking.applicationFirewall: init (#1520) 2025-06-22 18:43:41 +00:00
Sizhe Zhao f2457a22c8 systems.defaults.alf: deprecate 2025-06-23 00:46:57 +08:00
Sizhe Zhao caa59bf50a networking.applicationFirewall: init 2025-06-23 00:46:57 +08:00
SamandGitHub 04a3412801 homebrew: allow setting greedy for all casks by default (#1382) 2025-06-22 06:00:51 +00:00
Michael HoangandGitHub ff139e8183 Remove deprecated homebrew tap example (homebrew/cask-fonts) (#1515) 2025-06-22 02:18:14 +00:00
Michael Hoang be2d7d6535 applications: ensure sufficient permissions before updating apps 2025-06-21 14:54:32 +07:00
‮rekcäH nitraM‮andMichael Hoang 1f9cca7781 Copy applications instead of linking them to make macOS happy
All existing attempts fell short.
So we fall back to plain old copying applications over.

Problems with alternatives:

- Symlinking: Spotlight doesn't index symlinks. Therefore one cannot use
Spotlight to find or open the apps. Also they don't show up in
LaunchPad.

- Trampolines: Apples Security & Privacy doesn't get the concept and
shows them with the wrong name. Having an app open during an update will
also make it show up twice in the Dock.

- Aliasses: Require either AppleScript (a permission we don't want to
have, as it easily bypasses Apples TCC) or extra tools (that would be
ok), but also Aliasses are not categorized as 'Application' by
SpotLight.

- Directory Hardlinks are not supported by APFS - but also wouldn't work
cross volume.

- clonefile also doesn't work cross-volume.

Which all leads us back to Don Copine and Pastone. *sigh*
2025-06-21 14:54:32 +07:00
‮rekcäH nitraM‮andMichael Hoang 21d733a51f applications: reformat 2025-06-21 14:54:24 +07:00
Michael HoangandGitHub 0d71cbf88d programs/ssh: backport knownHosts changes (#1517) 2025-06-19 09:27:36 +00:00
Michael Hoang 82566dd254 programs/ssh: remove with lib; 2025-06-19 16:08:37 +07:00
Michael Hoangandpennae a991859d1f nixos/ssh: undeprecate knownHosts.«name».hostNames
Backport https://github.com/NixOS/nixpkgs/commit/e9f17a9f45e8466b34be1fededb70713b13d901c

Co-authored-by: pennae <github@quasiparticle.net>
2025-06-19 16:08:09 +07:00
Michael HoangandTaeer Bar-Yam 9d5b27bc93 modules/programs/ssh: knownHosts -> extraKnownHosts
Backport https://github.com/NixOS/nixpkgs/commit/8fa2e787f1400fd636983c9865ce0ef6cd3d193d

Co-authored-by: Taeer Bar-Yam <taeer@bar-yam.me>
2025-06-19 16:07:11 +07:00
Michael HoangandFlorian Klink 2d257c09a1 programs.ssh.knownHosts: update example to be an attrset
Backport https://github.com/NixOS/nixpkgs/commit/4f11c06fac92bc19b764a9248df416f20ff5ad03

Co-authored-by: Florian Klink <flokli@flokli.de>
2025-06-19 16:05:09 +07:00
Michael Hoang 04b04f4b9d programs/ssh: move to match path in NixOS 2025-06-19 10:45:32 +07:00
Garrett Hopper f67a4856c3 Update homebrew module documentation and examples
- Replace deprecated homebrew/cask-fonts with apple/apple tap example
- Update documentation links from archived homebrew-bundle to brew.sh/Brew-Bundle-and-Brewfile
- Update source file references to new location in main brew repository
2025-06-17 05:52:35 -05:00
SamandGitHub 2f140d6ac8 Preserve PATH variable when using sudo for Homebrew (#1503) 2025-06-14 04:00:26 +00:00
Brian Romanko 0721726e21 Wrap the call with env 2025-06-13 16:49:58 -07:00
Brian Romanko 300af6fcc5 Preserve PATH variable when using sudo
Some systems set `secure_path` in sudoers. When this is set
the `PATH` variable is not set in the sudo environment. Using
`--preserve-env=PATH` ensures that the PATH env var is set properly
in those systems.

This is similar to the issue with [darwin-rebuild](https://github.com/nix-darwin/nix-darwin/issues/798)
not working with sudo on these systems.
2025-06-13 16:49:57 -07:00
EmilyandGitHub 72c88d5928 Avoid confusing users with future deprecations (#1499) 2025-06-12 14:47:19 +00:00
SamandGitHub e2da3338ab etc: add known hashes for zprofile and zshrc in macOS 26 beta 1 (#1510) 2025-06-12 06:51:43 +00:00
Sam 63c31af37a etc: add known hashes for zprofile and zshrc in macOS 26 beta 1
This also includes versions of /etc/zshrc with both the official and
DeterminateSystems installers.
2025-06-11 01:43:35 -07:00
SamandGitHub 19346808c4 programs/direnv: fix silent option (#1491) 2025-06-06 07:19:53 +00:00
Duc Nghiem-Xuan daf8e22831 programs/direnv: add finalPackage readonly option 2025-06-06 15:49:37 +09:00
SamandGitHub 9753a8706b feat: add option programs.zsh.enableAutosuggestions (#1433) 2025-06-06 06:02:11 +00:00
Duc Nghiem-Xuan fb27326bbc programs/direnv: fix silent option 2025-06-05 17:49:17 +09:00
SamandGitHub fa6120c32f defaults: support AppleKeyboardUIMode = 2 for newer macOS versions (#1501) 2025-06-04 04:52:25 +00:00
Michael Hoang f6b29e4af8 defaults: support AppleKeyboardUIMode = 2 for newer macOS versions 2025-06-04 11:02:16 +10:00
Michael HoangandGitHub d46a07214f Fix ShellCheck escaped character issue in nixPath check (#1500) 2025-06-04 00:56:23 +00:00
Ethan Turkeltaub b07a4c8be5 Fix ShellCheck issue in nixPath check 2025-06-03 16:19:03 -04:00
Adam C. Stephens 7c284a6504 Avoid confusing users with future deprecations 2025-06-02 09:55:31 -04:00
EmilyandGitHub 44a7d0e687 darwin-rebuild: use NIX_REMOTE=daemon even as root (#1458) 2025-05-27 13:33:47 +00:00
Michael HoangandGitHub a9939228f6 config/system-path: restructure to mirror NixOS (#1481) 2025-05-25 05:00:28 +00:00
Michael HoangandGitHub 9f609d1d9f ci: enable merge queue (#1482) 2025-05-25 04:31:32 +00:00
Michael Hoang 0d3dcc55f3 ci: enable merge queue 2025-05-25 14:14:52 +10:00
Michael Hoang cd6a8a796d config/system-path: restructure to mirror NixOS
https://github.com/NixOS/nixpkgs/blob/2795c506fe8fb7b03c36ccb51f75b6df0ab2553f/nixos/modules/config/system-path.nix
2025-05-25 14:06:56 +10:00
Michael HoangandGitHub e0a7c37735 config/terminfo: init module (#1479) 2025-05-25 09:50:52 +10:00
Michael Hoang 5374405a01 config/terminfo: init module 2025-05-25 09:24:12 +10:00
Michael HoangandGitHub acd6aa5a90 programs/arqbackup: init module (#1474) 2025-05-24 15:40:10 +10:00
Michael Hoang 7347f72507 programs/arqbackup: init module 2025-05-24 15:16:24 +10:00
Robert Hensing 30845beee0 nix.nixPath: Do not use environment.darwinConfig if set to null
I've personally set it to `null` to make my `system.primaryUser = null;`
configuration work on a machine with `stateVersion = 4;`.

It may apply in other use cases as well.
2025-05-23 16:51:36 +02:00
EmilyandGitHub 33220d4791 system.build: Treat as variables, make lazy, fix error message (#1468) 2025-05-23 13:44:11 +01:00
Robert Hensing acf6b46011 system.build: Treat as variables, make lazy
This fixes an unnecessary evaluation dependency that prevented the
custom and much appreciated primaryUser error from popping up.

Specifically:

       … while evaluating the option `system.build':

       … while evaluating definitions from `/nix/store/lc6n4bhxj9255kzfn9pnpx65583a8cgc-source/modules/environment':

       … while evaluating definitions from `/nix/store/lc6n4bhxj9255kzfn9pnpx65583a8cgc-source/modules/nix':

       … while evaluating the option `environment.darwinConfig':

       … while evaluating the option `system.primaryUserHome':

       error: expected a string but found null: null
       at /nix/store/lc6n4bhxj9255kzfn9pnpx65583a8cgc-source/modules/system/primary-user.nix:26:30:
           25|       default =
           26|         config.users.users.${config.system.primaryUser}.home or "/Users/${config.system.primaryUser}";
             |                              ^
           27|     };

While it did have some indication as to the cause, it lets the good
error message go to waste.

**Context**

`lazyAttrsOf` is the better choice when you use an attrset as individual
variables instead of in aggregate (e.g. `attrNames`, `toJSON`).

The reason is that an expression like `a.b` is strict in `a`, which
entails the evaluating the _whole_ set of attribute _names_ in `a`.
In the `attrsOf` this means evaluating all `mkIf` conditions, which
in turn also means evaluating all the regular definitions to the
smallest degree (WHNF) to determine that they're not `mkIf`s.

`lazyAttrsOf` simply assumes that all attributes aren't `mkIf false`,
and throws an error in the attribute value if necessary.
This would be a problem with `toJSON` and such, but is completely
fine when the attributes are treated as variables of a lazy program,
as is the case here.

**NixOS**

NixOS made `system.build` a submodule with a `freeformType`, allowing
the things inside of it to be declared, and for them to have niceties
like documentation and merging behavior.
nix-darwin could probably adopt this.
2025-05-23 12:00:51 +02:00
Michael HoangandGitHub 93562b65cf feat(services.openssh): add extraConfig option (#1465) 2025-05-23 01:41:14 +00:00
squat 0e3b855456 add test
Signed-off-by: squat <lserven@gmail.com>
2025-05-23 02:58:23 +02:00
squat e09c1aefe4 feat(services.openssh): add extraConfig option
Same interface as in NixOS: https://search.nixos.org/options?channel=unstable&show=services.openssh.extraConfig&from=0&size=50&sort=relevance&type=packages&query=services.openssh.extraConfig
This is useful to customize the behavior of the SSH daemon, e.g. to add
options like `StreamLocalBindUnlink yes` to improve gpg-agent
forwarding.

Signed-off-by: squat <lserven@gmail.com>
2025-05-22 20:22:47 +02:00
Michael HoangandGitHub e2676937fa flake.lock: update (#1463) 2025-05-21 09:36:44 +00:00
Emily 0b5fee1285 flake.lock: update
Should fix the website build.
2025-05-21 10:05:49 +01:00
EmilyandGitHub 9ed53ae9ab version: bump to 25.11 (#1449) 2025-05-20 15:45:13 +01:00
Emily d23a9c26f3 darwin-rebuild: use NIX_REMOTE=daemon even as root 2025-05-19 18:26:49 +01:00
Michael HoangandGitHub b9b927dd1f Update repo links (#1450) 2025-05-18 08:45:43 +10:00
Siddhartha SahuandGitHub 24952f03f9 Update default.nix 2025-05-17 12:15:49 -04:00
Siddhartha SahuandGitHub 58f268e065 Update CHANGELOG 2025-05-17 12:15:18 -04:00
Siddhartha SahuandGitHub a4cc54778d Update repo link 2025-05-17 12:14:14 -04:00
Emily 0c0f423db8 version: bump to 25.11 2025-05-17 16:06:23 +01:00
EmilyandGitHub 8e251e4534 The Plan, phase 1 (#1341) 2025-05-17 16:02:22 +01:00
Emily b9e580c113 changelog: document user activation removal 2025-05-16 16:34:31 +01:00
Emily a0e4dd2af9 activation-scripts: move createRun after checks
The checks should no longer depend on `/run`, so this avoids modifying
the system before they run.
2025-05-16 16:34:31 +01:00
Emily 7e5c6f7e21 etc: merge etcChecks into checks
The `activate-system` daemon will now run all the checks, which seems
like probably a good idea anyway?
2025-05-16 16:34:31 +01:00
Emily af62c4d176 checks: make nixPath check more helpful 2025-05-16 16:34:31 +01:00
Emily 051283a895 {activation-scripts,activate-system}: purify environment again 2025-05-16 16:34:31 +01:00
Emily 516dbe1fa4 darwin-rebuild: require running as root 2025-05-16 16:34:31 +01:00
Emily 40d2a159cc tests: remove stray activate-user references 2025-05-16 16:34:31 +01:00
Emily 2ca294741f activation-scripts: get rid of user activation
🎉

Closes: #96
2025-05-16 16:34:31 +01:00
Emily 0abf012666 users: refuse to delete the primary user 2025-05-16 16:31:17 +01:00
Emily bed70a84af {environment,nix}: remove references to $HOME
These can’t be relied upon in a post‐user‐activation
world. Technically a breaking change, if anyone has their home
directory outside of `/Users` or is using `root` for this, but, well,
I did my best and these are legacy defaults anyway.
2025-05-16 16:31:17 +01:00
Emily 2892da83ea applications: use system.primaryUser for the legacy path
System activation scripts shouldn’t (and soon won’t be able to)
rely on `$HOME` being the primary user’s.
2025-05-16 16:31:17 +01:00
Emily f47b8062cb defaults: move userDefaults to system activation 2025-05-16 16:31:17 +01:00
Emily 7877cba5f5 launchd: move userLaunchd to system activation
I’m not *completely* certain that this handles user agents
correctly. There is a deprecated command, `launchctl asuser`, that
executes a command in the Mach bootstrap context of another user`.
<https://scriptingosx.com/2020/08/running-a-command-as-another-user/>
claims that this is required when loading and unloading user agents,
but I haven’t tested this. Our current launchd agent logic is pretty
weird and broken already anyway, so unless this actively regresses
things I’d lean towards keeping it like this until we can move
over entirely to `launchctl bootstrap`/`launchctl kickstart`, which
aren’t deprecated and can address individual users directly. Someone
should definitely test it more extensively than I have, though.
2025-05-16 16:29:17 +01:00
Emily c449918bfb homebrew: move to system activation
This adds an optional explicit `homebrew.user` option that allows users
to avoid setting `system.primaryUser`, partly as a proof of concept
of what the interfaces should look like in the future. Homebrew only
officially support one global installation, so a singleton matches
upstream’s expectations; in practice, it may be useful for us to
nest this into `users.users.*.homebrew` instead, at the expense of
being an unsupported setup if used to its full potential. Since
that would be a breaking change to the inteface anyway, I think
adding `homebrew.user` for now is acceptable. (I think one native
Apple Silicon and one Rosetta 2 Homebrew installation – under
`/opt/homebrew` and `/usr/local` respectively – may be exceptions
to this lack of upstream support, but that would be complicated to
support even with `users.users.*.homebrew`.)

I’m not entirely sure where in system activation this should
go. Probably after the user defaults and launch agents stuff, to match
the existing logic in user activation, and I lean towards doing it
as late as possible; too early and we might not have the users and
groups required to bootstrap a Homebrew installation set up, but
as Homebrew installations could be fiddly and fail, doing it in the
middle could leave a partially‐activated system.

Probably it should be done in a launch agent or something instead, but
this is my best guess as to the appropriate place for now. The downside
is that activation scripts generally won’t be able to assume that the
Homebrew prefix is populated according to the current configuration,
but they probably shouldn’t be depending on that anyway?
2025-05-16 16:29:17 +01:00
Emily 52ee8c57c2 primary-user: init 2025-05-16 16:29:17 +01:00
Michael HoangandGitHub 8817b00b00 defaults: add com.apple.iCal for managing Calendar.app (#1446) 2025-05-16 13:12:40 +10:00
Michael Hoang 14737a9676 defaults: add com.apple.iCal for managing Calendar.app 2025-05-16 12:52:49 +10:00
Michael HoangandGitHub b6fff20c69 defaults: update docs for AppleInterfaceStyle (#1445) 2025-05-15 18:28:21 +10:00
Michael Hoang d693997a32 defaults: update docs for AppleInterfaceStyle
Eventually we should implement a special type that allows deleting
values.
2025-05-15 18:02:47 +10:00
Michael HoangandGitHub f0fbf2dbe7 _1password{,-gui}: fix package not being used (#1444) 2025-05-15 17:29:56 +10:00
Michael Hoang f2753a4ca6 _1password{,-gui}: fix package not being used 2025-05-15 17:01:26 +10:00
Michael HoangandGitHub f88be00227 Merge pull request #1442 from lheckemann/gitlab-runner-fix
gitlab-runner: write config as toml, don't clobber existing file
2025-05-13 22:20:02 +10:00
SamandGitHub d642c98560 Merge pull request #1439 from dermetfan/buildkite-multi-tags 2025-05-12 10:07:22 -07:00
Linus Heckemann 4cabc9c286 gitlab-runner: write config as toml, don't clobber existing file
The previous command would fail because of datetimes not being
representable as JSON, wiping the config entirely because of the
`sponge` invocation that doesn't care whether the program piped in
fails.
2025-05-12 13:17:31 +02:00
Robin Stumm 846444354b services/buildkite-agents: support multi-tags 2025-05-12 12:59:13 +02:00
Michael HoangandGitHub 6cb36e8327 Merge pull request #1438 from Enzime/push-qztkxuoksrpv
programs/_1password{,-gui}: init modules
2025-05-08 22:50:54 +10:00
Michael Hoang c36b57f219 programs/_1password-gui: init module 2025-05-08 20:17:13 +10:00
Michael Hoang 24c2d2bab7 programs/_1password: init module 2025-05-08 20:16:50 +10:00
Michael HoangandGitHub 760a11c870 Merge pull request #1432 from WHForks/replacevars
nix-tools: use replaceVarsWith
2025-05-03 16:49:02 +10:00
ed9w2in6 0e83fc6e76 feat: add option programs.zsh.enableAutosuggestions
We got enableSyntaxHighlighting, so why not enableAutosuggestions too?

Ref: #527
2025-05-01 23:31:51 +08:00
WeetHet a6d73d0904 nix-tools: use replaceVarsWith 2025-05-01 18:24:30 +03:00
Michael HoangandGitHub 4515dacafb Merge pull request #1425 from Enzime/push-luyktrtqqskl
networking: allow users to override FQDN
2025-04-28 14:58:41 +10:00
Michael Hoang 9603417da1 networking: allow users to override FQDN
Backport of https://github.com/NixOS/nixpkgs/pull/391522
2025-04-28 14:22:30 +10:00
Michael HoangandGitHub 43975d782b Merge pull request #1423 from Enzime/push-kpkrwzkroylt
networking: backport `domain`, `fqdn` and `fqdnOrHostName` options
2025-04-12 19:29:39 +02:00
Michael Hoang 751a96bc1f networking: backport domain, fqdn and fqdnOrHostName options
https://github.com/NixOS/nixpkgs/blob/f675531bc7e6657c10a18b565cfebd8aa9e24c14/nixos/modules/tasks/network-interfaces.nix#L580-L618
2025-04-12 19:11:10 +02:00
Michael HoangandGitHub 113883e37d Merge pull request #1388 from ivankovnatsky/master
services/netdata: add cacheDir option
2025-04-09 20:44:32 +02:00
Michael HoangandGitHub 73d59580d0 Merge pull request #1400 from dwt/linux-builder-working-directory
Linux builder: working directory rename and cleanup
2025-04-01 17:36:52 +09:00
Michael Hoang 1b8d711826 linux-builder: format 2025-04-01 17:09:49 +09:00
‮rekcäH nitraM‮andMichael Hoang b8939c4fe4 linux-builder: remove /nix/store external directory when disabled
When /nix/store internal directories get renamed, they just don't get
into the next version of your system closure and are thus no problem to
rename. But state in the system is a problem, as there is no process to
remov eit. Thus we need to do it ourselves.
2025-04-01 17:09:19 +09:00
‮rekcäH nitraM‮andMichael Hoang a175c68f3f linux-builder: upgrade working directory
The working directory was still using an old name of the project, which
made it uneccessary hard to understand why that directory was used
exactly.
2025-04-01 17:07:02 +09:00
Michael HoangandGitHub eaff8219d6 Merge pull request #1410 from Enzime/push-kklymxxksrnp
nix-tools: re‐add `nixPackage`
2025-03-31 00:54:11 +09:00
EmilyandMichael Hoang e7bd2f8f2f nix-tools: re‐add nixPackage
(With some tweaks to handle `nix.enable` and order it at a more
sensible position in the `$PATH`.)

The installers actually install Nix into `root`’s profile for some
reason, which means that the path’s prioritization backfires when
the script runs as root and we’re managing the Nix installation. When
running `darwin-rebuild` as a normal user, this wasn’t a problem.

Maybe we should just have a check to make sure there’s no conflicting
Nix in `root`’s profile – it seems pretty bad for `root` to
get the wrong Nix – but it would trigger for almost everyone,
which seems kind of annoying. I guess we could automatically
remove it from `root`’s profile if it matches what’s in
`/nix/var/nix/profiles/default`…

This reverts commit 02232f71c5.
2025-03-31 00:34:55 +09:00
EmilyandGitHub 53d0f0ed11 Merge pull request #1407 from emilazy/push-xktutyxmrvks
website: try to fix
2025-03-29 04:17:53 +00:00
Emily 75a7fb885d website: try to fix redirect
It seems like the `#readme` is getting stripped after load, maybe
because of the `?tab=…` stuff. Hoping this will fix it.
2025-03-29 04:13:33 +00:00
Emily 516590cf12 website: fix manual path 2025-03-29 04:13:00 +00:00
EmilyandGitHub feb64b5364 Merge pull request #1406 from emilazy/push-nwzyqrynuvyo
ci: deploy the website from GitHub Actions
2025-03-29 04:10:02 +00:00
Emily 2c77fdbfba ci: deploy the website from GitHub Actions 2025-03-28 19:44:24 +00:00
Emily a5af2a5b22 readme: use logo from GitHub attachments
Avoids churn for now while moving around site stuff.
2025-03-28 17:05:16 +00:00
Michael HoangandGitHub 75f8e4dbc5 Merge pull request #1403 from emilazy/push-wqyxrrzkzovy
treewide: point to the new GitHub organization
2025-03-28 10:27:21 +09:00
Emily ce5a3b9db9 treewide: point to the new GitHub organization 2025-03-27 17:07:57 +00:00
Emily 000c40f4fe readme: update contact information 2025-03-27 17:07:57 +00:00
Michael HoangandGitHub bb81755a36 Merge pull request #920 from hiroqn/master
Expose `extendModules` attr
2025-03-25 11:27:55 +09:00
hiroqn 2c563bd049 expose extendModules 2025-03-25 11:00:38 +09:00
EmilyandGitHub ebb88c3428 Merge pull request #1374 from dwt/fix-docs
Docs: Fix wrong reference to systemd
2025-03-23 14:58:55 +00:00
‮rekcäH nitraM‮ fe728cfb5a autossh: Fix incorrect reference to systemd
Darwin has LaunchD.
2025-03-23 08:39:49 +01:00
EmilyandGitHub e9f41de2a8 Merge pull request #1375 from dwt/fix-docs-2
Docs: Fix references to NixOS
2025-03-21 22:10:55 +00:00
Michael HoangandGitHub 2d9b633169 Merge pull request #1331 from isabelroses/tools
feat: system tools can be configured individually
2025-03-19 17:35:36 +09:00
Ivan Kovnatsky 5417dfd58c services/netdata: add cacheDir option
For me netdata could not start:

```logs
time=2025-03-18T21:27:21.023+02:00 comm=netdata source=daemon level=info errno="2, No such file or directory" tid=257369  msg="CONFIG: cannot load cloud config '/var/lib/netdata/cloud.d/cloud.conf'. Running with internal defaults."
time=2025-03-18T21:27:21.024+02:00 comm=netdata source=daemon level=alert errno="2, No such file or directory" tid=257369  msg="Cannot create required directory '/var/cache/netdata'"
0   netdata                             0x0000000104845cb0 netdata_logger_fatal + 356
1   netdata                             0x00000001044d8734 verify_or_create_required_directory + 84
2   netdata                             0x00000001044d718c set_global_environment + 524
3   netdata                             0x00000001044db294 netdata_main + 1920
4   netdata                             0x00000001044dd178 main + 12
5   dyld                                0x0000000184394274 start + 2840
```
2025-03-18 22:13:30 +02:00
Michael HoangandGitHub 95eac71bf5 Merge pull request #1386 from Enzime/push-lnuotyxsytkz
Back out "github-runner: replace `mkdir -p -m` with `umask`"
2025-03-17 07:58:43 +09:00
Michael Hoang 7b4a4951dc Back out "github-runner: replace mkdir -p -m with umask"
This backs out commit 3b738c765d.

Setting a `umask` made the parent directory have too conservative of
permissions making it so `_github-runner` couldn't access the child
directories.
2025-03-16 19:31:31 +09:00
isabel 9951b44d5b nix-darwin: system tools can be configured indvidually 2025-03-15 09:24:22 +00:00
Michael HoangandGitHub 9175b4bb5f Merge pull request #1377 from zhaofengli/fix-custom-user-preferences-merging
Fix merging of system.defaults.CustomUserPreferences
2025-03-15 13:46:20 +09:00
Zhaofeng Li 814b503899 Fix merging of system.defaults.CustomUserPreferences 2025-03-14 12:00:17 -06:00
Michael HoangandGitHub 4d8a451649 Merge pull request #1355 from toodeluna/fix/profile-name
fix: use correct username for profile
2025-03-14 07:46:59 +09:00
Michael HoangandGitHub 2fb6b09b67 Merge pull request #1089 from niklasravnsborg/fix-modules-commands
Update nextdns to use `command`
2025-03-13 00:47:09 +09:00
Niklas Ravnsborg feecfd97cd update nextdns to use command instead of serviceConfig.ProgramArguments 2025-03-12 15:52:45 +01:00
Varun Narravula e2361f4496 homebrew: allow setting greedy for all casks by default 2025-03-11 01:23:51 -07:00
Luna Heyman 9ddb2e6ca7 fix: use correct username for profile 2025-03-10 19:55:24 +01:00
‮rekcäH nitraM‮ d97323bc60 Docs: Fix references to NixOS
This option applies to nix-darwin.
2025-03-06 16:24:46 +01:00
Michael HoangandGitHub adf5c88ba1 Merge pull request #1367 from Enzime/push-wmqtrnkuqvrt
readme: update instructions as Determinate Nix is now the default
2025-03-06 11:45:00 +09:00
Michael Hoang df599ea8f1 readme: update instructions as Determinate Nix is now the default 2025-03-05 11:25:30 +09:00
EmilyandGitHub 991bb2f6d4 Merge pull request #1362 from stepbrobd/master
homebrew: remove `--no-lock` flag
2025-03-04 18:17:28 +00:00
Yifei Sun d06cf700ee homebrew: remove --no-lock flag
https://github.com/Homebrew/homebrew-bundle/pull/1630
2025-03-04 12:09:11 -05:00
Michael HoangandGitHub 4a0bddd498 Merge pull request #1359 from amarshall/fix-dnscrypt-proxy-alias
services/dnscrypt-proxy: Fix use of pkg alias
2025-03-04 08:13:50 +09:00
Andrew Marshall fdc512d107 services/dnscrypt-proxy: Fix use of pkg alias
`dnscrypt-proxy2` is just an alias for `dnscrypt-proxy`. Use that and
avoid eval failures when Nixpkgs is configured with `allowAliases =
false`.
2025-03-03 08:13:33 -05:00
Michael HoangandGitHub 5d6e0851b6 Merge pull request #1343 from r17x/feat/dnscrypt-proxy
services/dnscrypt-proxy: init
2025-02-28 22:15:25 +07:00
r17x 7386d8878e services/dnscrypt-proxy: init 2025-02-28 19:58:19 +07:00
Michael HoangandGitHub 665cc04a60 Merge pull request #1216 from Coosis/master
Add `pam-watchid` authentication to `sudo` command
2025-02-27 13:09:12 +07:00
EmilyandGitHub 31631ea68f Merge pull request #1353 from booxter/revert-939-networking_hosts
Revert "Add networking.hosts and .hostFiles from nixos "
2025-02-26 23:50:21 +00:00
Ihar Hrachyshka b1db30ce36 networking: Restore the original /etc/hosts on activation
A patch that replaced the original file with a symlink to nix store was
reverted because MacOS Network framework doesn't support symlinks for
the file.

The revert leaves the system without any /etc/hosts file at all though.
To fix this, an activation step is added to restore the original file
from .before-nix-darwin backup, if it exists.

Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
2025-02-26 16:52:13 -05:00
Ihar HrachyshkaandGitHub 1d9f622484 Revert "Add networking.hosts and .hostFiles from nixos " 2025-02-26 09:24:15 -05:00
Coosis 727119f8c7 pam: add pam_watchid support 2025-02-25 23:51:30 +08:00
Michael HoangandGitHub 42be12b510 Merge pull request #1344 from Mic92/fix_pam_module
fix: move `pam` configuration to `sudo_local`
2025-02-25 10:06:11 +07:00
Michael HoangandGitHub 59efa72d69 Merge pull request #939 from ibizaman/networking_hosts
Add networking.hosts and .hostFiles from nixos
2025-02-25 09:54:13 +07:00
Michael HoangandAndrew Lubawy 11ea44f3e2 pam: add pam_reattach support
Co-Authored-By: Andrew Lubawy <andrew@andrewlubawy.com>
2025-02-25 09:47:28 +07:00
Michael HoangandAndrew Lubawy 47f263077e pam: switch to using sudo_local file
Co-Authored-By: Andrew Lubawy <andrew@andrewlubawy.com>
2025-02-25 09:47:28 +07:00
ibizaman bde9fa6f64 add networking.hosts and .hostFiles from nixos 2025-02-24 08:57:05 +01:00
Michael Hoang c9c2d40f71 pam: remove with lib; 2025-02-20 17:46:49 +07:00
EmilyandGitHub 6ab392f626 Merge pull request #1187 from khaneliman/spacer
dock: allow setting spacer tiles
2025-02-19 02:57:52 +00:00
Austin Horstman e21d07988b dock: refactor persistent-apps option 2025-02-17 13:12:40 -06:00
Austin Horstman 02ba211ea1 dock: allow setting tile-types
You can create spacer tiles in the dock by passing empty tile-data with
specific tile-types
2025-02-16 19:26:43 -06:00
EmilyandGitHub 678b22642a Merge pull request #1332 from emilazy/push-vyxwvkuuvvvw
treewide: add checks for `nix.enable`
2025-02-14 15:50:17 +00:00
Michael HoangandGitHub 7206892913 Merge pull request #1337 from sandydoo/fix-extra-nix-conf
nix: place `extra-`prefixed settings after their non-prefixed variants
2025-02-14 21:15:10 +07:00
Sander 5926058aec nix: place extra-prefixed settings after their non-prefixed variants
Fixes #626.

Essentially a copy of NixOS's workaround: https://github.com/NixOS/nixpkgs/pull/278064
2025-02-14 16:33:12 +04:00
Emily 731910af01 {activation-scripts,activate-system}: check gcroots before linking
When `nix.enable` is off, we don’t necessarily have an active
Nix installation, so there won’t necessarily be an active
`/nix/var/nix/gcroots` directory to link things into. NixOS just skips
this unconditionally when `nix.enable` is off, but that doesn’t
work well with a context in which we usually expect `nix.enable`
to be coupled with an unmanaged system installation of Nix.
2025-02-11 20:10:55 +00:00
Emily cd445c5465 nix: catch reads of unmanaged defaults
When we’re not managing the Nix installation, these defaults
aren’t used out of the box and won’t accurately represent the
state of any unmanaged Nix or the desired Nix package, so reading
the option defaults is a bug.

This was previously a warning for `nix.package` and a silent failure
for all the others. Now that all the problematic accesses in nix-darwin
have been appropriately conditionalized, and since a throw gives a
backtrace where a warning doesn’t, give throwing defaults to all the
`nix.*` options that don’t reflect reality and that that modules
shouldn’t be reading when `nix.enable` is off.

I’m not in love with the implementation strategy here… ideally
we’d think of something better than this and then upstream it to
NixOS. `nix.nrBuildUsers` growing a fake default that is never used
is particularly unfortunate. But this should hopefully catch mistakes
in module code reasonably reliably.
2025-02-11 20:10:55 +00:00
Emily d677e3e844 nix-tools: only pass config.nix.nixPath through if nix.enable 2025-02-11 20:10:55 +00:00
Emily 42e16f31c6 cachix-agent: check for nix.enable 2025-02-11 20:10:55 +00:00
Emily e3bde1588b github-runner: check for nix.enable 2025-02-11 20:10:55 +00:00
Emily f4e2805e19 ofborg: check for nix.enable 2025-02-11 20:10:55 +00:00
Emily aba0c60eba lorri: check for nix.enable 2025-02-11 20:10:55 +00:00
Emily 57c93ffe6c hercules-ci-agent: check for nix.enable 2025-02-11 20:10:55 +00:00
Emily 147ed950e3 nixpkgs-flake: check for nix.enable 2025-02-11 20:10:55 +00:00
Emily 7cca8f95f7 linux-builder: check for nix.enable 2025-02-11 20:10:55 +00:00
Emily 0176a5082b nix-optimise: check for nix.enable
This was added to Nixpkgs in eb8b70c020e6693b29634660fa173d7f14f882eb.
2025-02-11 20:10:55 +00:00
Emily fc9367a9ec nix-gc: check for nix.enable
This was added to Nixpkgs in eb8b70c020e6693b29634660fa173d7f14f882eb.
2025-02-11 20:10:55 +00:00
EmilyandGitHub a6746213b1 Merge pull request #1313 from emilazy/push-tzwxwyvonslk
nix: add `nix.enable` option to disable Nix management
2025-02-11 19:30:41 +00:00
EmilyandGitHub a36049dac5 Merge pull request #1329 from emilazy/push-nlxwnqymuupk
homebrew: use `mas` from Nixpkgs
2025-02-10 23:20:29 +00:00
EmilyandGitHub 0b6f96a6b9 Merge pull request #1322 from emilazy/push-trvmqywuwnop
Revert "nixpkgs: make config.nixpkgs.{buildPlatform,hostPlatform} write only"
2025-02-08 17:03:44 +00:00
Emily c31b6e8a03 homebrew: use mas from Nixpkgs
Currently, setting `homebrew.masApps` causes `"mas"` to automatically
be added to `homebrew.brews`. Users who want to use Homebrew only
for managing App Store apps and casks, like me, can override this
by setting `homebrew.brews = lib.mkForce [ ];` and adding Nixpkgs’
`mas` to their `environment.systemPackages`.

When the activation script path no longer depends on the built
configuration’s `environment.systemPackages`, this will no longer
work. Since this was originally added before `mas` was packaged in
Nixpkgs and we now have a perfectly serviceable binary package,
we can add it to the `$PATH` when invoking Homebrew and skip the
automatic formula installation.

As the Homebrew `bin` directory still comes first, users who
specifically want the formula can restore the previous behaviour by
explicitly adding `"mas"` to `homebrew.brews`.

Closes: #1314
2025-02-08 16:18:38 +00:00
EmilyandGitHub 3f4351d233 Merge pull request #1327 from emilazy/push-vunnqlmqnzts
checks: fix macOS version check exit code
2025-02-08 14:32:00 +00:00
Michael HoangandGitHub 30b6672aee Merge pull request #1320 from emilazy/push-vykszlnztmtt
users: use `launchctl managername` to determine session type
2025-02-08 19:34:41 +07:00
Emily a2e44a84be changelog: document changes to Nix installation management 2025-02-07 20:08:26 +00:00
Emily 00a8cb30fa readme: update information about Determinate 2025-02-07 20:08:26 +00:00
Emily 03877755e9 checks: add check for Determinate
This provides a more useful error message than the `/etc/nix/nix.conf`
hash mismatch error that would otherwise occur.
2025-02-07 20:08:26 +00:00
Emily fb2bc03f92 activation-scripts: add unmanaged system Nix to activation path
Currently, the `bin` directory of the configured system
is embedded in the `$PATH` of activation scripts, but not
other elements of the default `environment.systemPath` like
`/nix/var/nix/profiles/default/bin` or `/usr/local/bin`. This
means that when nix-darwin is not managing the Nix installation,
activation scripts like Home Manager’s that want to look up the
system‐managed Nix can’t find it. Search for it on the entire
`environment.systemPath` and add the appropriate directory if found.

We leave the launchd `activate-system` daemon alone, because it has
erroneously referred to `@out@/sw/bin` forever and therefore never got
a Nix on the path to begin with. That’s a problem for another time.

(The more ideal solution is probably for Home Manager activation to
be driven by launchd or something, but that’s a longer‐term goal.)
2025-02-07 20:08:26 +00:00
Emily 8a94b5b99b nix-daemon: remove services.nix-daemon.enable
We now manage the launchd daemon unconditionally when we manage the
Nix installation.
2025-02-07 19:44:59 +00:00
Emily adc989f7ec nix: remove nix.configureBuildUsers
We now manage the build users unconditionally when we manage the
Nix installation.
2025-02-07 19:44:59 +00:00
Emily c796587d2e nix: remove nix.useDaemon
We now assume the daemon is used unconditionally when we manage the
Nix installation.

The `nix.gc` and `nix.optimise` services lose their `$NIX_REMOTE`
setting rather than making it unconditional, as the NixOS `nix.gc`
module does not set it. Possibly it should, but I think uniformity
between the two systems is better than diverging, even though I kind
of hate that the non‐daemon method of access is even a thing.
2025-02-07 19:44:59 +00:00
Emily e182d8dff6 nix: add nix.enable option to disable Nix management
This is an equivalent of the `nix.enable` option from NixOS
and Home Manager. On NixOS, it mostly serves to allow building
fixed‐configuration systems without any Nix installation at
all. It should work for that purpose with nix-darwin too, and the
implementation is largely the same, but the main use case is more
similar to the Home Manager option: to allow the use of nix-darwin
with an unmanaged system installation of Nix, including when there
is another service expecting to manage it, as with Determinate.

By providing an escape hatch to opt out of Nix management entirely,
this will also allow us to consolidate and simplify our existing Nix
installation management, by being more opinionated about things like
taking ownership of the daemon and the build users. Porting one option
from NixOS lets us drop two that only ever existed in nix-darwin and
reduce overall complexity.
2025-02-07 19:44:59 +00:00
Emily d634e28f67 users: use launchctl managername to determine session type
Seems like this should be more robust, and it will work even
after the activation script purifies its environment. Apparently
it may treat `tmux` sessions like SSH ones, which may have
something to do with `reattach-to-user-namespace`/`pam_reattach`; see
<https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/issues/78#issuecomment-1074543831>.
(My hope is that `pam_reattach` does the right thing here, but I
haven’t tested.)
2025-02-07 18:03:36 +00:00
Emily 0824c13801 checks: fix macOS version check exit code 2025-02-06 22:57:32 +00:00
Emily da3311397a Revert "nixpkgs: make config.nixpkgs.{buildPlatform,hostPlatform} write only"
This was reverted upstream in 0b47fba23078cc01251b136c7af0127abd57112b.

This reverts commit 7c72c013b1.
2025-02-05 22:06:04 +00:00
Emily 3f6f512406 users: fix typo 2025-02-05 15:14:33 +00:00
Emily 9b9c9a57b6 nix: don’t set $NIX_REMOTE
NixOS doesn’t bother doing this, and Nix already matches this
conditional behaviour when `$NIX_REMOTE` is unset.
2025-02-05 15:14:04 +00:00
Emily 8f227c405e nix: fix typo in assertion conditional 2025-02-05 15:14:04 +00:00
Emily 1f7ed1c7fe checks: remove nixChannels check
I don’t think this is very important given the `nixPath` check,
and it doesn’t fit very well into a post‐user‐activation world.
2025-02-05 15:14:04 +00:00
Michael HoangandGitHub ae406c0457 Merge pull request #1318 from emilazy/push-tmtstvpkwkow
nixpkgs: backports from upstream
2025-02-05 18:26:27 +10:00
EmilyandWolfgang Walther 7c72c013b1 nixpkgs: make config.nixpkgs.{buildPlatform,hostPlatform} write only
The description for options.nixpkgs.system already hints at this:

  Neither ${opt.system} nor any other option in nixpkgs.* is meant
  to be read by modules and configurations.
  Use pkgs.stdenv.hostPlatform instead.

We can support this goal by not elaborating the systems anymore, forcing
users to go via pkgs.stdenv.

This will prevent problems when making the top-level package sets
composable in the next commit. For this to work, you should pass a fully
elaborated system to nixpkgs' localSystem or crossSystem options.

Backport of Nixpkgs commit 0a19371146130c0e2a402fd0c35f8283b0e81910.

Co-authored-by: Wolfgang Walther <walther@technowledgy.de>
2025-02-03 20:54:01 +00:00
Emily 5084b33265 git-blame-ignore-revs: add nixpkgs module formatting commit 2025-02-03 20:54:01 +00:00
Emily dc1c716ded nixpkgs: format with nixfmt 2025-02-03 20:44:32 +00:00
EmilyandMatt Sturgeon 80eddf2bf7 nixpkgs: show definition files in config assertion
Backport of Nixpkgs commit 6d9dfef94ffd59a327573eea7bc709a84c44b3d2.

Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
2025-02-03 20:44:32 +00:00
EmilyandMatt Sturgeon e84e84a256 nixpkgs: fix config assertion text
The assertion message should include the `nixpkgs.config` value, however
it currently includes the entire `nixpkgs.config` _option_.

This means the type, declarations, definitions, etc were all printed.

Backport of Nixpkgs commit 1bd4da1848cb7b68858ebb2ca1f8b0e5fed46c58.

Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
2025-02-03 20:44:32 +00:00
EmilyandFelix Buehler bd1d46766a nixpkgs: remove with lib;
Backport of Nixpkgs commit 609e57485d1fa111e3a689498d9d338dc03a7bc5.

Co-authored-by: Felix Buehler <account@buehler.rocks>
2025-02-03 20:44:32 +00:00
320bf025d2 nixpkgs: link to Nixpkgs manual for global configuration options
Backport of Nixpkgs commit e6057cfd59f278db3aeb058a4e1e0bcc24696267.

Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Co-authored-by: Dominic Mills <dominic.millz27@gmail.com>
2025-02-03 20:44:32 +00:00
EmilyandJared Baur 6b81859ed0 nixpkgs: fix determination for cross-compiled nix-darwin system
Since the output of `lib.systems.elaborate` contains functions, an
equality check with `==` does not suffice, `lib.systems.equals` should
be used instead.

Backport of Nixpkgs commit 3794246066409d7baac72e3fdfb0e4f66ef4a013.

Co-authored-by: Jared Baur <jaredbaur@fastmail.com>
2025-02-03 20:44:32 +00:00
EmilyandAlyssa Ross 2df9e48110 nixpkgs: use less confusing example systems
system and config shouldn't both be specified — each will be filled in
based on the other when the system is elaborated.

Backport of Nixpkgs commit a3ba0495452cd8e72735ebd4472838e96902a259.

Co-authored-by: Alyssa Ross <hi@alyssa.is>
2025-02-03 20:25:16 +00:00
3cd3a79f9b nixpkgs: Rewrite overlays option docs
henrik-ch was also here :)

Backport of Nixpkgs commit 11406bdc0e5af9b3c8a8d597da23349238c65277.

Co-authored-by: Silvan Mosberger <silvan.mosberger@tweag.io>
Co-Authored-By: Valentin Gagarin <valentin.gagarin@tweag.io>
2025-02-03 20:25:16 +00:00
EmilyandK900 962eb3f1c0 nixpkgs: assert that nixpkgs.config is not set when pkgs is passed in externally
This is a common footgun people hit often. Remove it.

Backport of Nixpkgs commit ce87196a00214a0062ece1c3e03a9a97f563580f.

Co-authored-by: K900 <me@0upti.me>
2025-02-03 20:25:16 +00:00
Emily 5b0cffeec2 nixpkgs: fix undefined variable in assertion
This got mangled in the backport a year and a half ago.

Fixes: e25eeff158
2025-02-03 20:25:16 +00:00
EmilyandGitHub 49b807fa7c Merge pull request #1311 from tarc/master
checks: fix sw_vers parameter for macOSVersion
2025-01-30 22:55:53 +00:00
tarc f1cf8c4f5a checks: fix sw_vers parameter for macOSVersion (--productVersion, not -productVersion) 2025-01-30 12:46:25 -03:00
Michael HoangandGitHub 349a74c66c Merge pull request #1306 from emilazy/push-kzsqtpuplusw
Revert "{activation-scripts,activate-system}: purify environment"
2025-01-28 09:58:58 +07:00
Emily cc9c8408bb Revert "{activation-scripts,activate-system}: purify environment"
This shouldn’t actually be split out from the Plan because of the
current use of `$HOME` in the defaults for channel‐based setups.

This reverts commit 4bff4bc8ae.
2025-01-28 02:31:59 +00:00
EmilyandGitHub f43dac477e Merge pull request #1280 from emilazy/push-tunoqoxyyuvy
{environment,readme}: default configuration path to `/etc/nix-darwin`
2025-01-28 02:14:28 +00:00
EmilyandGitHub 5c12a6f4a1 Merge pull request #1303 from emilazy/push-ulxuwyrnkwpq
{activation-scripts,activate-system}: purify environment
2025-01-27 23:11:51 +00:00
Emily 3509925a86 readme: make darwin-rebuild use more explicit 2025-01-27 23:10:14 +00:00
Emily 2733527a58 {environment,readme}: default configuration path to /etc/nix-darwin 2025-01-27 23:10:14 +00:00
Emily 5bc4677c03 readme: reduce duplication in installation instructions 2025-01-27 22:38:26 +00:00
EmilyandGitHub 6715348399 Merge pull request #1300 from emilazy/push-knuxyuxwswlu
ci: use the PR head as `<darwin>` for install test
2025-01-27 22:38:02 +00:00
EmilyandGitHub 67e7728c9a Merge pull request #1302 from emilazy/push-vtlomuzppvtu
checks: remove `darwinChanges`
2025-01-27 22:35:28 +00:00
Emily 4bff4bc8ae {activation-scripts,activate-system}: purify environment
This ensures that system activation does not depend on various
details of its process environment, ensuring uniformity across various
invocation contexts and with the `activate-system` daemon. This becomes
more important in a post‐user‐activation world to avoid problematic
dependencies like `$SUDO_USER`, but is a good idea in general.

The `sudoers(5)` defaults on my Sequoia system are:

    Defaults	env_reset
    Defaults	env_keep += "BLOCKSIZE"
    Defaults	env_keep += "COLORFGBG COLORTERM"
    Defaults	env_keep += "__CF_USER_TEXT_ENCODING"
    Defaults	env_keep += "CHARSET LANG LANGUAGE LC_ALL LC_COLLATE LC_CTYPE"
    Defaults	env_keep += "LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME"
    Defaults	env_keep += "LINES COLUMNS"
    Defaults	env_keep += "LSCOLORS"
    Defaults	env_keep += "SSH_AUTH_SOCK"
    Defaults	env_keep += "TZ"
    Defaults	env_keep += "DISPLAY XAUTHORIZATION XAUTHORITY"
    Defaults	env_keep += "EDITOR VISUAL"
    Defaults	env_keep += "HOME MAIL"

Of these preserved environment variables, the ones that are set in
practice when I run `sudo env` that aren’t set in the activation
script here are:

* `$COLORTERM`
* `$DISPLAY`
* `$EDITOR`
* `$MAIL`
* `$SSH_AUTH_SOCK`
* `$TERM`
* `$__CF_USER_TEXT_ENCODING`

Most of these seem either pointless or actively harmful to set for
the purpose of the system activation script.

This will mean that tools run during activation won’t print output
in the user’s preferred language, but that’s probably the right
trade‐off overall, as that is likely to break activation scripts
that parse command output anyway.
2025-01-27 22:31:15 +00:00
Emily ff80eacd0f activation-scripts: remove _status
I believe this has been obsolete since `set -e` was added in
8708ebb796.
2025-01-27 22:31:15 +00:00
Emily 0e87d3d391 activate-system: don’t KeepAlive
It seems like a bad idea to keep restarting the activation daemon
when it fails.
2025-01-27 22:31:15 +00:00
Emily 2119dd10f6 checks: remove darwinChanges
It seems like this has been broken since
26bab2fd32 from 2018; macOS `diff(1)`
does not support these arguments and the `$PATH` has been fixed since
that point. Before that, it would presumably only have worked if you
added GNU diffutils to `environment.systemPackages`.

Proactively notifying users about breaking changes isn’t a bad idea,
but the activation script doesn’t seem like the right place for it,
and as it’s non‐blocking it’s likely that even if it worked it
would get drowned out by the later output anyway. I’d like to move
the changelog into release notes as part of the manual, which would
requires changes to this anyway. Since it’s been broken for almost
seven years anyway, let’s just drop it for now and revisit later.
2025-01-27 20:59:20 +00:00
Emily 1e16e2a9c2 ci: use the PR head as <darwin> for install test
This was installing against the base branch, which causes annoying
issues when things like the state version are bumped. It’s possible
this was intentional to test the upgrade path, but it’s inconsistent
with the flake installation test and keeps breaking stuff on my
PRs. If we want to test the upgrade path then we could re‐add it
again later in a more sophisticated manner (e.g. using the example
config from the previous version).
2025-01-27 20:04:09 +00:00
EmilyandGitHub 62ba0a2242 Merge pull request #1282 from emilazy/push-uqnyoyklywvo
nix-tools: drop `nixPackage`, overwrite `$PATH` rather than prepending, set `$NIX_PATH`
2025-01-26 21:26:41 +00:00
EmilyandGitHub 65cc1fa8e3 Merge pull request #1283 from emilazy/push-nynpmzrmmozu
checks: remove `runLink`
2025-01-22 00:01:16 +00:00
EmilyandGitHub 46d0fa4ded Merge pull request #1279 from emilazy/push-tstmztlwwouo
darwin-uninstaller: remove `darwin` channel from `root` too
2025-01-21 01:33:50 +00:00
EmilyandGitHub 3cdacf160b Merge pull request #1281 from emilazy/push-ozqwkmtmkvtr
darwin-rebuild: pass `${extraBuildFlags[@]}` to `nix-instantiate`
2025-01-21 01:33:15 +00:00
EmilyandGitHub 9525191e9f Merge pull request #1278 from emilazy/push-vuuzmmsrorvw
system: tweak ShellCheck settings
2025-01-21 01:33:00 +00:00
EmilyandGitHub 74a58bfb3f Merge pull request #1290 from emilazy/push-rzokwryxsqxz
eval-config: omit `enableNixpkgsReleaseCheck` from `lib.evalModules`
2025-01-21 00:55:11 +00:00
Emily 87b61d6666 eval-config: omit enableNixpkgsReleaseCheck from lib.evalModules 2025-01-21 00:27:49 +00:00
Emily b5b7888793 nix-tools: set $NIX_PATH
This will be important once most users are running `sudo
darwin-rebuild` and therefore not getting their environment’s
`$NIX_PATH` passed through.
2025-01-20 05:29:44 +00:00
Emily 4d0ae6980d nix-tools: overwrite $PATH rather than prepending
I don’t see any reason for these scripts to depend on more
environmental state than necessary.
2025-01-20 05:29:44 +00:00
Emily c3954c51c4 checks: remove runLink
Now that we create `/run` as part of activation, this is no longer
useful for anaything.
2025-01-18 23:15:41 +00:00
Emily 3d95b01351 nix-tools: make systemPath more readable 2025-01-18 20:33:10 +00:00
Emily 02232f71c5 nix-tools: drop nixPackage
We already put `/nix/var/nix/profiles/default/bin` on the `$PATH`,
and whatever `nix.package` is set to already gets installed into
`/run/current-system/sw/bin`, so this is pointless.
2025-01-18 20:31:54 +00:00
Emily 5665d6c05e darwin-rebuild: pass ${extraBuildFlags[@]} to nix-instantiate
Theoretically required for `darwin-rebuild edit -I darwin-config=…`,
I guess. We also shouldn’t run it for flake‐based setups.
2025-01-18 20:01:22 +00:00
Emily 94adbd6259 darwin-uninstaller: remove darwin channel from root too 2025-01-18 19:38:34 +00:00
Emily e1976612f0 system: tweak ShellCheck settings 2025-01-18 19:34:21 +00:00
EmilyandGitHub 87131f51f8 Merge pull request #1266 from emilazy/push-qwtkyltnunqn
checks: check `/etc/nix/nix.custom.conf` hash
2025-01-18 01:12:15 +00:00
EmilyandGitHub 3924b55553 Merge pull request #1277 from emilazy/push-yxsrvorpzlor
{environment,nix-tools}: correct default `$PATH` ordering to match macOS
2025-01-18 01:11:06 +00:00
EmilyandGitHub 09414c7e2d Merge pull request #1272 from emilazy/push-uooytqlwsquo
defaults-write: fix activation script conditionalization
2025-01-17 03:41:37 +00:00
Emily 8abb2e7244 nix: add hashes for Determinate Systems installer v0.33.0 and v0.34.0 2025-01-17 03:34:11 +00:00
Emily 2fe899db70 nix: check /etc/nix/nix.custom.conf hash 2025-01-17 03:34:11 +00:00
Michael HoangandGitHub ca1f666b6d Merge pull request #1262 from belak-forks/additional-tiling-options
Add support for additional window tiling options
2025-01-17 14:28:18 +11:00
Michael HoangandGitHub c738b81ff5 Merge pull request #1265 from emilazy/push-turlyykvtunt
checks: check for macOS ≥ 11.3
2025-01-17 14:03:04 +11:00
Michael HoangandGitHub 97c05365cf Merge pull request #1273 from emilazy/push-nlqypwmmvons
doc/manual: use `--replace-fail`
2025-01-17 13:52:55 +11:00
Kaleb Elwert 4075a3c23a Add support for additional window tiling options
This adds support for the following defaults:

- com.apple.WindowManager.EnableTilingByEdgeDrag
- com.apple.WindowManager.EnableTopTilingByEdgeDrag
- com.apple.WindowManager.EnableTilingOptionAccelerator
2025-01-15 22:53:21 -08:00
Emily f959b8878b defaults-write: fix activation script conditionalization
These are lists, not attribute sets, so the condition was always
succeeding. As far as I can tell this bug has been present since the
function was added.
2025-01-16 00:13:57 +00:00
Emily ff1d6384df {environment,nix-tools}: correct default $PATH ordering to match macOS 2025-01-15 23:26:14 +00:00
Emily 47174f3868 doc/manual: use --replace-fail 2025-01-15 23:19:28 +00:00
Emily fe2fc038fd defaults/universalaccess: remove docs for macOS < 11 2025-01-14 15:56:20 +00:00
Emily c5b7b604ca darwin-rebuild: remove code for macOS < 11 2025-01-14 15:56:20 +00:00
Emily 8f4f3d8d2d darwin-uninstaller: remove code for macOS < 11 2025-01-14 15:56:20 +00:00
Emily 1c21c9410e system: remove unnecessary sudo 2025-01-14 15:56:20 +00:00
Emily b721000dc6 system: add missing newline 2025-01-14 15:56:20 +00:00
Emily ed6c4aabea system: remove code for macOS < 11 2025-01-14 15:56:20 +00:00
Emily 303a8143a4 checks: check for macOS ≥ 11.3 2025-01-12 19:43:29 +00:00
178 changed files with 5637 additions and 2126 deletions
+2
View File
@@ -0,0 +1,2 @@
# nixpkgs: format with `nixfmt`
dc1c716ded39758062ed7e6bc410ad274119de9f
+43 -34
View File
@@ -1,13 +1,13 @@
name: "Test"
on:
pull_request:
merge_group:
push:
branches:
- master
env:
NIXPKGS_BRANCH: nixpkgs-unstable
NIX_DARWIN_BRANCH: master
NIX_VERSION: 2.24.11
jobs:
@@ -19,7 +19,7 @@ jobs:
# TODO: Change them once the repository configuration is updated.
test-stable:
runs-on: macos-13
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: Install Nix
@@ -29,7 +29,7 @@ jobs:
- run: nix flake check --override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
install-against-stable:
runs-on: macos-13
runs-on: macos-14
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
@@ -40,48 +40,55 @@ jobs:
nix_path: nixpkgs=channel:${{ env.NIXPKGS_BRANCH }}
- name: Install channels
run: |
nix-channel --add https://github.com/LnL7/nix-darwin/archive/${{ env.NIX_DARWIN_BRANCH }}.tar.gz darwin
nix-channel --add https://nixos.org/channels/${{ env.NIXPKGS_BRANCH }} nixpkgs
nix-channel --update
sudo nix-channel --add https://nixos.org/channels/${{ env.NIXPKGS_BRANCH }} nixpkgs
sudo nix-channel --update
- name: Install nix-darwin
run: |
export NIX_PATH=$HOME/.nix-defexpr/channels
mkdir -p ~/.config/nix-darwin
cp modules/examples/simple.nix ~/.config/nix-darwin/configuration.nix
sudo mkdir -p /etc/nix-darwin
sudo cp modules/examples/simple.nix /etc/nix-darwin/configuration.nix
nixConfHash=$(shasum -a 256 /etc/nix/nix.conf | cut -d ' ' -f 1)
/usr/bin/sed -i.bak \
"s/# programs.fish.enable = true;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
~/.config/nix-darwin/configuration.nix
sudo /usr/bin/sed -i.bak \
"s/# programs.fish.enable = true;/ \
imports = [ \
({ options, ... }: { \
nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; \
environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ]; \
nix.nixPath = \
[ { darwin = \"${PWD////\/}\"; } ] \
++ options.nix.nixPath.default; \
}) \
]; \
/" \
/etc/nix-darwin/configuration.nix
nix run .#darwin-rebuild \
-- switch \
-I darwin-config=$HOME/.config/nix-darwin/configuration.nix
sudo nix run .#darwin-rebuild -- switch \
-I darwin=. \
-I darwin-config=/etc/nix-darwin/configuration.nix
- name: Switch to new configuration
run: |
. /etc/bashrc
/usr/bin/sed -i.bak \
sudo /usr/bin/sed -i.bak \
"s/pkgs.vim/pkgs.hello/" \
~/.config/nix-darwin/configuration.nix
/etc/nix-darwin/configuration.nix
darwin-rebuild switch -I darwin=.
sudo darwin-rebuild switch
hello
- name: Test uninstallation of nix-darwin
run: |
# We need to specify `--extra-experimental-features` because `experimental-features` is set by
# `cachix/install-nix-action` but not by our default config above
nix run .#darwin-uninstaller \
sudo nix run .#darwin-uninstaller \
--extra-experimental-features "nix-command flakes" \
--override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
nix run .#darwin-uninstaller.tests.uninstaller \
sudo nix run .#darwin-uninstaller.tests.uninstaller \
--extra-experimental-features "nix-command flakes" \
--override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
install-flake:
runs-on: macos-13
runs-on: macos-14
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
@@ -91,36 +98,38 @@ jobs:
install_url: https://releases.nixos.org/nix/nix-${{ env.NIX_VERSION }}/install
- name: Install nix-darwin
run: |
mkdir -p ~/.config/nix-darwin
sudo mkdir -p /etc/nix-darwin
darwin=$(pwd)
pushd ~/.config/nix-darwin
nix flake init -t $darwin
pushd /etc/nix-darwin
sudo nix flake init -t $darwin
nixConfHash=$(shasum -a 256 /etc/nix/nix.conf | cut -d ' ' -f 1)
/usr/bin/sed -i.bak \
sudo /usr/bin/sed -i.bak \
"s/# programs.fish.enable = true;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
flake.nix
/usr/bin/sed -i.bak \
sudo /usr/bin/sed -i.bak \
's/darwinConfigurations."simple"/darwinConfigurations."'$(scutil --get LocalHostName)'"/g' \
flake.nix
sudo /usr/bin/sed -i.bak \
's/nixpkgs.hostPlatform = "aarch64-darwin";/nixpkgs.hostPlatform = "'$(nix eval --expr builtins.currentSystem --impure --raw)'";/' \
flake.nix
popd
nix run .#darwin-rebuild -- \
switch --flake ~/.config/nix-darwin#simple \
sudo nix run .#darwin-rebuild -- switch \
--override-input nix-darwin . \
--override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
- name: Switch to new configuration
run: |
. /etc/bashrc
/usr/bin/sed -i.bak \
sudo /usr/bin/sed -i.bak \
"s/pkgs.vim/pkgs.hello/" \
~/.config/nix-darwin/flake.nix
/etc/nix-darwin/flake.nix
darwin-rebuild switch --flake ~/.config/nix-darwin#simple \
sudo darwin-rebuild switch \
--override-input nix-darwin . \
--override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
hello
- name: Test uninstallation of nix-darwin
run: |
nix run .#darwin-uninstaller --override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
nix run .#darwin-uninstaller.tests.uninstaller --override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
sudo nix run .#darwin-uninstaller --override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
sudo nix run .#darwin-uninstaller.tests.uninstaller --override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
-35
View File
@@ -1,35 +0,0 @@
name: Update manual
on:
push:
branches:
- master
jobs:
update-manual:
runs-on: macos-13
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# So that we fetch all branches, since we need to checkout the `gh-pages` branch later.
fetch-depth: 0
- name: Install Nix
uses: cachix/install-nix-action@v30
- name: Build manual
run: |
nix build .#manualHTML
- name: Push update to manual
run: |
git checkout gh-pages
rm -rf manual
cp -R result/share/doc/darwin manual
rm result
git checkout master -- README.md
git config user.name github-actions
git config user.email github-actions@github.com
git add --all
git commit -m "Update manual"
git push
+45
View File
@@ -0,0 +1,45 @@
name: Update website
on:
push:
branches:
- master
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build
runs-on: macos-14
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- name: Install Nix
uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f
- name: Build website
run: nix build .#website -o _site
- name: Upload website
id: deployment
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa
# See: <https://github.com/actions/deploy-pages?tab=readme-ov-file#usage>
deploy:
name: Deploy
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-24.04
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e
+1
View File
@@ -1,2 +1,3 @@
.DS_Store
*.swp
result*
+89 -2
View File
@@ -1,3 +1,90 @@
2026-05-16
- The reversed split-window key bindings previously generated by
`programs.tmux.enableSensible` are no longer emitted when
`system.stateVersion` is 7 or later, so tmux uses its conventional
behavior: `%` splits the current pane horizontally and `"` splits it
vertically.
Existing configurations with `system.stateVersion` 6 or earlier keep
the previous reversed bindings. You can explicitly choose either
behavior with `programs.tmux.reverseSplitBindings`.
2026-02-10
- Major changes to `homebrew` module
`homebrew.brewPrefix` was renamed to `homebrew.prefix`, and its semantics
changed: the old option pointed to the bin directory (e.g.,
`/opt/homebrew/bin`), while the new option points to the Homebrew prefix
(e.g., `/opt/homebrew`), matching `brew --prefix`.
`homebrew.whalebrews` was removed. Whalebrew support was removed from
Homebrew Bundle in Homebrew 4.7.0 (Nov 2025), so `whalebrew` entries in a
Brewfile now cause `brew bundle` to fail.
`homebrew.global.lockfiles` and `homebrew.global.noLock` no longer have any
effect. Homebrew Bundle removed lockfile support in Homebrew 4.4.0 (Oct 2024).
`homebrew.onActivation.cleanup` now supports a `"check"` mode, which checks
for unlisted packages and aborts activation if any are found, without
removing them.
Shell integration options were added: `homebrew.enableBashIntegration`,
`homebrew.enableFishIntegration`, and `homebrew.enableZshIntegration`.
New Brewfile entry types were added: `homebrew.goPackages`,
`homebrew.cargoPackages`, and `homebrew.vscode`.
New options were added for brews: `postinstall`, `link = "overwrite"`, and
`restart_service = "always"`. The `postinstall` option was also added for
casks.
2025-01-30
- Previously, some nix-darwin options applied to the user running
`darwin-rebuild`. As part of a longterm migration to make
nix-darwin focus on systemwide activation and support firstclass
multiuser setups, all system activation now runs as `root`, and
these options instead apply to the `system.primaryUser` user.
You will get an evaluation error if you are using any options to
which this applies.
To continue using these options, set `system.primaryUser` to the name
of the user you have been using to run `darwin-rebuild`. In the long
run, this setting will be deprecated and removed after all the
functionality it is relevant for has been adjusted to allow
specifying the relevant user separately, moved under the
`users.users.*` namespace, or migrated to Home Manager.
Accordingly, `darwin-rebuild` must now be run as root, the
`system.activationScripts.{extraUserActivation,preUserActivation,
postUserActivation}` settings have been removed, and all activation
scripts are now executed as `root` be careful if you override any
of them.
If you run into any unexpected issues with the migration, please
open an issue at <https://github.com/nix-darwin/nix-darwin/issues/new>
and include as much information as possible.
2025-01-29
- There is now a `nix.enable` toggle to disable management of the Nix
installation. Nix installation management has been made more
opinionated as a consequence; nix-darwin now only supports managing a
multiuser daemon installation of Nix, and unconditionally takes
ownership of the nix-daemon launchd daemon and the `_nixbld*` build
users when Nix installation management is enabled.
If the new constraints do not work with your setup, you can disable
the `nix.enable` option to opt out of Nix installation management
entirely; see the option documentation for caveats.
2025-01-18
- The default configuration path for all new installations
is `/etc/nix-darwin`. This was already the undocumented
default for `darwin-rebuild switch` when using flakes. This
is implemented by setting `environment.darwinConfig` to
`"/etc/nix-darwin/configuration.nix"` by default when
`system.stateVersion` ≥ 6.
2024-09-10
- The default Nix build user group ID is now set to 350 when
`system.stateVersion` ≥ 5, to reflect the default for new Nix
@@ -69,7 +156,7 @@
`nix.daemonIONice` was renamed to `nix.daemonIOLowPriority`, and
`nix.daemonNiceLevel` was removed in favor a new option
`nix.nix.daemonProcessType`.
`nix.daemonProcessType`.
2021-01-16
- Added `homebrew` module, to manage formulas installed by Homebrew via `brew bundle`.
@@ -189,7 +276,7 @@
Use a channel for nix-darwin or configure nix.nixPath
sudo nix-channel --add https://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin
sudo nix-channel --add https://github.com/nix-darwin/nix-darwin/archive/master.tar.gz darwin
sudo nix-channel --update
nix.nixPath =
+37 -38
View File
@@ -1,8 +1,8 @@
[<img src="https://daiderd.com/nix-darwin/images/nix-darwin.png" width="200px" alt="logo" />](https://github.com/LnL7/nix-darwin)
[<img src="https://github.com/user-attachments/assets/0e1a77ac-6739-4153-bd24-abd3a5e143f5" width="200px" alt="logo" />](https://github.com/nix-darwin/nix-darwin)
# nix-darwin
[![Test](https://github.com/LnL7/nix-darwin/actions/workflows/test.yml/badge.svg)](https://github.com/LnL7/nix-darwin/actions/workflows/test.yml)
[![Test](https://github.com/nix-darwin/nix-darwin/actions/workflows/test.yml/badge.svg)](https://github.com/nix-darwin/nix-darwin/actions/workflows/test.yml)
Nix modules for darwin, `/etc/nixos/configuration.nix` for macOS.
@@ -11,14 +11,11 @@ nix-darwin is built up around [Nixpkgs](https://github.com/NixOS/nixpkgs), quite
## Prerequisites
The only prerequisite is a Nix implementation, both Nix and Lix are supported.
As 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:
- 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. **Make sure you use it without the `--determinate` flag**. The `--determinate` flag installs the Determinate Nix distribution which does not work out of the box with nix-darwin.
* The [Lix installer](https://lix.systems/install/#on-any-other-linuxmacos-system) supports both flake-based and channel-based setups.
The only prerequisite is a Nix implementation; both Nix and Lix are supported.
As the official Nix installer does not include an automated uninstaller, and manual uninstallation on macOS is a complex process, we recommend using the [Lix installer](https://lix.systems/install/#on-any-other-linuxmacos-system), which supports both flake-based and channel-based setups.
The installer you use doesn't affect which Nix interpreter your system will use later on. nix-darwin manages the Nix installation by default and will default to upstream Nix. If you wish to use Lix instead of Nix, set `nix.package = pkgs.lix` in your configuration.
## Getting started
@@ -33,21 +30,22 @@ Despite being an experimental feature in Nix currently, nix-darwin recommends th
<summary>Getting started from scratch</summary>
<p></p>
If you don't have an existing `configuration.nix`, you can run the following commands to generate a basic `flake.nix` inside `~/.config/nix-darwin`:
If you don't have an existing `configuration.nix`, you can run the following commands to generate a basic `flake.nix` inside `/etc/nix-darwin`:
```bash
mkdir -p ~/.config/nix-darwin
cd ~/.config/nix-darwin
sudo mkdir -p /etc/nix-darwin
sudo chown $(id -nu):$(id -ng) /etc/nix-darwin
cd /etc/nix-darwin
# To use Nixpkgs unstable:
nix flake init -t nix-darwin/master
# To use Nixpkgs 24.11:
nix flake init -t nix-darwin/nix-darwin-24.11
# To use Nixpkgs 26.05:
nix flake init -t nix-darwin/nix-darwin-26.05
sed -i '' "s/simple/$(scutil --get LocalHostName)/" flake.nix
```
Make sure to change `nixpkgs.hostPlatform` to `aarch64-darwin` if you are using Apple Silicon.
Make sure to check if `nixpkgs.hostPlatform` is set to either `x86_64-darwin` for Intel or `aarch64-darwin` for Apple Silicon.
</details>
@@ -62,10 +60,10 @@ Add the following to `flake.nix` in the same folder as `configuration.nix`:
description = "John's darwin system";
inputs = {
# Use `github:NixOS/nixpkgs/nixpkgs-24.11-darwin` to use Nixpkgs 24.11.
# Use `github:NixOS/nixpkgs/nixpkgs-26.05-darwin` to use Nixpkgs 26.05.
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
# Use `github:LnL7/nix-darwin/nix-darwin-24.11` to use Nixpkgs 24.11.
nix-darwin.url = "github:LnL7/nix-darwin/master";
# Use `github:nix-darwin/nix-darwin/nix-darwin-26.05` to use Nixpkgs 26.05.
nix-darwin.url = "github:nix-darwin/nix-darwin/master";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
};
@@ -88,7 +86,10 @@ Make sure to set `nixpkgs.hostPlatform` in your `configuration.nix` to either `x
Unlike 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:
```bash
nix run nix-darwin -- switch --flake ~/.config/nix-darwin
# To use Nixpkgs unstable:
sudo nix run nix-darwin/master#darwin-rebuild -- switch
# To use Nixpkgs 26.05:
sudo nix run nix-darwin/nix-darwin-26.05#darwin-rebuild -- switch
```
### Step 3. Using `nix-darwin`
@@ -96,7 +97,7 @@ nix run nix-darwin -- switch --flake ~/.config/nix-darwin
After installing, you can run `darwin-rebuild` to apply changes to your system:
```bash
darwin-rebuild switch --flake ~/.config/nix-darwin
sudo darwin-rebuild switch
```
#### Using flake inputs
@@ -124,15 +125,15 @@ nix-darwin.lib.darwinSystem {
### Step 1. Creating `configuration.nix`
Copy the [simple](./modules/examples/simple.nix) example to `~/.config/nix-darwin/configuration.nix`.
Copy the [simple](./modules/examples/simple.nix) example to `/etc/nix-darwin/configuration.nix`.
### Step 2. Adding `nix-darwin` channel
```bash
# If you use Nixpkgs unstable (the default):
sudo nix-channel --add https://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin
# If you use Nixpkgs 24.11:
sudo nix-channel --add https://github.com/LnL7/nix-darwin/archive/nix-darwin-24.11.tar.gz darwin
sudo nix-channel --add https://github.com/nix-darwin/nix-darwin/archive/master.tar.gz darwin
# If you use Nixpkgs 26.05:
sudo nix-channel --add https://github.com/nix-darwin/nix-darwin/archive/nix-darwin-26.05.tar.gz darwin
sudo nix-channel --update
```
@@ -142,12 +143,8 @@ sudo nix-channel --update
To 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:
```bash
# If you use Nixpkgs unstable (the default):
nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A darwin-rebuild
# If you use Nixpkgs 24.11:
nix-build https://github.com/LnL7/nix-darwin/archive/nix-darwin-24.11.tar.gz -A darwin-rebuild
./result/bin/darwin-rebuild switch -I darwin-config=$HOME/.config/nix-darwin/configuration.nix
nix-build '<darwin>' -A darwin-rebuild
sudo ./result/bin/darwin-rebuild switch -I darwin-config=/etc/nix-darwin/configuration.nix
```
### Step 4. Using `nix-darwin`
@@ -155,7 +152,7 @@ nix-build https://github.com/LnL7/nix-darwin/archive/nix-darwin-24.11.tar.gz -A
After installing, you can run `darwin-rebuild` to apply changes to your system:
```bash
darwin-rebuild switch
sudo darwin-rebuild switch
```
### Step 5. Updating `nix-darwin`
@@ -169,22 +166,24 @@ sudo nix-channel --update
## Documentation
`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).
The reference documentation is available:
The documentation is also available as manpages by running `man 5 configuration.nix`.
* Online: [nix-darwin reference](https://nix-darwin.github.io/nix-darwin/manual/index.html)
* Locally in your browser via the `darwin-help` command
* As a manual page via `man 5 configuration.nix`
## Uninstalling
To run the latest version of the uninstaller, you can run the following command:
```
nix --extra-experimental-features "nix-command flakes" run nix-darwin#darwin-uninstaller
sudo nix --extra-experimental-features "nix-command flakes" run nix-darwin#darwin-uninstaller
```
If that command doesn't work for you, you can try the locally installed uninstaller:
```
darwin-uninstaller
sudo darwin-uninstaller
```
## Tests
@@ -210,7 +209,7 @@ flag can also be used to override darwin-config or nixpkgs, for more
information on the `-I` flag look at the nix-build [manpage](https://nixos.org/manual/nix/stable/command-ref/nix-build.html).
```bash
darwin-rebuild switch -I darwin=.
sudo darwin-rebuild switch -I darwin=.
```
If you're adding a module, please add yourself to `meta.maintainers`, for example
@@ -226,6 +225,6 @@ If you're adding a module, please add yourself to `meta.maintainers`, for exampl
The `or` operator takes care of graceful degradation when `lib` from Nixpkgs
goes out of sync.
Also feel free to contact me if you have questions,
- Matrix - @daiderd:matrix.org, you can find me in [#macos:nixos.org](https://matrix.to/#/#macos:nixos.org)
- @LnL7 on twitter
Feel free to contact us on Matrix if you have questions:
* **User support:** [#macos:nixos.org](https://matrix.to/#/#macos:nixos.org)
* **Development discussion:** [#nix-darwin-dev:nixos.org](https://matrix.to/#/#nix-darwin-dev:nixos.org)
@@ -0,0 +1,82 @@
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
# System-wide profile for interactive zsh(1) shells.
# Setup user specific overrides for this in ~/.zshrc. See zshbuiltins(1)
# and zshoptions(1) for more details.
# Correctly display UTF-8 with combining characters. We'll assume UTF-8 if the
# locale(1) binary is missing entirely.
if [[ ! -x /usr/bin/locale ]] || [[ "$(locale LC_CTYPE)" == "UTF-8" ]]; then
setopt COMBINING_CHARS
fi
# Disable the log builtin, so we don't conflict with /usr/bin/log
disable log
# Save command history
HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history
HISTSIZE=2000
SAVEHIST=1000
# Beep on error
setopt BEEP
# Use keycodes (generated via zkbd) if present, otherwise fallback on
# values from terminfo
if [[ -r ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR} ]] ; then
source ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR}
else
typeset -g -A key
[[ -n "$terminfo[kf1]" ]] && key[F1]=$terminfo[kf1]
[[ -n "$terminfo[kf2]" ]] && key[F2]=$terminfo[kf2]
[[ -n "$terminfo[kf3]" ]] && key[F3]=$terminfo[kf3]
[[ -n "$terminfo[kf4]" ]] && key[F4]=$terminfo[kf4]
[[ -n "$terminfo[kf5]" ]] && key[F5]=$terminfo[kf5]
[[ -n "$terminfo[kf6]" ]] && key[F6]=$terminfo[kf6]
[[ -n "$terminfo[kf7]" ]] && key[F7]=$terminfo[kf7]
[[ -n "$terminfo[kf8]" ]] && key[F8]=$terminfo[kf8]
[[ -n "$terminfo[kf9]" ]] && key[F9]=$terminfo[kf9]
[[ -n "$terminfo[kf10]" ]] && key[F10]=$terminfo[kf10]
[[ -n "$terminfo[kf11]" ]] && key[F11]=$terminfo[kf11]
[[ -n "$terminfo[kf12]" ]] && key[F12]=$terminfo[kf12]
[[ -n "$terminfo[kf13]" ]] && key[F13]=$terminfo[kf13]
[[ -n "$terminfo[kf14]" ]] && key[F14]=$terminfo[kf14]
[[ -n "$terminfo[kf15]" ]] && key[F15]=$terminfo[kf15]
[[ -n "$terminfo[kf16]" ]] && key[F16]=$terminfo[kf16]
[[ -n "$terminfo[kf17]" ]] && key[F17]=$terminfo[kf17]
[[ -n "$terminfo[kf18]" ]] && key[F18]=$terminfo[kf18]
[[ -n "$terminfo[kf19]" ]] && key[F19]=$terminfo[kf19]
[[ -n "$terminfo[kf20]" ]] && key[F20]=$terminfo[kf20]
[[ -n "$terminfo[kbs]" ]] && key[Backspace]=$terminfo[kbs]
[[ -n "$terminfo[kich1]" ]] && key[Insert]=$terminfo[kich1]
[[ -n "$terminfo[kdch1]" ]] && key[Delete]=$terminfo[kdch1]
[[ -n "$terminfo[khome]" ]] && key[Home]=$terminfo[khome]
[[ -n "$terminfo[kend]" ]] && key[End]=$terminfo[kend]
[[ -n "$terminfo[kpp]" ]] && key[PageUp]=$terminfo[kpp]
[[ -n "$terminfo[knp]" ]] && key[PageDown]=$terminfo[knp]
[[ -n "$terminfo[kcuu1]" ]] && key[Up]=$terminfo[kcuu1]
[[ -n "$terminfo[kcub1]" ]] && key[Left]=$terminfo[kcub1]
[[ -n "$terminfo[kcud1]" ]] && key[Down]=$terminfo[kcud1]
[[ -n "$terminfo[kcuf1]" ]] && key[Right]=$terminfo[kcuf1]
fi
# Default key bindings
[[ -n ${key[Delete]} ]] && bindkey "${key[Delete]}" delete-char
[[ -n ${key[Home]} ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
[[ -n ${key[Up]} ]] && bindkey "${key[Up]}" up-line-or-search
[[ -n ${key[Down]} ]] && bindkey "${key[Down]}" down-line-or-search
# Default prompt
PS1="%n@%m %1~ %# "
# Useful support for interacting with Terminal.app or other terminal programs
[ -r "/etc/zshrc_$TERM_PROGRAM" ] && . "/etc/zshrc_$TERM_PROGRAM"
@@ -0,0 +1,3 @@
# Written by https://github.com/DeterminateSystems/nix-installer.
# The contents below are based on options specified at installation time.
@@ -0,0 +1,74 @@
# System-wide profile for interactive zsh(1) shells.
# Setup user specific overrides for this in ~/.zshrc. See zshbuiltins(1)
# and zshoptions(1) for more details.
# Correctly display UTF-8 with combining characters. We'll assume UTF-8 if the
# locale(1) binary is missing entirely.
if [[ ! -x /usr/bin/locale ]] || [[ "$(locale LC_CTYPE)" == "UTF-8" ]]; then
setopt COMBINING_CHARS
fi
# Disable the log builtin, so we don't conflict with /usr/bin/log
disable log
# Save command history
HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history
HISTSIZE=2000
SAVEHIST=1000
# Beep on error
setopt BEEP
# Use keycodes (generated via zkbd) if present, otherwise fallback on
# values from terminfo
if [[ -r ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR} ]] ; then
source ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR}
else
typeset -g -A key
[[ -n "$terminfo[kf1]" ]] && key[F1]=$terminfo[kf1]
[[ -n "$terminfo[kf2]" ]] && key[F2]=$terminfo[kf2]
[[ -n "$terminfo[kf3]" ]] && key[F3]=$terminfo[kf3]
[[ -n "$terminfo[kf4]" ]] && key[F4]=$terminfo[kf4]
[[ -n "$terminfo[kf5]" ]] && key[F5]=$terminfo[kf5]
[[ -n "$terminfo[kf6]" ]] && key[F6]=$terminfo[kf6]
[[ -n "$terminfo[kf7]" ]] && key[F7]=$terminfo[kf7]
[[ -n "$terminfo[kf8]" ]] && key[F8]=$terminfo[kf8]
[[ -n "$terminfo[kf9]" ]] && key[F9]=$terminfo[kf9]
[[ -n "$terminfo[kf10]" ]] && key[F10]=$terminfo[kf10]
[[ -n "$terminfo[kf11]" ]] && key[F11]=$terminfo[kf11]
[[ -n "$terminfo[kf12]" ]] && key[F12]=$terminfo[kf12]
[[ -n "$terminfo[kf13]" ]] && key[F13]=$terminfo[kf13]
[[ -n "$terminfo[kf14]" ]] && key[F14]=$terminfo[kf14]
[[ -n "$terminfo[kf15]" ]] && key[F15]=$terminfo[kf15]
[[ -n "$terminfo[kf16]" ]] && key[F16]=$terminfo[kf16]
[[ -n "$terminfo[kf17]" ]] && key[F17]=$terminfo[kf17]
[[ -n "$terminfo[kf18]" ]] && key[F18]=$terminfo[kf18]
[[ -n "$terminfo[kf19]" ]] && key[F19]=$terminfo[kf19]
[[ -n "$terminfo[kf20]" ]] && key[F20]=$terminfo[kf20]
[[ -n "$terminfo[kbs]" ]] && key[Backspace]=$terminfo[kbs]
[[ -n "$terminfo[kich1]" ]] && key[Insert]=$terminfo[kich1]
[[ -n "$terminfo[kdch1]" ]] && key[Delete]=$terminfo[kdch1]
[[ -n "$terminfo[khome]" ]] && key[Home]=$terminfo[khome]
[[ -n "$terminfo[kend]" ]] && key[End]=$terminfo[kend]
[[ -n "$terminfo[kpp]" ]] && key[PageUp]=$terminfo[kpp]
[[ -n "$terminfo[knp]" ]] && key[PageDown]=$terminfo[knp]
[[ -n "$terminfo[kcuu1]" ]] && key[Up]=$terminfo[kcuu1]
[[ -n "$terminfo[kcub1]" ]] && key[Left]=$terminfo[kcub1]
[[ -n "$terminfo[kcud1]" ]] && key[Down]=$terminfo[kcud1]
[[ -n "$terminfo[kcuf1]" ]] && key[Right]=$terminfo[kcuf1]
fi
# Default key bindings
[[ -n ${key[Delete]} ]] && bindkey "${key[Delete]}" delete-char
[[ -n ${key[Home]} ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
[[ -n ${key[Up]} ]] && bindkey "${key[Up]}" up-line-or-search
[[ -n ${key[Down]} ]] && bindkey "${key[Down]}" down-line-or-search
# Default prompt
PS1="%n@%m %1~ %# "
# Useful support for interacting with Terminal.app or other terminal programs
[ -r "/etc/zshrc_$TERM_PROGRAM" ] && . "/etc/zshrc_$TERM_PROGRAM"
@@ -0,0 +1,7 @@
# Set up Nix only on SSH connections
# See: https://github.com/DeterminateSystems/nix-installer/pull/714
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ] && [ -n "${SSH_CONNECTION:-}" ] && [ "${SHLVL:-0}" -eq 1 ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
@@ -0,0 +1,14 @@
# Generated by https://github.com/DeterminateSystems/nix-installer.
# See `/nix/nix-installer --version` for the version details.
!include nix.custom.conf
experimental-features = nix-command flakes
always-allow-substitutes = true
extra-trusted-substituters = https://cache.flakehub.com
extra-trusted-public-keys = cache.flakehub.com-3:hJuILl5sVK4iKm86JzgdXW12Y2Hwd5G07qKtHTOcDCM= cache.flakehub.com-4:Asi8qIv291s0aYLyH6IOnr5Kf6+OF14WVjkE6t3xMio= cache.flakehub.com-5:zB96CRlL7tiPtzA9/WKyPkp3A2vqxqgdgyTVNGShPDU= cache.flakehub.com-6:W4EGFwAGgBj3he7c5fNh9NkOXw0PUVaxygCVKeuvaqU= cache.flakehub.com-7:mvxJ2DZVHn/kRxlIaxYNMuDG1OvMckZu32um1TadOR8= cache.flakehub.com-8:moO+OVS0mnTjBTcOUh2kYLQEd59ExzyoW1QgQ8XAARQ= cache.flakehub.com-9:wChaSeTI6TeCuV/Sg2513ZIM9i0qJaYsF+lZCXg0J6o= cache.flakehub.com-10:2GqeNlIp6AKp4EF2MVbE1kBOp9iBSyo0UPR9KoR0o1Y=
bash-prompt-prefix = (nix:$name)\040
max-jobs = auto
extra-nix-path = nixpkgs=flake:nixpkgs
upgrade-nix-store-path-url = https://install.determinate.systems/nix-upgrade/stable/universal
@@ -0,0 +1,4 @@
# Written by https://github.com/DeterminateSystems/nix-installer.
# The contents below are based on options specified at installation time.
@@ -0,0 +1,13 @@
# Generated by https://github.com/DeterminateSystems/nix-installer.
# See `/nix/nix-installer --version` for the version details.
extra-experimental-features = nix-command flakes
always-allow-substitutes = true
extra-trusted-substituters = https://cache.flakehub.com
extra-trusted-public-keys = cache.flakehub.com-3:hJuILl5sVK4iKm86JzgdXW12Y2Hwd5G07qKtHTOcDCM= cache.flakehub.com-4:Asi8qIv291s0aYLyH6IOnr5Kf6+OF14WVjkE6t3xMio= cache.flakehub.com-5:zB96CRlL7tiPtzA9/WKyPkp3A2vqxqgdgyTVNGShPDU= cache.flakehub.com-6:W4EGFwAGgBj3he7c5fNh9NkOXw0PUVaxygCVKeuvaqU= cache.flakehub.com-7:mvxJ2DZVHn/kRxlIaxYNMuDG1OvMckZu32um1TadOR8= cache.flakehub.com-8:moO+OVS0mnTjBTcOUh2kYLQEd59ExzyoW1QgQ8XAARQ= cache.flakehub.com-9:wChaSeTI6TeCuV/Sg2513ZIM9i0qJaYsF+lZCXg0J6o= cache.flakehub.com-10:2GqeNlIp6AKp4EF2MVbE1kBOp9iBSyo0UPR9KoR0o1Y=
bash-prompt-prefix = (nix:$name)\040
max-jobs = auto
extra-nix-path = nixpkgs=flake:nixpkgs
upgrade-nix-store-path-url = https://install.determinate.systems/nix-upgrade/stable/universal
!include nix.custom.conf
@@ -0,0 +1,3 @@
# Written by https://github.com/NixOS/nix-installer
# The contents below are based on options specified at installation time.
@@ -0,0 +1,10 @@
# Generated by https://github.com/NixOS/nix-installer
# See `/nix/nix-installer --version` for the version details.
extra-experimental-features = nix-command flakes
always-allow-substitutes = true
bash-prompt-prefix = (nix:$name)\040
max-jobs = auto
extra-nix-path = nixpkgs=flake:nixpkgs
!include nix.custom.conf
@@ -0,0 +1,11 @@
# Generated by https://install.lix.systems/.
# See `/nix/lix-installer --version` for the version details.
extra-experimental-features = nix-command
always-allow-substitutes = true
extra-trusted-substituters = https://cache.lix.systems
extra-trusted-public-keys = cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o=
bash-prompt-prefix = (nix:$name)\040
max-jobs = auto
!include nix.custom.conf
@@ -0,0 +1,3 @@
# Written by https://install.lix.systems/.
# The contents below are based on options specified at installation time.
@@ -0,0 +1,81 @@
# System-wide profile for interactive zsh(1) shells.
# Setup user specific overrides for this in ~/.zshrc. See zshbuiltins(1)
# and zshoptions(1) for more details.
# Correctly display UTF-8 with combining characters. We'll assume UTF-8 if the
# locale(1) binary is missing entirely.
if [[ ! -x /usr/bin/locale ]] || [[ "$(locale LC_CTYPE)" == "UTF-8" ]]; then
setopt COMBINING_CHARS
fi
# Disable the log builtin, so we don't conflict with /usr/bin/log
disable log
# Save command history
HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history
HISTSIZE=2000
SAVEHIST=1000
# Beep on error
setopt BEEP
# Use keycodes (generated via zkbd) if present, otherwise fallback on
# values from terminfo
if [[ -r ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR} ]] ; then
source ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR}
else
typeset -g -A key
[[ -n "$terminfo[kf1]" ]] && key[F1]=$terminfo[kf1]
[[ -n "$terminfo[kf2]" ]] && key[F2]=$terminfo[kf2]
[[ -n "$terminfo[kf3]" ]] && key[F3]=$terminfo[kf3]
[[ -n "$terminfo[kf4]" ]] && key[F4]=$terminfo[kf4]
[[ -n "$terminfo[kf5]" ]] && key[F5]=$terminfo[kf5]
[[ -n "$terminfo[kf6]" ]] && key[F6]=$terminfo[kf6]
[[ -n "$terminfo[kf7]" ]] && key[F7]=$terminfo[kf7]
[[ -n "$terminfo[kf8]" ]] && key[F8]=$terminfo[kf8]
[[ -n "$terminfo[kf9]" ]] && key[F9]=$terminfo[kf9]
[[ -n "$terminfo[kf10]" ]] && key[F10]=$terminfo[kf10]
[[ -n "$terminfo[kf11]" ]] && key[F11]=$terminfo[kf11]
[[ -n "$terminfo[kf12]" ]] && key[F12]=$terminfo[kf12]
[[ -n "$terminfo[kf13]" ]] && key[F13]=$terminfo[kf13]
[[ -n "$terminfo[kf14]" ]] && key[F14]=$terminfo[kf14]
[[ -n "$terminfo[kf15]" ]] && key[F15]=$terminfo[kf15]
[[ -n "$terminfo[kf16]" ]] && key[F16]=$terminfo[kf16]
[[ -n "$terminfo[kf17]" ]] && key[F17]=$terminfo[kf17]
[[ -n "$terminfo[kf18]" ]] && key[F18]=$terminfo[kf18]
[[ -n "$terminfo[kf19]" ]] && key[F19]=$terminfo[kf19]
[[ -n "$terminfo[kf20]" ]] && key[F20]=$terminfo[kf20]
[[ -n "$terminfo[kbs]" ]] && key[Backspace]=$terminfo[kbs]
[[ -n "$terminfo[kich1]" ]] && key[Insert]=$terminfo[kich1]
[[ -n "$terminfo[kdch1]" ]] && key[Delete]=$terminfo[kdch1]
[[ -n "$terminfo[khome]" ]] && key[Home]=$terminfo[khome]
[[ -n "$terminfo[kend]" ]] && key[End]=$terminfo[kend]
[[ -n "$terminfo[kpp]" ]] && key[PageUp]=$terminfo[kpp]
[[ -n "$terminfo[knp]" ]] && key[PageDown]=$terminfo[knp]
[[ -n "$terminfo[kcuu1]" ]] && key[Up]=$terminfo[kcuu1]
[[ -n "$terminfo[kcub1]" ]] && key[Left]=$terminfo[kcub1]
[[ -n "$terminfo[kcud1]" ]] && key[Down]=$terminfo[kcud1]
[[ -n "$terminfo[kcuf1]" ]] && key[Right]=$terminfo[kcuf1]
fi
# Default key bindings
[[ -n ${key[Delete]} ]] && bindkey "${key[Delete]}" delete-char
[[ -n ${key[Home]} ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
[[ -n ${key[Up]} ]] && bindkey "${key[Up]}" up-line-or-search
[[ -n ${key[Down]} ]] && bindkey "${key[Down]}" down-line-or-search
# Default prompt
PS1="%n@%m %1~ %# "
# Useful support for interacting with Terminal.app or other terminal programs
[ -r "/etc/zshrc_$TERM_PROGRAM" ] && . "/etc/zshrc_$TERM_PROGRAM"
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
@@ -0,0 +1,12 @@
# Generated by https://install.lix.systems/.
# See `/nix/lix-installer --version` for the version details.
extra-experimental-features = nix-command flakes
always-allow-substitutes = true
extra-trusted-substituters = https://cache.lix.systems
extra-trusted-public-keys = cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o=
bash-prompt-prefix = (nix:$name)\040
max-jobs = auto
extra-nix-path = nixpkgs=flake:nixpkgs
!include nix.custom.conf
@@ -0,0 +1,12 @@
# System-wide profile for interactive zsh(1) login shells.
# Setup user specific overrides for this in ~/.zprofile. See zshbuiltins(1)
# and zshoptions(1) for more details.
if [ -z "$LANG" ]; then
export LANG=C.UTF-8
fi
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
+5 -6
View File
@@ -30,7 +30,7 @@ let
declarations = map
(decl:
if lib.hasPrefix (toString prefix) (toString decl) then
gitHubDeclaration "LnL7" "nix-darwin" revision
gitHubDeclaration "nix-darwin" "nix-darwin" revision
(lib.removePrefix "/"
(lib.removePrefix (toString prefix) (toString decl)))
# TODO: handle this in a better way (may require upstream
@@ -53,7 +53,7 @@ in rec {
substitute \
${optionsDoc.optionsJSON}/nix-support/hydra-build-products \
$out/nix-support/hydra-build-products \
--replace \
--replace-fail \
'${optionsDoc.optionsJSON}/share/doc/nixos' \
"$out/share/doc/darwin"
'';
@@ -74,8 +74,8 @@ in rec {
cp -r ${pkgs.documentation-highlighter} $dst/highlightjs
substitute ${./manual.md} manual.md \
--replace '@DARWIN_VERSION@' "${version}" \
--replace \
--replace-fail '@DARWIN_VERSION@' "${version}" \
--replace-fail \
'@DARWIN_OPTIONS_JSON@' \
${optionsJSON}/share/doc/darwin/options.json
@@ -94,8 +94,7 @@ in rec {
--stylesheet highlightjs/mono-blue.css \
--script ./highlightjs/highlight.pack.js \
--script ./highlightjs/loader.js \
--toc-depth 1 \
--chunk-toc-depth 1 \
--sidebar-depth 1 \
./manual.md \
$dst/index.html
+24
View File
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>nix-darwin</title>
<script>
window.location.replace("https://github.com/nix-darwin/nix-darwin#readme");
</script>
<noscript>
<meta
http-equiv="refresh"
content="0; url=https://github.com/nix-darwin/nix-darwin#readme">
</noscript>
</head>
<body>
<h1>nix-darwin</h1>
<p>
nix-darwin is a declarative configuration system for macOS, based
on Nix. See the
<a href="https://github.com/nix-darwin/nix-darwin#readme">GitHub
repository</a> for more information.
</p>
</body>
</html>
+12 -14
View File
@@ -37,7 +37,7 @@ assert enableNixpkgsReleaseCheck -> checkRelease lib || throw ''
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/NIXPKGS-BRANCH";
nix-darwin.url = "github:LnL7/nix-darwin/NIX-DARWIN-BRANCH";
nix-darwin.url = "github:nix-darwin/nix-darwin/NIX-DARWIN-BRANCH";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
#
};
@@ -46,7 +46,7 @@ assert enableNixpkgsReleaseCheck -> checkRelease lib || throw ''
$ sudo nix-channel --list
nixpkgs https://nixos.org/channels/NIXPKGS-BRANCH
darwin https://github.com/LnL7/nix-darwin/archive/NIX-DARWIN-BRANCH.tar.gz
darwin https://github.com/nix-darwin/nix-darwin/archive/NIX-DARWIN-BRANCH.tar.gz
$ nix-channel --list
@@ -58,12 +58,12 @@ assert enableNixpkgsReleaseCheck -> checkRelease lib || throw ''
You can then fix your channels like this:
$ sudo nix-channel --add https://nixos.org/channels/NIXPKGS-BRANCH nixpkgs
$ sudo nix-channel --add https://github.com/LnL7/nix-darwin/archive/NIX-DARWIN-BRANCH.tar.gz darwin
$ sudo nix-channel --add https://github.com/nix-darwin/nix-darwin/archive/NIX-DARWIN-BRANCH.tar.gz darwin
$ sudo nix-channel --update
After that, activating your system again should work correctly. If it
doesnt, please open an issue at
<https://github.com/LnL7/nix-darwin/issues/new> and include as much
<https://github.com/nix-darwin/nix-darwin/issues/new> and include as much
information as possible.
'';
@@ -77,17 +77,15 @@ let
};
};
eval = lib.evalModules (builtins.removeAttrs args [ "lib" ] // {
eval = lib.evalModules (builtins.removeAttrs args [ "lib" "enableNixpkgsReleaseCheck" ] // {
class = "darwin";
modules = modules ++ [ argsModule ] ++ baseModules;
specialArgs = { modulesPath = builtins.toString ./modules; } // specialArgs;
});
in
{
inherit (eval._module.args) pkgs;
inherit (eval) options config;
inherit (eval) _module;
system = eval.config.system.build.toplevel;
}
withExtraAttrs = configuration: configuration // {
inherit (configuration._module.args) pkgs;
system = configuration.config.system.build.toplevel;
extendModules = args: withExtraAttrs (configuration.extendModules args);
};
in withExtraAttrs eval
+11
View File
@@ -0,0 +1,11 @@
{
lib,
...
}:
{
options.flake.darwinConfigurations = lib.mkOption {
type = lib.types.lazyAttrsOf lib.types.raw;
default = { };
description = "Darwin system configurations";
};
}
Generated
+3 -3
View File
@@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1736241350,
"narHash": "sha256-CHd7yhaDigUuJyDeX0SADbTM9FXfiWaeNyY34FL1wQU=",
"lastModified": 1783279667,
"narHash": "sha256-/NAkDSsve+GNM0Bt6tleJdCGfsTlK89nPjkVOzZMo0s=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8c9fd3e564728e90829ee7dbac6edc972971cd0f",
"rev": "f205b5574fd0cb7da5b702a2da51507b7f4fdd1b",
"type": "github"
},
"original": {
+9
View File
@@ -56,6 +56,8 @@
darwin-uninstaller = prev.callPackage ./pkgs/darwin-uninstaller { };
};
flakeModules.default = ./flake-module.nix;
darwinModules.hydra = ./modules/examples/hydra.nix;
darwinModules.lnl = ./modules/examples/lnl.nix;
darwinModules.simple = ./modules/examples/simple.nix;
@@ -78,6 +80,13 @@
default = self.packages.${system}.darwin-rebuild;
inherit (pkgs) darwin-option darwin-rebuild darwin-version darwin-uninstaller;
# TODO: Include manuals for active release branches in the website.
# (This may involve moving it to a separate repository.)
website = pkgs.linkFarm "nix-darwin-website" {
"index.html" = ./doc/website/index.html;
manual = "${self.packages.${system}.manualHTML}/share/doc/darwin";
};
})));
};
}
+149
View File
@@ -0,0 +1,149 @@
# This module defines the packages that appear in
# /run/current-system/sw.
{
config,
lib,
pkgs,
...
}:
let
makeDrvBinPath = lib.concatMapStringsSep ":" (p: if lib.isDerivation p then "${p}/bin" else p);
defaultPackageNames = [ ];
defaultPackages = map (
n:
let
pkg = pkgs.${n};
in
lib.setPrio ((pkg.meta.priority or lib.meta.defaultPriority) + 3) pkg
) defaultPackageNames;
defaultPackagesText = "[ ${lib.concatMapStringsSep " " (n: "pkgs.${n}") defaultPackageNames} ]";
in
{
imports = [
(lib.mkRenamedOptionModule ["environment" "postBuild"] ["environment" "extraSetup"])
];
options = {
environment = {
systemPath = lib.mkOption {
type = lib.types.listOf (lib.types.either lib.types.path lib.types.str);
description = "The set of paths that are added to PATH.";
apply = x: if lib.isList x then makeDrvBinPath x else x;
};
systemPackages = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [ ];
example = lib.literalExpression "[ pkgs.firefox pkgs.thunderbird ]";
description = ''
The set of packages that appear in
/run/current-system/sw. These packages are
automatically available to all users, and are
automatically updated every time you rebuild the system
configuration. (The latter is the main difference with
installing them in the default profile,
{file}`/nix/var/nix/profiles/default`.
'';
};
defaultPackages = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = defaultPackages;
defaultText = lib.literalMD ''
these packages, with their `meta.priority` numerically increased
(thus lowering their installation priority):
${defaultPackagesText}
'';
example = [ ];
description = ''
Set of default packages that aren't strictly necessary
for a running system, entries can be removed for a more
minimal NixOS installation.
Like with systemPackages, packages are installed to
{file}`/run/current-system/sw`. They are
automatically available to all users, and are
automatically updated every time you rebuild the system
configuration.
'';
};
pathsToLink = lib.mkOption {
type = lib.types.listOf lib.types.str;
# According to https://github.com/NixOS/nixpkgs/blob/2795c506fe8fb7b03c36ccb51f75b6df0ab2553f/nixos/modules/config/system-path.nix#L108-L109
# `/lib` needs to be added to make NSS modules work, however currently we don't add it
# and it's unclear whether the comment applies on macOS as well.
default = [ ];
example = [ "/share/doc" ];
description = "List of directories to be symlinked in {file}`/run/current-system/sw`.";
};
extraOutputsToInstall = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
example = [
"dev"
"info"
];
description = ''
Entries listed here will be appended to the `meta.outputsToInstall` attribute for each package in `environment.systemPackages`, and the files from the corresponding derivation outputs symlinked into {file}`/run/current-system/sw`.
For example, this can be used to install the `dev` and `info` outputs for all packages in the system environment, if they are available.
To use specific outputs instead of configuring them globally, select the corresponding attribute on the package derivation, e.g. `libxml2.dev` or `coreutils.info`.
'';
};
extraSetup = lib.mkOption {
type = lib.types.lines;
default = "";
description = "Shell fragments to be run after the system environment has been created. This should only be used for things that need to modify the internals of the environment, e.g. generating MIME caches. The environment being built can be accessed at $out.";
};
};
system = {
path = lib.mkOption {
internal = true;
description = ''
The packages you want in the system environment.
'';
};
};
};
config = {
environment.systemPackages = config.environment.defaultPackages;
environment.pathsToLink = [
"/bin"
"/share/locale"
];
system.path = pkgs.buildEnv {
name = "system-path";
paths = config.environment.systemPackages;
inherit (config.environment) pathsToLink extraOutputsToInstall;
ignoreCollisions = true;
# !!! Hacky, should modularise.
# outputs TODO: note that the tools will often not be linked by default
postBuild = ''
# Remove wrapped binaries, they shouldn't be accessible via PATH.
find $out/bin -maxdepth 1 -name ".*-wrapped" -type l -delete
${config.environment.extraSetup}
'';
};
};
}
+90
View File
@@ -0,0 +1,90 @@
# This module manages the terminfo database
# and its integration in the system.
{
config,
lib,
pkgs,
...
}:
{
options = {
environment.enableAllTerminfo = lib.mkOption {
default = false;
type = lib.types.bool;
description = ''
Whether to install all terminfo outputs
'';
};
security.sudo.keepTerminfo = lib.mkOption {
default = true;
type = lib.types.bool;
description = ''
Whether to preserve the `TERMINFO` and `TERMINFO_DIRS`
environment variables, for `root` and the `admin` group.
'';
};
};
config = {
# This should not contain packages that are broken or can't build, since it
# will break this expression
#
# can be generated with:
# lib.attrNames (lib.filterAttrs
# (_: drv: (builtins.tryEval (
# lib.isDerivation drv && drv ? terminfo && drv.meta.available && !drv.meta.broken && !drv.meta.unsupported)).value)
# pkgs)
environment.systemPackages = lib.mkIf config.environment.enableAllTerminfo (
map (x: x.terminfo) (
with pkgs.pkgsBuildBuild;
[
alacritty
alacritty-graphics
ghostty-bin
kitty
mtm
rio
rxvt-unicode-unwrapped
rxvt-unicode-unwrapped-emoji
st
tmux
wezterm
]
)
);
environment.pathsToLink = [
"/share/terminfo"
];
environment.etc.terminfo = {
source = "${config.system.path}/share/terminfo";
};
# TODO: use `environment.profileRelativeSessionVariables`
environment.variables = {
TERMINFO_DIRS = map (path: path + "/share/terminfo") config.environment.profiles ++ [ "/usr/share/terminfo" ];
};
environment.extraInit = ''
# reset TERM with new TERMINFO available (if any)
export TERM=$TERM
'';
security =
let
extraConfig = ''
# Keep terminfo database for root and %admin.
Defaults:root,%admin env_keep+=TERMINFO_DIRS
Defaults:root,%admin env_keep+=TERMINFO
'';
in
lib.mkIf config.security.sudo.keepTerminfo {
sudo = { inherit extraConfig; };
};
};
}
+31 -72
View File
@@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ options, config, lib, pkgs, ... }:
with lib;
@@ -11,13 +11,10 @@ let
aliasCommands =
mapAttrsToList (n: v: ''alias ${n}=${escapeShellArg v}'')
(filterAttrs (k: v: v != null) cfg.shellAliases);
makeDrvBinPath = concatMapStringsSep ":" (p: if isDerivation p then "${p}/bin" else p);
in
{
imports = [
(mkRenamedOptionModule ["environment" "postBuild"] ["environment" "extraSetup"])
(mkRemovedOptionModule [ "environment" "loginShell" ] ''
This option was only used to change the default command in tmux.
@@ -26,49 +23,30 @@ in
];
options = {
environment.systemPackages = mkOption {
type = types.listOf types.package;
default = [];
example = literalExpression "[ pkgs.curl pkgs.vim ]";
description = ''
The set of packages that appear in
/run/current-system/sw. These packages are
automatically available to all users, and are
automatically updated every time you rebuild the system
configuration. (The latter is the main difference with
installing them in the default profile,
{file}`/nix/var/nix/profiles/default`.
'';
};
environment.systemPath = mkOption {
type = types.listOf (types.either types.path types.str);
description = "The set of paths that are added to PATH.";
apply = x: if isList x then makeDrvBinPath x else x;
};
environment.profiles = mkOption {
type = types.listOf types.str;
description = "A list of profiles used to setup the global environment.";
};
environment.extraOutputsToInstall = mkOption {
type = types.listOf types.str;
default = [];
example = [ "doc" "info" "devdoc" ];
description = "List of additional package outputs to be symlinked into {file}`/run/current-system/sw`.";
};
environment.pathsToLink = mkOption {
type = types.listOf types.str;
default = [];
example = [ "/share/doc" ];
description = "List of directories to be symlinked in {file}`/run/current-system/sw`.";
};
environment.darwinConfig = mkOption {
type = types.either types.path types.str;
default = "$HOME/.nixpkgs/darwin-configuration.nix";
type = types.nullOr (types.either types.path types.str);
default =
if config.nixpkgs.flake.setNixPath then
# Dont set this for flakebased systems.
null
else if config.system.stateVersion >= 6 then
"/etc/nix-darwin/configuration.nix"
else
"${config.system.primaryUserHome}/.nixpkgs/darwin-configuration.nix";
defaultText = literalExpression ''
if config.nixpkgs.flake.setNixPath then
# Dont set this for flakebased systems.
null
else if config.system.stateVersion >= 6 then
"/etc/nix-darwin/configuration.nix"
else
"''${config.system.primaryUserHome}/.nixpkgs/darwin-configuration.nix"
'';
description = ''
The path of the darwin configuration.nix used to configure the system,
this updates the default darwin-config entry in NIX_PATH. Since this
@@ -110,7 +88,7 @@ in
description = ''
Shell script code called during global environment initialisation
after all variables and profileVariables have been set.
This code is asumed to be shell-independent, which means you should
This code is assumed to be shell-independent, which means you should
stick to pure sh without sh word split.
'';
};
@@ -144,24 +122,23 @@ in
'';
type = types.lines;
};
environment.extraSetup = mkOption {
type = types.lines;
default = "";
description = ''
Shell fragments to be run after the system environment has been created.
This should only be used for things that need to modify the internals
of the environment, e.g. generating MIME caches.
The environment being built can be accessed at $out.
'';
};
};
config = {
# This is horrible, sorry.
system.requiresPrimaryUser = mkIf (
config.nix.enable
&& !config.nixpkgs.flake.setNixPath
&& config.system.stateVersion < 6
&& options.environment.darwinConfig.highestPrio == (mkOptionDefault {}).priority
) [
"environment.darwinConfig"
];
environment.systemPath = mkMerge [
[ (makeBinPath cfg.profiles) ]
(mkOrder 1200 [ "/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin" ])
(mkOrder 1200 [ "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" ])
];
# Use user, default and system profiles.
@@ -170,16 +147,7 @@ in
[ "/run/current-system/sw" "/nix/var/nix/profiles/default" ]
];
environment.pathsToLink = [
"/bin"
"/share/locale"
"/share/terminfo"
];
environment.extraInit = ''
# reset TERM with new TERMINFO available (if any)
export TERM=$TERM
export NIX_USER_PROFILE_DIR="/nix/var/nix/profiles/per-user/$USER"
export NIX_PROFILES="${concatStringsSep " " (reverseList cfg.profiles)}"
'';
@@ -188,19 +156,10 @@ in
{
XDG_CONFIG_DIRS = map (path: path + "/etc/xdg") cfg.profiles;
XDG_DATA_DIRS = map (path: path + "/share") cfg.profiles;
TERMINFO_DIRS = map (path: path + "/share/terminfo") cfg.profiles ++ [ "/usr/share/terminfo" ];
EDITOR = mkDefault "nano";
PAGER = mkDefault "less -R";
};
system.path = pkgs.buildEnv {
name = "system-path";
paths = cfg.systemPackages;
postBuild = cfg.extraSetup;
ignoreCollisions = true;
inherit (cfg) pathsToLink extraOutputsToInstall;
};
system.build.setEnvironment = pkgs.writeText "set-environment" ''
# Prevent this file from being sourced by child shells.
export __NIX_DARWIN_SET_ENVIRONMENT_DONE=1
+2 -2
View File
@@ -3,7 +3,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nix-darwin.url = "github:LnL7/nix-darwin/master";
nix-darwin.url = "github:nix-darwin/nix-darwin/master";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
};
@@ -27,7 +27,7 @@
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 5;
system.stateVersion = 6;
# The platform the configuration will be used on.
nixpkgs.hostPlatform = "aarch64-darwin";
+1 -1
View File
@@ -43,5 +43,5 @@ in
echo "ok"
'';
system.stateVersion = 5;
system.stateVersion = 6;
}
+4 -5
View File
@@ -1,6 +1,8 @@
{ config, lib, inputs, pkgs, ... }:
{
system.primaryUser = "lnl";
system.defaults.NSGlobalDomain.AppleKeyboardUIMode = 3;
system.defaults.NSGlobalDomain.ApplePressAndHoldEnabled = false;
system.defaults.NSGlobalDomain.InitialKeyRepeat = 10;
@@ -48,8 +50,6 @@
pkgs.jq
pkgs.ripgrep
pkgs.shellcheck
pkgs.qes
];
services.yabai.enable = true;
@@ -199,7 +199,7 @@
programs.zsh.enableFzfGit = true;
programs.zsh.enableFzfHistory = true;
programs.zsh.variables.cfg = "$HOME/.config/nixpkgs/darwin/configuration.nix";
programs.zsh.variables.cfg = "/etc/nix-darwin/configuration.nix";
programs.zsh.variables.darwin = "$HOME/.nix-defexpr/darwin";
programs.zsh.variables.nixpkgs = "$HOME/.nix-defexpr/nixpkgs";
@@ -319,8 +319,7 @@
# path = /etc/per-user/lnl/gitconfig
# environment.etc."per-user/lnl/gitconfig".text = builtins.readFile "${inputs.dotfiles}/git/gitconfig";
nix.configureBuildUsers = true;
nix.nrBuildUsers = 32;
system.stateVersion = 5;
system.stateVersion = 6;
}
+1 -4
View File
@@ -7,13 +7,10 @@
[ pkgs.vim
];
# Use custom location for configuration.nix.
environment.darwinConfig = "$HOME/.config/nix-darwin/configuration.nix";
# Enable alternative shell support in nix-darwin.
# programs.fish.enable = true;
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 5;
system.stateVersion = 6;
}
+370 -125
View File
@@ -12,7 +12,7 @@ let
mkBrewfileSectionString = heading: entries: optionalString (entries != [ ]) ''
# ${heading}
${concatMapStringsSep "\n" (v: v.brewfileLine or v) entries}
${concatStringsSep "\n" (unique (map (v: v.brewfileLine or v) entries))}
'';
@@ -28,9 +28,23 @@ let
mkBrewfileLineOptionsListString = attrs:
concatStringsSep ", " (mapAttrsToList (n: v: "${n}: ${v}") attrs);
# Renders a Brewfile option that can be either a bool or a Ruby symbol (e.g. `:overwrite`).
mkBrewfileLineBoolOrSymbolString = name: config: sCfg:
optionalString (hasAttr name sCfg) (
", ${name}: " + (
if isBool config.${name} then sCfg.${name}
else ":${config.${name}}"
)
);
# Option and submodule helper functions ----------------------------------------------------------
mkShellIntegrationOption = shell: mkEnableOption ''
Homebrew ${shell} shell integration, which sets up Homebrew's environment
and shell completions
'';
mkNullOrBoolOption = args: mkOption (args // {
type = types.nullOr types.bool;
default = null;
@@ -54,37 +68,44 @@ let
# Submodules -------------------------------------------------------------------------------------
# Option values and descriptions of Brewfile entries are sourced/derived from:
# * `brew` manpage: https://docs.brew.sh/Manpage
# * `brew bundle` source files (at https://github.com/Homebrew/homebrew-bundle/tree/9fffe077f1a5a722ed5bd26a87ed622e8cb64e0c):
# * lib/bundle/dsl.rb
# * lib/bundle/{brew,cask,tap}_installer.rb
# * spec/bundle/{brew,cask,tap}_installer_spec.rb
# * `brew bundle` source files (at https://github.com/Homebrew/brew/tree/master/Library/Homebrew/bundle):
# * dsl.rb
# * {brew,cask,tap}_installer.rb
# * ../test/bundle/{brew,cask,tap}_installer_spec.rb
onActivationOptions = { config, ... }: {
options = {
cleanup = mkOption {
type = types.enum [ "none" "uninstall" "zap" ];
type = types.enum [ "none" "check" "uninstall" "zap" ];
default = "none";
example = "uninstall";
description = ''
This option manages what happens to formulae installed by Homebrew, that aren't present in
This option manages what happens to packages installed by Homebrew that aren't present in
the Brewfile generated by this module, during {command}`nix-darwin` system
activation.
When set to `"none"` (the default), formulae not present in the generated
When set to `"none"` (the default), packages not present in the generated
Brewfile are left installed.
When set to `"check"`, {command}`nix-darwin` verifies during system activation that no
Homebrew packages (taps, formulae, casks, etc.) are installed that aren't present in the
generated Brewfile. If extra packages are found, activation fails with a list of them.
Note that when this check fails during {command}`darwin-rebuild switch`, the entire
system activation is aborted and no other configuration changes will be applied until
the issue is resolved.
When set to `"uninstall"`, {command}`nix-darwin` invokes
{command}`brew bundle [install]` with the {command}`--cleanup` flag. This
uninstalls all formulae not listed in generated Brewfile, i.e.,
{command}`brew uninstall` is run for those formulae.
uninstalls all packages not listed in the generated Brewfile, i.e.,
{command}`brew uninstall` is run for those packages.
When set to `"zap"`, {command}`nix-darwin` invokes
{command}`brew bundle [install]` with the {command}`--cleanup --zap`
flags. This uninstalls all formulae not listed in the generated Brewfile, and if the
formula is a cask, removes all files associated with that cask. In other words,
{command}`brew uninstall --zap` is run for all those formulae.
flags. This uninstalls all packages not listed in the generated Brewfile, and if the
package is a cask, removes all files associated with that cask. In other words,
{command}`brew uninstall --zap` is run for all those packages.
If you plan on exclusively using {command}`nix-darwin` to manage formulae
If you plan on exclusively using {command}`nix-darwin` to manage packages
installed by Homebrew, you probably want to set this option to
`"uninstall"` or `"zap"`.
'';
@@ -97,7 +118,7 @@ let
{command}`nix-darwin` system activation. The default is `false`
so that repeated invocations of {command}`darwin-rebuild switch` are idempotent.
Note that Homebrew auto-updates when it's been more then 5 minutes since it last updated.
Note that Homebrew auto-updates when it's been more than 5 minutes since it last updated.
Although auto-updating is disabled by default during system activation, note that Homebrew
will auto-update when you manually invoke certain Homebrew commands. To modify this
@@ -121,6 +142,26 @@ let
activation.
'';
};
extraEnv = mkOption {
type = types.attrsOf types.str;
default = { };
example = {
HOMEBREW_NO_ENV_HINTS = "1";
HOMEBREW_NO_ANALYTICS = "1";
};
description = ''
Extra environment variables to set when {command}`nix-darwin` invokes
{command}`brew bundle [install]` during system checks and activation.
Useful for setting Homebrew's `HOMEBREW_NO_*` variables (e.g.,
`HOMEBREW_NO_ENV_HINTS`, `HOMEBREW_NO_ANALYTICS`, `HOMEBREW_NO_UPDATE_REPORT_NEW`)
that aren't inherited from the user's shell environment because activation runs
under sudo.
Each entry is prepended to the {command}`brew bundle` invocation in the form
`KEY=VALUE`, alongside `HOMEBREW_NO_AUTO_UPDATE=1` when applicable.
'';
};
extraFlags = mkOption {
type = types.listOf types.str;
default = [ ];
@@ -131,17 +172,31 @@ let
'';
};
brewBundleCmd = mkInternalOption { type = types.str; };
brewBundleCmd = mkInternalOption { type = types.functionTo types.str; };
};
config = {
brewBundleCmd = concatStringsSep " " (
optional (!config.autoUpdate) "HOMEBREW_NO_AUTO_UPDATE=1"
++ [ "brew bundle --file='${brewfileFile}' --no-lock" ]
++ optional (!config.upgrade) "--no-upgrade"
++ optional (config.cleanup == "uninstall") "--cleanup"
++ optional (config.cleanup == "zap") "--cleanup --zap"
++ config.extraFlags
brewBundleCmd = { onlyCheck }: concatStringsSep " " (
[
''PATH="${cfg.prefix}/bin:${lib.makeBinPath [ pkgs.mas ]}:$PATH"''
"sudo"
"--preserve-env=PATH"
"--user=${escapeShellArg cfg.user}"
"--set-home"
"env"
]
++ optional (onlyCheck || !config.autoUpdate) "HOMEBREW_NO_AUTO_UPDATE=1"
++ mapAttrsToList (k: v: "${k}=${escapeShellArg v}") config.extraEnv
++ [ "brew bundle --file='${brewfileFile}'" ]
++ (
if onlyCheck then
[ "cleanup 2>&1" ]
else
optional (!config.upgrade) "--no-upgrade"
++ optional (config.cleanup == "uninstall") "--force-cleanup"
++ optional (config.cleanup == "zap") "--zap --force-cleanup"
++ config.extraFlags
)
);
};
};
@@ -155,14 +210,6 @@ let
Whether to enable Homebrew to automatically use the Brewfile that this module generates in
the Nix store, when you manually invoke {command}`brew bundle`.
Enabling this option will change the default value of
[](#opt-homebrew.global.lockfiles) to `false` since, with
this option enabled, {command}`brew bundle [install]` will default to using the
Brewfile that this module generates in the Nix store, unless you explicitly point it at
another Brewfile using the `--file` flag. As a result, it will try to
write the lockfile in the Nix store, and complain that it can't (though the command will
run successfully regardless).
Implementation note: when enabled, this option sets the
`HOMEBREW_BUNDLE_FILE` environment variable to the path of the Brewfile
that this module generates in the Nix store, by adding it to
@@ -178,7 +225,7 @@ let
{command}`brew tap`, and {command}`brew bundle [install]`.
Note that Homebrew auto-updates when you manually invoke commands like the ones mentioned
above if it's been more then 5 minutes since it last updated.
above if it's been more than 5 minutes since it last updated.
You may want to consider disabling this option if you have
[](#opt-homebrew.onActivation.upgrade) enabled, and
@@ -191,31 +238,13 @@ let
[](#opt-environment.variables).
'';
};
lockfiles = mkOption {
type = types.bool;
default = !config.brewfile;
defaultText = literalExpression "!config.homebrew.global.brewfile";
description = ''
Whether to enable Homebrew to generate lockfiles when you manually invoke
{command}`brew bundle [install]`.
This option will default to `false` if
[](#opt-homebrew.global.brewfile) is enabled since, with that option enabled,
{command}`brew bundle [install]` will default to using the Brewfile that this
module generates in the Nix store, unless you explicitly point it at another Brewfile
using the `--file` flag. As a result, it will try to write the
lockfile in the Nix store, and complain that it can't (though the command will run
successfully regardless).
Implementation note: when disabled, this option sets the
`HOMEBREW_BUNDLE_NO_LOCK` environment variable, by adding it to
[](#opt-environment.variables).
'';
};
# The `noLock` option was replaced by `lockfiles`. Due to `homebrew.global` being a submodule,
# we can't use `mkRemovedOptionModule`, so we leave this option definition here, and trigger
# and error message with an assertion below if it's set by the user.
# `noLock` was the original option; `lockfiles` replaced it (with inverted semantics).
# Both are now dead: Homebrew Bundle removed lockfile support in Homebrew 4.4.0
# (Oct 2024), so the `HOMEBREW_BUNDLE_NO_LOCK` env var and `--no-lock` CLI flag are
# ignored. We keep both definitions with null defaults to detect explicit user
# configuration and emit a warning below. We can't use `mkRemovedOptionModule` because
# `homebrew.global` is a submodule.
lockfiles = mkOption { visible = false; default = null; };
noLock = mkOption { visible = false; default = null; };
homebrewEnvironmentVariables = mkInternalOption { type = types.attrs; };
@@ -225,7 +254,6 @@ let
homebrewEnvironmentVariables = {
HOMEBREW_BUNDLE_FILE = mkIf config.brewfile "${brewfileFile}";
HOMEBREW_NO_AUTO_UPDATE = mkIf (!config.autoUpdate) "1";
HOMEBREW_BUNDLE_NO_LOCK = mkIf (!config.lockfiles) "1";
};
};
};
@@ -234,7 +262,7 @@ let
options = {
name = mkOption {
type = types.str;
example = "homebrew/cask-fonts";
example = "apple/apple";
description = ''
When {option}`clone_target` is unspecified, this is the name of a formula
repository to tap from GitHub using HTTPS. For example, `"user/repo"`
@@ -253,6 +281,25 @@ let
description = ''
Whether to auto-update the tap even if it is not hosted on GitHub. By default, only taps
hosted on GitHub are auto-updated (for performance reasons).
Note: Homebrew Bundle accepts this option in Brewfile syntax but may silently ignore it
during installation. See [the Homebrew Bundle source](https://github.com/Homebrew/brew/tree/master/Library/Homebrew/bundle)
for current behavior.
'';
};
trusted = mkOption {
type = types.bool;
default = false;
example = true;
description = ''
Whether to trust this tap during {command}`nix-darwin` system activation, by adding the
`trusted: true` option to its {command}`brew bundle` Brewfile entry.
Homebrew 6.0.0 enabled `HOMEBREW_REQUIRE_TAP_TRUST` by default, which refuses to
load formulae/casks from non-official taps that haven't been trusted, aborting activation.
Set this to `true` for non-official taps you control so their formulae and casks are
installed during activation. Official taps are always trusted, so this has no effect only
them.
'';
};
@@ -268,7 +315,8 @@ let
"tap ${sCfg.name}"
+ optionalString (sCfg ? clone_target) ", ${sCfg.clone_target}"
+ optionalString (sCfg ? force_auto_update)
", force_auto_update: ${sCfg.force_auto_update}";
", force_auto_update: ${sCfg.force_auto_update}"
+ optionalString config.trusted ", trusted: true";
};
};
@@ -385,19 +433,34 @@ let
};
require_sha = mkNullOrBoolOption {
description = ''
Whether to require cask(s) to have a checksum.
Whether to require casks to have a checksum.
Homebrew's default is `false`.
'';
};
no_quarantine = mkNullOrBoolOption {
description = "Whether to disable quarantining of downloads.";
description = ''
Whether to disable quarantining of downloads.
Note: this option is deprecated in Homebrew and may be removed in a
future release. See [Homebrew/brew#20755](https://github.com/Homebrew/brew/issues/20755).
Homebrew's default is `false`.
'';
};
no_binaries = mkNullOrBoolOption {
description = "Whether to disable linking of helper executables.";
description = ''
Whether to disable linking of helper executables.
Homebrew's default is `false`.
'';
};
ignore_dependencies = mkNullOrBoolOption {
description = "Ignore casks dependencies in case you manage them extrenally";
description = ''
Whether to ignore cask dependencies, e.g., when you manage them externally.
Homebrew's default is `false`.
'';
};
brewfileLine = mkInternalOption { type = types.nullOr types.str; };
@@ -424,7 +487,7 @@ let
type = with types; nullOr (listOf str);
default = null;
description = ''
Arguments flags to pass to {command}`brew install`. Values should not include the
Argument flags to pass to {command}`brew install`. Values should not include the
leading `"--"`.
'';
};
@@ -437,12 +500,14 @@ let
'';
};
restart_service = mkOption {
type = with types; nullOr (either bool (enum [ "changed" ]));
type = with types; nullOr (either bool (enum [ "changed" "always" ]));
default = null;
description = ''
Whether to run {command}`brew services restart` for the formula and register it to
launch at login (or boot). If set to `"changed"`, the service will only
be restarted on version changes.
be restarted when the formula is newly installed or upgraded. If set to
`"always"`, the service will be restarted on every {command}`brew bundle`
run, even if nothing changed.
Homebrew's default is `false`.
'';
@@ -450,17 +515,53 @@ let
start_service = mkNullOrBoolOption {
description = ''
Whether to run {command}`brew services start` for the formula and register it to
launch at login (or boot).
launch at login (or boot). Unlike {option}`restart_service`, this only starts
the service if it is not currently running, without restarting an already-running
service.
Homebrew's default is `false`.
'';
};
link = mkNullOrBoolOption {
link = mkOption {
type = with types; nullOr (either bool (enum [ "overwrite" ]));
default = null;
description = ''
Whether to link the formula to the Homebrew prefix. When this option is
`null`, Homebrew will use it's default behavior which is to link the
formula if it's currently unlinked and not keg-only, and to unlink the formula if it's
currently linked and keg-only.
Whether to link the formula to the Homebrew prefix. When set to `"overwrite"`,
existing symlinks will be overwritten ({command}`brew link --overwrite`). When this
option is `null`, Homebrew will use its default behavior, which is to link the formula
if it's currently unlinked and not keg-only, and to unlink the formula if it's currently
linked and keg-only.
'';
};
postinstall = mkNullOrStrOption {
description = ''
A shell command to run after the formula is installed or upgraded. The command is passed
to the system shell and only executes when the formula actually changed (was freshly
installed or upgraded), not on every {command}`brew bundle` run.
'';
};
# `version_file` is intentionally not exposed: it writes the installed version to a file
# path relative to the `brew bundle` working directory, which is not meaningful during
# nix-darwin system activation.
trusted = mkOption {
type = types.bool;
default = true;
example = false;
description = ''
Whether to trust this formula during {command}`nix-darwin` system activation, by adding the
`trusted: true` option to its {command}`brew bundle` Brewfile entry.
Homebrew 6.0.0 enabled `HOMEBREW_REQUIRE_TAP_TRUST` by default, which refuses to
load formulae from non-official taps that haven't been trusted, aborting activation. Set
this to `true` for a formula from a non-official tap you control so it is installed during
activation.
This only takes effect when {option}`name` is a fully-qualified name (`user/repo/formula`),
since only fully-qualified names map to a tap and can be trusted (and installed) on their
own. When {option}`name` is a plain formula name, it is resolved through your tapped
repositories, so trust must instead come from the containing tap being marked as trusted
(see [](#opt-homebrew.taps)). Official taps are always trusted, so this has no effect on
them.
'';
};
@@ -470,20 +571,15 @@ let
config =
let
sCfg = mkProcessedSubmodConfig config;
sCfgSubset = removeAttrs sCfg [ "name" "restart_service" ];
sCfgSubset = removeAttrs sCfg [ "name" "restart_service" "link" "trusted" ];
in
{
brewfileLine =
"brew ${sCfg.name}"
+ optionalString (sCfgSubset != { }) ", ${mkBrewfileLineOptionsListString sCfgSubset}"
# We need to handle the `restart_service` option seperately since it can be either a bool
# or `:changed` in the Brewfile.
+ optionalString (sCfg ? restart_service) (
", restart_service: " + (
if isBool config.restart_service then sCfg.restart_service
else ":${config.restart_service}"
)
);
+ mkBrewfileLineBoolOrSymbolString "link" config sCfg
+ mkBrewfileLineBoolOrSymbolString "restart_service" config sCfg
+ optionalString config.trusted ", trusted: true";
};
};
@@ -502,12 +598,42 @@ let
[](#opt-homebrew.caskArgs) for the available options.
'';
};
greedy = mkNullOrBoolOption {
greedy = mkOption {
type = types.nullOr types.bool;
default = cfg.greedyCasks;
description = ''
Whether to always upgrade this cask regardless of whether it's unversioned or it updates
itself.
'';
};
postinstall = mkNullOrStrOption {
description = ''
A shell command to run after the cask is installed or upgraded. The command is passed to
the system shell and only executes when the cask was actually installed or upgraded, not
on every {command}`brew bundle` run.
'';
};
trusted = mkOption {
type = types.bool;
default = true;
example = false;
description = ''
Whether to trust this cask during {command}`nix-darwin` system activation, by adding the
`trusted: true` option to its {command}`brew bundle` Brewfile entry.
Homebrew 6.0.0 enabled `HOMEBREW_REQUIRE_TAP_TRUST` by default, which refuses to
load casks from non-official taps that haven't been trusted, silently skipping them. Set
this to `true` for a cask from a non-official tap you control so it is installed during
activation.
This only takes effect when {option}`name` is a fully-qualified name (`user/repo/cask`),
since only fully-qualified names map to a tap and can be trusted (and installed) on their
own. When {option}`name` is a plain cask name, it is resolved through your tapped
repositories, so trust must instead come from the containing tap being marked as trusted
(see [](#opt-homebrew.taps)). Official taps are always trusted, so this has no effect on
them.
'';
};
brewfileLine = mkInternalOption { type = types.nullOr types.str; };
};
@@ -515,12 +641,13 @@ let
config =
let
sCfg = mkProcessedSubmodConfig config;
sCfgSubset = removeAttrs sCfg [ "name" ];
sCfgSubset = removeAttrs sCfg [ "name" "trusted" ];
in
{
brewfileLine =
"cask ${sCfg.name}"
+ optionalString (sCfgSubset != { }) ", ${mkBrewfileLineOptionsListString sCfgSubset}";
+ optionalString (sCfgSubset != { }) ", ${mkBrewfileLineOptionsListString sCfgSubset}"
+ optionalString config.trusted ", trusted: true";
};
};
in
@@ -531,21 +658,26 @@ in
imports = [
(mkRenamedOptionModule [ "homebrew" "autoUpdate" ] [ "homebrew" "onActivation" "autoUpdate" ])
(mkRenamedOptionModule [ "homebrew" "cleanup" ] [ "homebrew" "onActivation" "cleanup" ])
(mkRemovedOptionModule [ "homebrew" "brewPrefix" ] "`homebrew.brewPrefix` has been renamed to `homebrew.prefix` and its semantics changed: the old option pointed to the bin directory (e.g., `/opt/homebrew/bin`), while the new option points to the Homebrew prefix (e.g., `/opt/homebrew`), matching `brew --prefix`. Please replace `homebrew.brewPrefix` with `homebrew.prefix`, removing the trailing `/bin` if present.")
(mkRemovedOptionModule [ "homebrew" "whalebrews" ] "Whalebrew support was removed from Homebrew Bundle in Homebrew 4.7.0 (Nov 2025). `whalebrew` entries in a Brewfile now cause `brew bundle` to fail. Please manage Whalebrew images directly using the `whalebrew` CLI.")
];
options.homebrew = {
enable = mkEnableOption ''
{command}`nix-darwin` to manage installing/updating/upgrading Homebrew taps, formulae,
and casks, as well as Mac App Store apps and Docker containers, using Homebrew Bundle.
casks, Mac App Store apps, Visual Studio Code extensions, Go packages, and Cargo
crates using Homebrew Bundle.
Note that enabling this option does not install Homebrew, see the Homebrew
[website](https://brew.sh) for installation instructions.
Use the [](#opt-homebrew.brews), [](#opt-homebrew.casks),
[](#opt-homebrew.masApps), and [](#opt-homebrew.whalebrews) options
to list the Homebrew formulae, casks, Mac App Store apps, and Docker containers you'd like to
install. Use the [](#opt-homebrew.taps) option, to make additional formula
repositories available to Homebrew. This module uses those options (along with the
[](#opt-homebrew.masApps), [](#opt-homebrew.vscode),
[](#opt-homebrew.goPackages), and [](#opt-homebrew.cargoPackages) options to list
the Homebrew formulae, casks, Mac App Store apps, Visual Studio Code extensions,
Go packages, and Cargo crates you'd like to install. Use the
[](#opt-homebrew.taps) option, to make additional formula repositories available to
Homebrew. This module uses those options (along with the
[](#opt-homebrew.caskArgs) options) to generate a Brewfile that
{command}`nix-darwin` passes to the {command}`brew bundle` command during
system activation.
@@ -559,20 +691,38 @@ in
This module also provides a few options for modifying how Homebrew commands behave when
you manually invoke them, under [](#opt-homebrew.global)'';
brewPrefix = mkOption {
user = mkOption {
type = types.str;
default = if pkgs.stdenv.hostPlatform.isAarch64 then "/opt/homebrew/bin" else "/usr/local/bin";
defaultText = literalExpression ''
if pkgs.stdenv.hostPlatform.isAarch64 then "/opt/homebrew/bin"
else "/usr/local/bin"
'';
default = config.system.primaryUser;
defaultText = literalExpression "config.system.primaryUser";
description = ''
The path prefix where the {command}`brew` executable is located. This will be set to
the correct value based on your system's platform, and should only need to be changed if you
manually installed Homebrew in a non-standard location.
The user that owns the Homebrew installation. In most cases
this should be the normal user account that you installed
Homebrew as.
'';
};
prefix = mkOption {
type = types.str;
default = if pkgs.stdenv.hostPlatform.isAarch64 then "/opt/homebrew" else "/usr/local";
defaultText = literalExpression ''
if pkgs.stdenv.hostPlatform.isAarch64 then "/opt/homebrew"
else "/usr/local"
'';
description = ''
The Homebrew prefix directory, i.e., the value that {command}`brew --prefix` returns.
The default is automatically set based on your system's platform, and should only need
to be changed if you manually installed Homebrew in a non-standard location.
'';
};
# These default to `false` (unlike direnv, which defaults to `true`) because existing users
# likely already have `brew shellenv` in their dotfiles, and enabling by default would cause
# duplicate evaluation.
enableBashIntegration = mkShellIntegrationOption "Bash";
enableFishIntegration = mkShellIntegrationOption "Fish";
enableZshIntegration = mkShellIntegrationOption "Zsh";
onActivation = mkOption {
type = types.submodule onActivationOptions;
default = { };
@@ -594,10 +744,10 @@ in
type = with types; listOf (coercedTo str (name: { inherit name; }) (submodule tapOptions));
default = [ ];
example = literalExpression ''
# Adapted examples from https://github.com/Homebrew/homebrew-bundle#usage
# Adapted from https://docs.brew.sh/Brew-Bundle-and-Brewfile
[
# `brew tap`
"homebrew/cask"
"apple/apple"
# `brew tap` with custom Git URL and arguments
{
@@ -631,11 +781,20 @@ in
'';
};
greedyCasks = mkNullOrBoolOption {
description = ''
Whether to always upgrade casks listed in [](#opt-homebrew.casks) regardless
of whether it's unversioned or it updates itself.
Homebrew's default is `false`.
'';
};
brews = mkOption {
type = with types; listOf (coercedTo str (name: { inherit name; }) (submodule brewOptions));
default = [ ];
example = literalExpression ''
# Adapted examples from https://github.com/Homebrew/homebrew-bundle#usage
# Adapted from https://docs.brew.sh/Brew-Bundle-and-Brewfile
[
# `brew install`
"imagemagick"
@@ -654,6 +813,12 @@ in
link = true;
conflicts_with = [ "mysql" ];
}
# `brew install`, run a post-install command on version changes
{
name = "postgresql@16";
postinstall = "\''${HOMEBREW_PREFIX}/opt/postgresql@16/bin/postgres -D \''${HOMEBREW_PREFIX}/var/postgresql@16";
}
]
'';
description = ''
@@ -669,7 +834,7 @@ in
type = with types; listOf (coercedTo str (name: { inherit name; }) (submodule caskOptions));
default = [ ];
example = literalExpression ''
# Adapted examples from https://github.com/Homebrew/homebrew-bundle#usage
# Adapted from https://docs.brew.sh/Brew-Bundle-and-Brewfile
[
# `brew install --cask`
"google-chrome"
@@ -685,6 +850,12 @@ in
name = "opera";
greedy = true;
}
# `brew install --cask`, run a post-install command on install or upgrade
{
name = "google-cloud-sdk";
postinstall = "\''${HOMEBREW_PREFIX}/bin/gcloud components update";
}
]
'';
description = ''
@@ -708,9 +879,6 @@ in
description = ''
Applications to install from Mac App Store using {command}`mas`.
When this option is used, `"mas"` is automatically added to
[](#opt-homebrew.brews).
Note that you need to be signed into the Mac App Store for {command}`mas` to
successfully install and upgrade applications, and that unfortunately apps removed from this
option will not be uninstalled automatically even if
@@ -722,21 +890,47 @@ in
'';
};
whalebrews = mkOption {
vscode = mkOption {
type = with types; listOf str;
default = [ ];
example = [ "whalebrew/wget" ];
example = [ "golang.go" ];
description = ''
List of Docker images to install using {command}`whalebrew`.
List of Visual Studio Code extensions to install using Homebrew Bundle.
When this option is used, `"whalebrew"` is automatically added to
[](#opt-homebrew.brews).
A compatible editor (Visual Studio Code, VSCodium, Cursor, or VS Code Insiders)
must be available. If none is found, Homebrew will attempt to install
`visual-studio-code` automatically.
For more information on {command}`whalebrew` see:
[github.com/whalebrew/whalebrew](https://github.com/whalebrew/whalebrew).
For more information on {command}`code` see:
[VSCode Extension Marketplace](https://code.visualstudio.com/docs/editor/extension-marketplace).
'';
};
goPackages = mkOption {
type = with types; listOf str;
default = [ ];
example = [ "github.com/charmbracelet/crush" ];
description = ''
List of Go packages to install using {command}`go install`.
Homebrew will automatically install the {command}`go` formula if it is not already
installed.
'';
};
cargoPackages = mkOption {
type = with types; listOf str;
default = [ ];
example = [ "ripgrep" ];
description = ''
List of Rust packages to install using {command}`cargo install`.
Homebrew will automatically install the {command}`rust` formula if it is not already
installed.
'';
};
extraConfig = mkOption {
type = types.lines;
default = "";
@@ -749,7 +943,7 @@ in
brewfile = mkInternalOption {
type = types.str;
description = "String reprensentation of the generated Brewfile useful for debugging.";
description = "String representation of the generated Brewfile useful for debugging.";
};
};
@@ -758,18 +952,15 @@ in
config = {
assertions = [
# See comment above `homebrew.global.noLock` option declaration for why this is required.
{ assertion = cfg.global.noLock == null; message = "The option `homebrew.global.noLock' was removed, use `homebrew.global.lockfiles' in it's place."; }
];
warnings = [
(mkIf (options.homebrew.autoUpdate.isDefined || options.homebrew.cleanup.isDefined) "The `homebrew' module no longer upgrades outdated formulae and apps by default during `nix-darwin' system activation. To enable upgrading, set `homebrew.onActivation.upgrade = true'.")
(mkIf (cfg.global.noLock != null || cfg.global.lockfiles != null) "The options `homebrew.global.noLock' and `homebrew.global.lockfiles' have been deprecated. Homebrew Bundle removed lockfile support in Homebrew 4.4.0 (Oct 2024), so these options no longer have any effect. Please remove them from your configuration.")
(mkIf (hasSuffix "/bin" cfg.prefix) "`homebrew.prefix` should be the Homebrew prefix directory (e.g., `/opt/homebrew`), not the bin directory. The value should match what `brew --prefix` returns. Did you mean to remove the trailing `/bin`?")
];
homebrew.brews =
optional (cfg.masApps != { }) "mas"
++ optional (cfg.whalebrews != [ ]) "whalebrew";
system.requiresPrimaryUser = mkIf (cfg.enable && options.homebrew.user.highestPrio == (mkOptionDefault {}).priority) [
"homebrew.enable"
];
homebrew.brewfile =
"# Created by `nix-darwin`'s `homebrew` module\n\n"
@@ -780,19 +971,73 @@ in
+ mkBrewfileSectionString "Casks" cfg.casks
+ mkBrewfileSectionString "Mac App Store apps"
(mapAttrsToList (n: id: ''mas "${n}", id: ${toString id}'') cfg.masApps)
+ mkBrewfileSectionString "Docker containers" (map (v: ''whalebrew "${v}"'') cfg.whalebrews)
+ mkBrewfileSectionString "Visual Studio Code extensions" (map (v: ''vscode "${v}"'') cfg.vscode)
+ mkBrewfileSectionString "Go packages" (map (v: ''go "${v}"'') cfg.goPackages)
+ mkBrewfileSectionString "Cargo packages" (map (v: ''cargo "${v}"'') cfg.cargoPackages)
+ optionalString (cfg.extraConfig != "") ("# Extra config\n" + cfg.extraConfig);
environment.variables = mkIf cfg.enable cfg.global.homebrewEnvironmentVariables;
programs = mkIf cfg.enable {
bash.interactiveShellInit = mkIf cfg.enableBashIntegration ''
eval "$(${cfg.prefix}/bin/brew shellenv bash)"
if [[ -r "${cfg.prefix}/etc/profile.d/bash_completion.sh" ]]; then
source "${cfg.prefix}/etc/profile.d/bash_completion.sh"
else
for COMPLETION in "${cfg.prefix}/etc/bash_completion.d/"*; do
[[ -r "$COMPLETION" ]] && source "$COMPLETION"
done
fi
'';
zsh.interactiveShellInit = mkIf cfg.enableZshIntegration ''
eval "$(${cfg.prefix}/bin/brew shellenv zsh)"
'';
fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
eval (${cfg.prefix}/bin/brew shellenv fish)
if test -d "${cfg.prefix}/share/fish/completions"
set -p fish_complete_path "${cfg.prefix}/share/fish/completions"
end
if test -d "${cfg.prefix}/share/fish/vendor_completions.d"
set -p fish_complete_path "${cfg.prefix}/share/fish/vendor_completions.d"
end
'';
};
system.checks.text = mkIf (cfg.enable && cfg.onActivation.cleanup == "check") ''
if [ -f "${cfg.prefix}/bin/brew" ]; then
homebrewCleanupExitCode=0
homebrewCleanupResult=$(${cfg.onActivation.brewBundleCmd { onlyCheck = true; }}) || homebrewCleanupExitCode=$?
if [ "$homebrewCleanupExitCode" -eq 1 ]; then
printf >&2 '\e[1;31merror: found Homebrew packages not listed in the Brewfile, aborting activation\e[0m\n'
printf >&2 '%s\n' "$homebrewCleanupResult"
printf >&2 '\n'
printf >&2 'To fix this, either:\n'
printf >&2 ' - Add the listed packages to your nix-darwin Homebrew configuration\n'
printf >&2 ' - Remove them by running: brew bundle cleanup --force\n'
printf >&2 ' - Set homebrew.onActivation.cleanup to "uninstall" or "zap"\n'
exit 2
elif [ "$homebrewCleanupExitCode" -ne 0 ]; then
printf >&2 '\e[1;31merror: brew bundle cleanup failed, aborting activation\e[0m\n'
printf >&2 '%s\n' "$homebrewCleanupResult"
exit 2
fi
fi
'';
system.activationScripts.homebrew.text = mkIf cfg.enable ''
# Homebrew Bundle
echo >&2 "Homebrew bundle..."
if [ -f "${cfg.brewPrefix}/brew" ]; then
PATH="${cfg.brewPrefix}":$PATH ${cfg.onActivation.brewBundleCmd}
if [ -f "${cfg.prefix}/bin/brew" ]; then
${cfg.onActivation.brewBundleCmd { onlyCheck = false; }}
else
echo -e "\e[1;31merror: Homebrew is not installed, skipping...\e[0m" >&2
fi
'';
};
meta.maintainers = [
lib.maintainers.malo or "malo"
];
}
+24 -3
View File
@@ -9,7 +9,7 @@ let
toEnvironmentText = name: value: {
name = "${value.serviceConfig.Label}.plist";
value.text = generators.toPlist { } value.serviceConfig;
value.text = generators.toPlist { escape = true; } value.serviceConfig;
};
launchdConfig = import ./launchd.nix;
@@ -90,7 +90,7 @@ let
serviceConfig.ProgramArguments = mkIf (config.command != "") [
"/bin/sh"
"-c"
"/bin/wait4path /nix/store &amp;&amp; exec ${config.command}"
"/bin/wait4path /nix/store && exec ${config.command}"
];
serviceConfig.EnvironmentVariables = mkIf (env != {}) env;
};
@@ -170,7 +170,16 @@ in
launchd.user.agents = mkOption {
default = {};
type = types.attrsOf (types.submodule serviceOptions);
type = types.attrsOf (types.submodule [
serviceOptions
({ name, ... }: {
options.managedBy = lib.mkOption {
type = lib.types.str;
internal = true;
default = lib.showOption [ "launchd" "user" "agents" name ];
};
})
]);
description = ''
Definition of per-user launchd agents.
@@ -187,6 +196,18 @@ in
config = {
system.requiresPrimaryUser =
lib.map (
name:
lib.showOption [
"launchd"
"user"
"envVariables"
name
]
) (attrNames cfg.user.envVariables)
++ lib.map ({ managedBy, ... }: managedBy) (attrValues cfg.user.agents);
environment.launchAgents = mapAttrs' toEnvironmentText cfg.agents;
environment.launchDaemons = mapAttrs' toEnvironmentText cfg.daemons;
+12
View File
@@ -120,6 +120,18 @@ in
This key maps to the second argument of `execvp(3)`. This key is required in the absence of the Program
key. Please note: many people are confused by this key. Please read `execvp(3)` very carefully!
'';
# TODO: Remove this some time after 25.11.
apply =
val:
if (builtins.isNull val) then
val
else
(map (
item:
lib.warnIf (lib.hasInfix "&amp;" item)
"A value for `ProgramArguments` contains the literal string `&amp;`. This is no longer necessary and will lead to double-escaping, as nix-darwin now automatically escapes special characters."
item
) val);
};
EnableGlobbing = mkOption {
+2
View File
@@ -39,11 +39,13 @@ in
ids.uids = {
nixbld = lib.mkDefault 350;
_prometheus-node-exporter = 534;
_dnscrypt-proxy = 535;
};
ids.gids = {
nixbld = lib.mkDefault (if config.system.stateVersion < 5 then 30000 else 350);
_prometheus-node-exporter = 534;
_dnscrypt-proxy = 535;
};
};
+12 -1
View File
@@ -1,5 +1,7 @@
[
./alias.nix
./config/system-path.nix
./config/terminfo.nix
./documentation
./meta.nix
./misc/ids.nix
@@ -10,6 +12,7 @@
./security/sudo.nix
./system
./system/base.nix
./system/primary-user.nix
./system/checks.nix
./system/activation-scripts.nix
./system/applications.nix
@@ -23,6 +26,7 @@
./system/defaults/dock.nix
./system/defaults/finder.nix
./system/defaults/hitoolbox.nix
./system/defaults/iCal.nix
./system/defaults/screencapture.nix
./system/defaults/screensaver.nix
./system/defaults/alf.nix
@@ -45,6 +49,7 @@
./system/version.nix
./time
./networking
./networking/applicationFirewall.nix
./nix
./nix/linux-builder.nix
./nix/nix-darwin.nix
@@ -62,6 +67,7 @@
./services/chunkwm.nix
./services/cachix-agent.nix
./services/dnsmasq.nix
./services/dnscrypt-proxy.nix
./services/emacs.nix
./services/eternal-terminal.nix
./services/github-runner
@@ -98,14 +104,19 @@
./services/yabai
./services/nextdns
./services/jankyborders
./programs/_1password.nix
./programs/_1password-gui.nix
./programs/arqbackup.nix
./programs/bash
./programs/devenv.nix
./programs/direnv.nix
./programs/fish.nix
./programs/gnupg.nix
./programs/man.nix
./programs/mas.nix
./programs/info
./programs/nix-index
./programs/ssh
./programs/ssh.nix
./programs/tmux.nix
./programs/vim.nix
./programs/zsh
@@ -0,0 +1,73 @@
{ config, lib, ... }:
let
cfg = config.networking.applicationFirewall;
socketfilterfw =
option: value:
lib.concatStringsSep " " [
"/usr/libexec/ApplicationFirewall/socketfilterfw"
"--${option}"
(if value then "on" else "off")
];
in
{
meta.maintainers = [
(lib.maintainers.prince213 or "prince213")
(lib.maintainers.ryanccn or "ryanccn")
];
options.networking.applicationFirewall = {
enable = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
example = true;
description = "Whether to enable application firewall.";
};
blockAllIncoming = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
example = true;
description = "Whether to block all incoming connections.";
};
allowSigned = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
example = true;
description = "Whether to allow built-in software to receive incoming connections.";
};
allowSignedApp = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
example = true;
description = "Whether to allow downloaded signed software to receive incoming connections.";
};
enableStealthMode = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
example = true;
description = "Whether to enable stealth mode.";
};
};
config = {
system.activationScripts.networking.text = ''
echo "configuring application firewall..." >&2
${lib.optionalString (cfg.enable != null) (socketfilterfw "setglobalstate" cfg.enable)}
${lib.optionalString (cfg.blockAllIncoming != null) (
socketfilterfw "setblockall" cfg.blockAllIncoming
)}
${lib.optionalString (cfg.allowSigned != null) (socketfilterfw "setallowsigned" cfg.allowSigned)}
${lib.optionalString (cfg.allowSignedApp != null) (
socketfilterfw "setallowsignedapp" cfg.allowSignedApp
)}
${lib.optionalString (cfg.enableStealthMode != null) (
socketfilterfw "setstealthmode" cfg.enableStealthMode
)}
'';
};
}
+74 -1
View File
@@ -18,6 +18,9 @@ let
*${lib.escapeShellArg srv}*)
networksetup -setdnsservers ${lib.escapeShellArgs ([ srv ] ++ (emptyList cfg.dns))}
networksetup -setsearchdomains ${lib.escapeShellArgs ([ srv ] ++ (emptyList cfg.search))}
${optionalString (cfg.dhcpClientId != null) ''
networksetup -setdhcp ${lib.escapeShellArgs [ srv cfg.dhcpClientId ]}
''}
;;
esac
'') cfg.knownNetworkServices}
@@ -71,6 +74,56 @@ in
'';
};
networking.domain = mkOption {
default = null;
example = "home.arpa";
type = types.nullOr types.str;
description = ''
The domain. It can be left empty if it is auto-detected through DHCP.
'';
};
networking.fqdn = mkOption {
type = types.str;
default =
if (cfg.hostName != "" && cfg.domain != null) then
"${cfg.hostName}.${cfg.domain}"
else
throw ''
The FQDN is required but cannot be determined from `networking.hostName`
and `networking.domain`. Please ensure these options are set properly or
set `networking.fqdn` directly.
'';
defaultText = literalExpression ''"''${networking.hostName}.''${networking.domain}"'';
description = ''
The fully qualified domain name (FQDN) of this host. By default, it is
the result of combining `networking.hostName` and `networking.domain.`
Using this option will result in an evaluation error if the hostname is empty or
no domain is specified.
Modules that accept a mere `networking.hostName` but prefer a fully qualified
domain name may use `networking.fqdnOrHostName` instead.
'';
};
networking.fqdnOrHostName = mkOption {
readOnly = true;
type = types.str;
default = if cfg.domain == null then cfg.hostName else cfg.fqdn;
defaultText = literalExpression ''
if cfg.domain == null then cfg.hostName else cfg.fqdn
'';
description = ''
Either the fully qualified domain name (FQDN), or just the host name if
it does not exists.
This is a convenience option for modules to read instead of `fqdn` when
a mere `hostName` is also an acceptable value; this option does not
throw an error when `domain` is unset.
'';
};
networking.knownNetworkServices = mkOption {
type = types.listOf types.str;
default = [];
@@ -83,6 +136,21 @@ in
'';
};
networking.dhcpClientId = mkOption {
type = types.nullOr types.str;
default = null;
example = "my-client-id";
description = ''
The DHCP client identifier to use when requesting an IP address from a DHCP server.
If this option is set, it will be used by the system when requesting an IP address.
If not set, no changes will be made.
Set to the string "empty" to clear any previously configured client ID
and restore the system default behavior.
'';
};
networking.dns = mkOption {
type = types.listOf types.str;
default = [];
@@ -112,13 +180,13 @@ in
warnings = [
(mkIf (cfg.knownNetworkServices == [] && cfg.dns != []) "networking.knownNetworkServices is empty, dns servers will not be configured.")
(mkIf (cfg.knownNetworkServices == [] && cfg.search != []) "networking.knownNetworkServices is empty, dns searchdomains will not be configured.")
(mkIf (cfg.knownNetworkServices == [] && cfg.dhcpClientId != null) "networking.knownNetworkServices is empty, dhcp client ID will not be configured.")
];
system.activationScripts.networking.text = ''
echo "configuring networking..." >&2
${optionalString (cfg.computerName != null) ''
# shellcheck disable=SC1112
scutil --set ComputerName ${escapeShellArg cfg.computerName}
''}
${optionalString (cfg.hostName != null) ''
@@ -133,6 +201,11 @@ in
${optionalString (cfg.wakeOnLan.enable != null) ''
systemsetup -setWakeOnNetworkAccess '${onOff cfg.wakeOnLan.enable}' &> /dev/null
''}
if [ -e /etc/hosts.before-nix-darwin ]; then
echo "restoring /etc/hosts..." >&2
sudo mv /etc/hosts{.before-nix-darwin,}
fi
'';
};
+175 -66
View File
@@ -12,6 +12,8 @@ let
isNixAtLeast = versionAtLeast (getVersion nixPackage);
configureBuildUsers = !(config.nix.settings.auto-allocate-uids or false);
makeNixBuildUser = nr: {
name = "_nixbld${toString nr}";
value = {
@@ -49,13 +51,16 @@ let
mkKeyValuePairs = attrs: concatStringsSep "\n" (mapAttrsToList mkKeyValue attrs);
isExtra = key: hasPrefix "extra-" key;
in
pkgs.writeTextFile {
name = "nix.conf";
text = ''
# WARNING: this file is generated from the nix.* options in
# your nix-darwin configuration. Do not edit it!
${mkKeyValuePairs cfg.settings}
${mkKeyValuePairs (filterAttrs (key: value: !(isExtra key)) cfg.settings)}
${mkKeyValuePairs (filterAttrs (key: value: isExtra key) cfg.settings)}
${cfg.extraOptions}
'';
checkPhase =
@@ -134,6 +139,34 @@ let
namedPaths ++ searchPaths;
};
handleUnmanaged = managedConfig: mkMerge [
(mkIf cfg.enable managedConfig)
(mkIf (!cfg.enable) {
system.activationScripts.nix-daemon.text = ''
# Restore unmanaged Nix daemon if present
unmanagedNixProfile=/nix/var/nix/profiles/default
if [[
-e /run/current-system/Library/LaunchDaemons/org.nixos.nix-daemon.plist
&& -e $unmanagedNixProfile/Library/LaunchDaemons/org.nixos.nix-daemon.plist
]]; then
printf >&2 'restoring unmanaged Nix daemon...\n'
cp \
"$unmanagedNixProfile/Library/LaunchDaemons/org.nixos.nix-daemon.plist" \
/Library/LaunchDaemons
launchctl load -w /Library/LaunchDaemons/org.nixos.nix-daemon.plist
fi
'';
})
];
managedDefault = name: default: {
default = if cfg.enable then default else throw ''
${name}: accessed when `nix.enable` is off; this is a bug in
nix-darwin or a thirdparty module
'';
defaultText = default;
};
in
{
@@ -144,7 +177,6 @@ in
in
[
# Only ever in NixOS
(mkRemovedOptionModule [ "nix" "enable" ] "No `nix-darwin` equivalent to this NixOS option.")
(mkRemovedOptionModule [ "nix" "daemonCPUSchedPolicy" ] (altOption "nix.daemonProcessType"))
(mkRemovedOptionModule [ "nix" "daemonIOSchedClass" ] (altOption "nix.daemonProcessType"))
(mkRemovedOptionModule [ "nix" "daemonIOSchedPriority" ] (altOption "nix.daemonIOLowPriority"))
@@ -157,6 +189,14 @@ in
(mkRenamedOptionModule [ "users" "nix" "nrBuildUsers" ] [ "nix" "nrBuildUsers" ])
(mkRenamedOptionModule [ "nix" "daemonIONice" ] [ "nix" "daemonIOLowPriority" ])
(mkRemovedOptionModule [ "nix" "daemonNiceLevel" ] (consider "nix.daemonProcessType"))
(mkRemovedOptionModule [ "nix" "useDaemon" ] ''
nix-darwin now only supports managing multiuser daemon
installations of Nix.
'')
(mkRemovedOptionModule [ "nix" "configureBuildUsers" ] ''
nix-darwin now manages build users unconditionally when
`nix.enable` is on.
'')
] ++ mapAttrsToList (oldConf: newConf: mkRenamedOptionModule [ "nix" oldConf ] [ "nix" "settings" newConf ]) legacyConfMappings;
###### interface
@@ -165,29 +205,43 @@ in
nix = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to enable Nix.
Disabling this will stop nix-darwin from managing the
installed version of Nix, the nix-daemon launchd daemon, and
the settings in {file}`/etc/nix/nix.conf`.
This allows you to use nix-darwin without it taking over your
system installation of Nix. 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. You will also have to upgrade
Nix yourself, as nix-darwin will no longer do so.
::: {.warning}
If you have already removed your global system installation
of Nix, this will break nix-darwin and you will have to
reinstall Nix to fix it.
:::
'';
};
package = mkOption {
type = types.package;
default = pkgs.nix;
inherit (managedDefault "nix.package" pkgs.nix) default;
defaultText = literalExpression "pkgs.nix";
description = ''
This option specifies the Nix package instance to use throughout the system.
'';
};
# Not in NixOS module
useDaemon = mkOption {
type = types.bool;
default = false;
description = ''
If set, Nix will use the daemon to perform operations.
Use this instead of services.nix-daemon.enable if you don't want the
daemon service to be managed for you.
'';
};
distributedBuilds = mkOption {
type = types.bool;
default = false;
inherit (managedDefault "nix.distributedBuilds" false) default defaultText;
description = ''
Whether to distribute builds to the machines listed in
{option}`nix.buildMachines`.
@@ -197,7 +251,7 @@ in
# Not in NixOS module
daemonProcessType = mkOption {
type = types.enum [ "Background" "Standard" "Adaptive" "Interactive" ];
default = "Standard";
inherit (managedDefault "nix.daemonProcessType" "Standard") default defaultText;
description = ''
Nix daemon process resource limits class. These limits propagate to
build processes. `Standard` is the default process type
@@ -212,7 +266,7 @@ in
# Not in NixOS module
daemonIOLowPriority = mkOption {
type = types.bool;
default = false;
inherit (managedDefault "nix.daemonIOLowPriority" false) default defaultText;
description = ''
Whether the Nix daemon process should considered to be low priority when
doing file system I/O.
@@ -340,7 +394,7 @@ in
};
};
});
default = [ ];
inherit (managedDefault "nix.buildMachines" [ ]) default defaultText;
description = ''
This option lists the machines to be used if distributed builds are
enabled (see {option}`nix.distributedBuilds`).
@@ -354,21 +408,13 @@ in
envVars = mkOption {
type = types.attrs;
internal = true;
default = { };
inherit (managedDefault "nix.envVars" { }) default defaultText;
description = "Environment variables used by Nix.";
};
# Not in NixOS module
configureBuildUsers = mkOption {
type = types.bool;
default = false;
description = ''
Enable configuration for nixbld group and users.
'';
};
nrBuildUsers = mkOption {
type = types.int;
inherit (managedDefault "nix.nrBuildUsers" 0) default defaultText;
description = ''
Number of `nixbld` user accounts created to
perform secure concurrent builds. If you receive an error
@@ -396,11 +442,16 @@ in
# Definition differs substantially from NixOS module
nixPath = mkOption {
type = nixPathType;
default = lib.optionals cfg.channel.enable [
# Include default path <darwin-config>.
{ darwin-config = "${config.environment.darwinConfig}"; }
"/nix/var/nix/profiles/per-user/root/channels"
];
inherit (managedDefault "nix.nixPath" (
lib.optionals cfg.channel.enable (
lib.optionals (config.environment.darwinConfig != null) [
# Include default path <darwin-config>.
{ darwin-config = "${config.environment.darwinConfig}"; }
] ++ [
"/nix/var/nix/profiles/per-user/root/channels"
]
)
)) default;
defaultText = lib.literalExpression ''
lib.optionals cfg.channel.enable [
@@ -422,7 +473,7 @@ in
checkConfig = mkOption {
type = types.bool;
default = true;
inherit (managedDefault "nix.checkConfig" true) default defaultText;
description = ''
If enabled (the default), checks for data type mismatches and that Nix
can parse the generated nix.conf.
@@ -483,7 +534,7 @@ in
};
}
));
default = { };
inherit (managedDefault "nix.registry" { }) default defaultText;
description = ''
A system-wide flake registry.
'';
@@ -491,7 +542,7 @@ in
extraOptions = mkOption {
type = types.lines;
default = "";
inherit (managedDefault "nix.extraOptions" "") default defaultText;
example = ''
keep-outputs = true
keep-derivations = true
@@ -660,7 +711,7 @@ in
};
};
};
default = { };
inherit (managedDefault "nix.settings" { }) default defaultText;
description = ''
Configuration for Nix, see
<https://nixos.org/manual/nix/stable/#sec-conf-file>
@@ -678,7 +729,7 @@ in
###### implementation
config = {
config = handleUnmanaged {
environment.systemPackages =
[
nixPackage
@@ -702,8 +753,13 @@ in
"5d23e6d7015756c6f300f8cd558ec4d9234ca61deefd4f2478e91a49760b0747" # DeterminateSystems Nix installer 0.16.0
"e4974acb79c56148cb8e92137fa4f2de9b7356e897b332fc4e6769e8c0b83e18" # DeterminateSystems Nix installer 0.20.0
"966d22ef5bb9b56d481e8e0d5f7ca2deaf4d24c0f0fc969b2eeaa7ae0aa42907" # DeterminateSystems Nix installer 0.22.0
"53712b4335030e2dbfb46bb235f8cffcac83fea404bd32dc99417ac89e2dd7c5" # DeterminateSystems Nix installer 0.33.0
"6bb8d6b0dd16b44ee793a9b8382dac76c926e4c16ffb8ddd2bb4884d1ca3f811" # DeterminateSystems Nix installer 0.34.0
"24797ac05542ff8b52910efc77870faa5f9e3275097227ea4e50c430a5f72916" # lix-installer 0.17.1 with flakes
"b027b5cad320b5b8123d9d0db9f815c3f3921596c26dc3c471457098e4d3cc40" # lix-installer 0.17.1 without flakes
"74ee0ae5ad21a1b101617685fd3d001f74a9466d9d763d92eb75b99cc740db91" # experimental official Nix installer 2.33.3
"daa9d824601c088f52de3da176e14328ba41e7be3eb450fdf8b93c86f236f722" # lix-installer 3.95.0 (47bc300) with flakes
"7659f39ef9ab9cdf50f8e6ae3476cbf3f27be6485500d1f225d45574d943a9f7" # lix-installer 3.95.0 (47bc300) without flakes
];
environment.etc."nix/registry.json".text = builtins.toJSON {
@@ -757,13 +813,16 @@ in
# Not in NixOS module
{ assertion = elem "nixbld" config.users.knownGroups -> elem "nixbld" createdGroups; message = "refusing to delete group nixbld in users.knownGroups, this would break nix"; }
{ assertion = elem "_nixbld1" config.users.knownGroups -> elem "_nixbld1" createdUsers; message = "refusing to delete user _nixbld1 in users.knownUsers, this would break nix"; }
{ assertion = elem "_nixbld1" config.users.knownUsers -> elem "_nixbld1" createdUsers; message = "refusing to delete user _nixbld1 in users.knownUsers, this would break nix"; }
{ assertion = config.users.groups ? "nixbld" -> config.users.groups.nixbld.members != []; message = "refusing to remove all members from nixbld group, this would break nix"; }
{
# Should be fixed in Lix by https://gerrit.lix.systems/c/lix/+/2100
# Should be fixed in Lix by https://gerrit.lix.systems/c/lix/+/2100, Nix by https://github.com/NixOS/nix/commit/d888846b68dd5fad998b84c5cb6246b1b63398cd
# Lix 2.92.0 will set `VERSION_SUFFIX` to `""`; `lib.versionAtLeast "" "pre20241107"` will return `true`.
assertion = cfg.settings.auto-optimise-store -> (cfg.package.pname == "lix" && (isNixAtLeast "2.92.0" && versionAtLeast (strings.removePrefix "-" cfg.package.VERSION_SUFFIX) "pre20241107"));
assertion = cfg.settings.auto-optimise-store -> (
(cfg.package.pname == "lix" && (isNixAtLeast "2.92.0" && versionAtLeast (strings.removePrefix "-" cfg.package.VERSION_SUFFIX) "pre20241107"))
|| (cfg.package.pname == "nix" && ((isNixAtLeast "2.31.3" && !isNixAtLeast "2.32") || isNixAtLeast "2.32.5" || isNixAtLeast "2.33"))
);
message = "`nix.settings.auto-optimise-store` is known to corrupt the Nix Store, please use `nix.optimise.automatic` instead.";
}
];
@@ -775,29 +834,26 @@ in
# Not in NixOS module
nix.nixPath = mkIf (config.system.stateVersion < 2) (mkDefault [
"darwin=$HOME/.nix-defexpr/darwin"
"darwin-config=$HOME/.nixpkgs/darwin-configuration.nix"
"darwin=${config.system.primaryUserHome}/.nix-defexpr/darwin"
"darwin-config=${config.system.primaryUserHome}/.nixpkgs/darwin-configuration.nix"
"/nix/var/nix/profiles/per-user/root/channels"
]);
system.requiresPrimaryUser = mkIf (
config.system.stateVersion < 2
&& options.nix.nixPath.highestPrio == (mkDefault {}).priority
) [
"nix.nixPath"
];
# Set up the environment variables for running Nix.
environment.variables = cfg.envVars // { NIX_PATH = cfg.nixPath; };
environment.extraInit = mkMerge [
(mkIf cfg.channel.enable ''
if [ -e "$HOME/.nix-defexpr/channels" ]; then
export NIX_PATH="$HOME/.nix-defexpr/channels''${NIX_PATH:+:$NIX_PATH}"
fi
'')
# Not in NixOS module
''
# Set up secure multi-user builds: non-root users build through the
# Nix daemon.
if [ ! -w /nix/var/nix/db ]; then
export NIX_REMOTE=daemon
fi
''
];
environment.extraInit = mkIf cfg.channel.enable ''
if [ -e "$HOME/.nix-defexpr/channels" ]; then
export NIX_PATH="$HOME/.nix-defexpr/channels''${NIX_PATH:+:$NIX_PATH}"
fi
'';
environment.extraSetup = mkIf (!cfg.channel.enable) ''
rm --force $out/bin/nix-channel
@@ -805,10 +861,10 @@ in
nix.nrBuildUsers = mkDefault (max 32 (if cfg.settings.max-jobs == "auto" then 0 else cfg.settings.max-jobs));
users.users = mkIf cfg.configureBuildUsers nixbldUsers;
users.users = mkIf configureBuildUsers nixbldUsers;
# Not in NixOS module
users.groups.nixbld = mkIf cfg.configureBuildUsers {
users.groups.nixbld = mkIf configureBuildUsers {
description = "Nix build group for nix-daemon";
gid = config.ids.gids.nixbld;
members = attrNames nixbldUsers;
@@ -816,14 +872,66 @@ in
users.knownUsers =
let nixbldUserNames = attrNames nixbldUsers;
in
mkIf cfg.configureBuildUsers (mkMerge [
mkMerge [
nixbldUserNames
(map (removePrefix "_") nixbldUserNames) # delete old style nixbld users
]);
users.knownGroups = mkIf cfg.configureBuildUsers [ "nixbld" ];
];
users.knownGroups = [ "nixbld" ];
# The Determinate Systems installer puts userspecified settings in
# `/etc/nix/nix.custom.conf` since v0.33.0. Supplement the
# `/etc/nix/nix.conf` hash check so that we dont accidentally
# clobber user configuration.
#
# TODO: Maybe this could use a more general file placement mechanism
# to express that we want it deleted and know only one hash?
system.activationScripts.checks.text = mkAfter ''
nixCustomConfKnownSha256Hashes=(
# DetSys v0.33.0
6787fade1cf934f82db554e78e1fc788705c2c5257fddf9b59bdd963ca6fec63
# DetSys v0.34.0
3bd68ef979a42070a44f8d82c205cfd8e8cca425d91253ec2c10a88179bb34aa
# Nix 2.33.3
71f7fdc9f6c9e55ca0f2e6f85137037d660b3224a34d59305e8530ca292bc734
# Lix 2.95.1
a6dee4985bf207d3bec6a3cee28aefb33e60f5d0a91d8c20bbd71b9dadb2e601
)
if [[ -e /etc/nix/nix.custom.conf ]]; then
nixCustomConfSha256Output=$(shasum -a 256 /etc/nix/nix.custom.conf)
nixCustomConfSha256Hash=''${nixCustomConfSha256Output%% *}
nixCustomConfIsKnown=
for nixCustomConfKnownSha256Hash
in "''${nixCustomConfKnownSha256Hashes[@]}"
do
if
[[ $nixCustomConfSha256Hash == "$nixCustomConfKnownSha256Hash" ]]
then
nixCustomConfIsKnown=1
break
fi
done
if [[ ! $nixCustomConfIsKnown ]]; then
printf >&2 '\e[1;31merror: custom settings in `/etc/nix/nix.custom.conf`, aborting activation\e[0m\n'
printf >&2 'You will need to migrate these to nix-darwin `nix.*` settings if you\n'
printf >&2 'wish to keep them. Check the manual for the appropriate settings and\n'
printf >&2 'add them to your system configuration, then run:\n'
printf >&2 '\n'
printf >&2 ' $ sudo mv /etc/nix/nix.custom.conf{,.before-nix-darwin}\n'
printf >&2 '\n'
printf >&2 'and activate your system again.\n'
exit 2
fi
fi
'';
# Unrelated to use in NixOS module
system.activationScripts.nix-daemon.text = mkIf cfg.useDaemon ''
system.activationScripts.nix-daemon.text = ''
# Follow up on the `/etc/nix/nix.custom.conf` check.
# TODO: Use a more generalized file placement mechanism for this.
if [[ -e /etc/nix/nix.custom.conf ]]; then
mv /etc/nix/nix.custom.conf{,.before-nix-darwin}
fi
if ! diff /etc/nix/nix.conf /run/current-system/etc/nix/nix.conf &> /dev/null || ! diff /etc/nix/machines /run/current-system/etc/nix/machines &> /dev/null; then
echo "reloading nix-daemon..." >&2
launchctl kill HUP system/org.nixos.nix-daemon
@@ -840,6 +948,9 @@ in
trusted-users = [ "root" ];
substituters = mkAfter [ "https://cache.nixos.org/" ];
# Not in NixOS module
build-users-group = "nixbld";
# Not implemented yet
# system-features = mkDefault (
# [ "nixos-test" "benchmark" "big-parallel" "kvm" ] ++
@@ -855,8 +966,6 @@ in
(mkIf (isNixAtLeast "2.3pre") { sandbox-fallback = false; })
# Not in NixOS module
(mkIf cfg.useDaemon { build-users-group = "nixbld"; })
];
};
+64 -45
View File
@@ -144,7 +144,7 @@ in
workingDirectory = mkOption {
type = types.str;
default = "/var/lib/darwin-builder";
default = "/var/lib/linux-builder";
description = ''
The working directory of the Linux builder daemon process.
'';
@@ -159,57 +159,76 @@ in
'';
};
config = mkIf cfg.enable {
system.activationScripts.preActivation.text = ''
mkdir -p ${cfg.workingDirectory}
'';
config = mkMerge [
(mkIf (!cfg.enable) {
system.activationScripts.preActivation.text = ''
rm -rf ${cfg.workingDirectory}
'';
})
(mkIf cfg.enable {
assertions = [
{
assertion = config.nix.enable;
message = ''`nix.linux-builder.enable` requires `nix.enable`'';
}
];
launchd.daemons.linux-builder = {
environment = {
inherit (config.environment.variables) NIX_SSL_CERT_FILE;
};
system.activationScripts.preActivation.text = ''
# Migrate if using the old working directory
if [ -e /var/lib/darwin-builder ] && [ ! -e ${cfg.workingDirectory} ]; then
mv /var/lib/darwin-builder ${cfg.workingDirectory}
fi
# create-builder uses TMPDIR to share files with the builder, notably certs.
# macOS will clean up files in /tmp automatically that haven't been accessed in 3+ days.
# If we let it use /tmp, leaving the computer asleep for 3 days makes the certs vanish.
# So we'll use /run/org.nixos.linux-builder instead and clean it up ourselves.
script = ''
export TMPDIR=/run/org.nixos.linux-builder USE_TMPDIR=1
rm -rf $TMPDIR
mkdir -p $TMPDIR
trap "rm -rf $TMPDIR" EXIT
${lib.optionalString cfg.ephemeral ''
rm -f ${cfg.workingDirectory}/${cfg.package.nixosConfig.networking.hostName}.qcow2
''}
${cfg.package}/bin/create-builder
mkdir -p ${cfg.workingDirectory}
'';
serviceConfig = {
KeepAlive = true;
RunAtLoad = true;
WorkingDirectory = cfg.workingDirectory;
launchd.daemons.linux-builder = {
environment = {
inherit (config.environment.variables) NIX_SSL_CERT_FILE;
};
# create-builder uses TMPDIR to share files with the builder, notably certs.
# macOS will clean up files in /tmp automatically that haven't been accessed in 3+ days.
# If we let it use /tmp, leaving the computer asleep for 3 days makes the certs vanish.
# So we'll use /run/org.nixos.linux-builder instead and clean it up ourselves.
script = ''
export TMPDIR=/run/org.nixos.linux-builder USE_TMPDIR=1
rm -rf $TMPDIR
mkdir -p $TMPDIR
trap "rm -rf $TMPDIR" EXIT
${lib.optionalString cfg.ephemeral ''
rm -f ${cfg.workingDirectory}/${cfg.package.nixosConfig.networking.hostName}.qcow2
''}
${cfg.package}/bin/create-builder
'';
serviceConfig = {
KeepAlive = true;
RunAtLoad = true;
WorkingDirectory = cfg.workingDirectory;
};
};
};
environment.etc."ssh/ssh_config.d/100-linux-builder.conf".text = ''
Host linux-builder
User builder
Hostname localhost
HostKeyAlias linux-builder
Port 31022
IdentityFile /etc/nix/builder_ed25519
'';
environment.etc."ssh/ssh_config.d/100-linux-builder.conf".text = ''
Host linux-builder
User builder
Hostname localhost
HostKeyAlias linux-builder
Port 31022
IdentityFile /etc/nix/builder_ed25519
'';
nix.distributedBuilds = true;
nix.distributedBuilds = true;
nix.buildMachines = [{
hostName = "linux-builder";
sshUser = "builder";
sshKey = "/etc/nix/builder_ed25519";
publicHostKey = "c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUpCV2N4Yi9CbGFxdDFhdU90RStGOFFVV3JVb3RpQzVxQkorVXVFV2RWQ2Igcm9vdEBuaXhvcwo=";
inherit (cfg) mandatoryFeatures maxJobs protocol speedFactor supportedFeatures systems;
}];
nix.buildMachines = [{
hostName = "linux-builder";
sshUser = "builder";
sshKey = "/etc/nix/builder_ed25519";
publicHostKey = "c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUpCV2N4Yi9CbGFxdDFhdU90RStGOFFVV3JVb3RpQzVxQkorVXVFV2RWQ2Igcm9vdEBuaXhvcwo=";
inherit (cfg) mandatoryFeatures maxJobs protocol speedFactor supportedFeatures systems;
}];
nix.settings.builders-use-substitutes = true;
};
nix.settings.builders-use-substitutes = true;
})
];
}
+28 -22
View File
@@ -4,44 +4,50 @@ let
nix-tools = pkgs.callPackage ../../pkgs/nix-tools {
inherit (config.system) profile;
inherit (config.environment) systemPath;
nixPackage = config.nix.package;
nixPath = lib.optionalString config.nix.enable (lib.concatStringsSep ":" config.nix.nixPath);
nixPackage = if config.nix.enable then config.nix.package else null;
};
darwin-uninstaller = pkgs.callPackage ../../pkgs/darwin-uninstaller { };
inherit (nix-tools) darwin-option darwin-rebuild darwin-version;
mkToolModule = { name, package ? nix-tools.${name} }: { config, ... }: {
options.system.tools.${name}.enable = lib.mkEnableOption "${name} script" // {
default = config.system.tools.enable;
};
config = lib.mkIf config.system.tools.${name}.enable {
environment.systemPackages = [ package ];
};
};
in
{
options.system = {
disableInstallerTools = lib.mkOption {
type = lib.types.bool;
internal = true;
default = false;
description = ''
Disable darwin-rebuild and darwin-option. This is useful to shrink
systems which are not expected to rebuild or reconfigure themselves.
Use at your own risk!
'';
};
includeUninstaller = lib.mkOption {
tools.enable = lib.mkOption {
type = lib.types.bool;
internal = true;
default = true;
description = ''
Disable internal tools, such as darwin-rebuild and darwin-option. This
is useful to shrink systems which are not expected to rebuild or
reconfigure themselves. Use at your own risk!
'';
};
};
config = {
environment.systemPackages =
[ darwin-version ]
++ lib.optionals (!config.system.disableInstallerTools) [
darwin-option
darwin-rebuild
] ++ lib.optional config.system.includeUninstaller darwin-uninstaller;
imports = [
(lib.mkRenamedOptionModule [ "system" "includeUninstaller" ] [ "system" "tools" "darwin-uninstaller" "enable" ])
(lib.mkRemovedOptionModule [ "system" "disableInstallerTools" ] "Please use system.tools.enable instead")
(mkToolModule { name = "darwin-option"; })
(mkToolModule { name = "darwin-rebuild"; })
(mkToolModule { name = "darwin-version"; })
(mkToolModule { name = "darwin-uninstaller"; package = darwin-uninstaller; })
];
config = {
system.build = {
inherit darwin-option darwin-rebuild darwin-version;
inherit (nix-tools) darwin-option darwin-rebuild darwin-version;
};
};
}
+16 -4
View File
@@ -37,8 +37,8 @@ in
setNixPath = mkOption {
type = types.bool;
default = cfg.source != null;
defaultText = "config.nixpkgs.flake.source != null";
default = config.nix.enable && cfg.source != null;
defaultText = literalExpression ''config.nix.enable && nixpkgs.flake.source != null'';
description = ''
Whether to set {env}`NIX_PATH` to include `nixpkgs=flake:nixpkgs` such that `<nixpkgs>`
@@ -57,8 +57,8 @@ in
setFlakeRegistry = mkOption {
type = types.bool;
default = cfg.source != null;
defaultText = "config.nixpkgs.flake.source != null";
default = config.nix.enable && cfg.source != null;
defaultText = literalExpression ''config.nix.enable && config.nixpkgs.flake.source != null'';
description = ''
Whether to pin nixpkgs in the system-wide flake registry (`/etc/nix/registry.json`) to the
@@ -85,6 +85,18 @@ in
be set, since it is implemented in terms of indirection through the flake registry.
'';
}
# TODO: Upstream these to NixOS.
{
assertion = cfg.setNixPath -> config.nix.enable;
message = ''`nixpkgs.flake.setNixPath` requires `nix.enable`'';
}
{
assertion = cfg.setFlakeRegistry -> config.nix.enable;
message = ''`nixpkgs.flake.setFlakeRegistry` requires `nix.enable`'';
}
];
}
(mkIf cfg.setFlakeRegistry {
+136 -112
View File
@@ -1,89 +1,99 @@
{ config, options, lib, pkgs, ... }:
with lib;
{
config,
options,
lib,
pkgs,
...
}:
let
cfg = config.nixpkgs;
opt = options.nixpkgs;
isConfig = x:
builtins.isAttrs x || lib.isFunction x;
isConfig = x: builtins.isAttrs x || lib.isFunction x;
optCall = f: x:
if lib.isFunction f
then f x
else f;
optCall = f: x: if lib.isFunction f then f x else f;
mergeConfig = lhs_: rhs_:
mergeConfig =
lhs_: rhs_:
let
lhs = optCall lhs_ { inherit pkgs; };
rhs = optCall rhs_ { inherit pkgs; };
lhs = optCall lhs_ { inherit lib pkgs; };
rhs = optCall rhs_ { inherit lib pkgs; };
in
recursiveUpdate lhs rhs //
optionalAttrs (lhs ? packageOverrides) {
packageOverrides = pkgs:
optCall lhs.packageOverrides pkgs //
optCall (attrByPath [ "packageOverrides" ] { } rhs) pkgs;
} //
optionalAttrs (lhs ? perlPackageOverrides) {
perlPackageOverrides = pkgs:
optCall lhs.perlPackageOverrides pkgs //
optCall (attrByPath [ "perlPackageOverrides" ] { } rhs) pkgs;
lib.recursiveUpdate lhs rhs
// lib.optionalAttrs (lhs ? allowUnfreePackages) {
allowUnfreePackages = lhs.allowUnfreePackages ++ (lib.attrByPath [ "allowUnfreePackages" ] [ ] rhs);
}
// lib.optionalAttrs (lhs ? packageOverrides) {
packageOverrides =
pkgs:
optCall lhs.packageOverrides pkgs // optCall (lib.attrByPath [ "packageOverrides" ] { } rhs) pkgs;
}
// lib.optionalAttrs (lhs ? perlPackageOverrides) {
perlPackageOverrides =
pkgs:
optCall lhs.perlPackageOverrides pkgs
// optCall (lib.attrByPath [ "perlPackageOverrides" ] { } rhs) pkgs;
};
configType = mkOptionType {
configType = lib.mkOptionType {
name = "nixpkgs-config";
description = "nixpkgs config";
check = x:
let traceXIfNot = c:
if c x then true
else lib.traceSeqN 1 x false;
in traceXIfNot isConfig;
merge = args: foldr (def: mergeConfig def.value) {};
check =
x:
let
traceXIfNot = c: if c x then true else lib.traceSeqN 1 x false;
in
traceXIfNot isConfig;
merge = args: lib.foldr (def: mergeConfig def.value) { };
};
overlayType = mkOptionType {
overlayType = lib.mkOptionType {
name = "nixpkgs-overlay";
description = "nixpkgs overlay";
check = lib.isFunction;
merge = lib.mergeOneOption;
};
pkgsType = types.pkgs // {
pkgsType = lib.types.pkgs // {
# This type is only used by itself, so let's elaborate the description a bit
# for the purpose of documentation.
description = "An evaluation of Nixpkgs; the top level attribute set of packages";
};
hasBuildPlatform = opt.buildPlatform.highestPrio < (mkOptionDefault {}).priority;
hasBuildPlatform = opt.buildPlatform.highestPrio < (lib.mkOptionDefault { }).priority;
hasHostPlatform = opt.hostPlatform.isDefined;
hasPlatform = hasHostPlatform || hasBuildPlatform;
# Context for messages
hostPlatformLine = optionalString hasHostPlatform "${showOptionWithDefLocs opt.hostPlatform}";
buildPlatformLine = optionalString hasBuildPlatform "${showOptionWithDefLocs opt.buildPlatform}";
hostPlatformLine = lib.optionalString hasHostPlatform "${lib.showOptionWithDefLocs opt.hostPlatform}";
buildPlatformLine = lib.optionalString hasBuildPlatform "${lib.showOptionWithDefLocs opt.buildPlatform}";
legacyOptionsDefined =
optional (opt.system.highestPrio < (mkDefault {}).priority) opt.system
;
legacyOptionsDefined = lib.optional (
opt.system.highestPrio < (lib.mkDefault { }).priority
) opt.system;
defaultPkgs =
if opt.hostPlatform.isDefined
then
let isCross = cfg.buildPlatform != cfg.hostPlatform;
systemArgs =
if isCross
then {
if opt.hostPlatform.isDefined then
let
isCross = cfg.buildPlatform != cfg.hostPlatform;
systemArgs =
if isCross then
{
localSystem = cfg.buildPlatform;
crossSystem = cfg.hostPlatform;
}
else {
else
{
localSystem = cfg.hostPlatform;
};
in
import cfg.source ({
inherit (cfg) config overlays;
} // systemArgs)
import cfg.source (
{
inherit (cfg) config overlays;
}
// systemArgs
)
else
import cfg.source {
inherit (cfg) config overlays;
@@ -96,9 +106,9 @@ in
{
options.nixpkgs = {
pkgs = mkOption {
pkgs = lib.mkOption {
type = pkgsType;
example = literalExpression "import <nixpkgs> {}";
example = lib.literalExpression "import <nixpkgs> {}";
description = ''
If set, the pkgs argument to all nix-darwin modules is the value of
this option, extended with `nixpkgs.overlays`, if
@@ -120,53 +130,48 @@ in
'';
};
config = mkOption {
default = {};
example = literalExpression
''
{ allowBroken = true; allowUnfree = true; }
'';
config = lib.mkOption {
default = { };
example = lib.literalExpression ''
{ allowBroken = true; allowUnfree = true; }
'';
type = configType;
description = ''
The configuration of the Nix Packages collection. (For
details, see the Nixpkgs documentation.) It allows you to set
package configuration options.
Global configuration for Nixpkgs.
The complete list of [Nixpkgs configuration options](https://nixos.org/manual/nixpkgs/unstable/#sec-config-options-reference) is in the [Nixpkgs manual section on global configuration](https://nixos.org/manual/nixpkgs/unstable/#chap-packageconfig).
Ignored when `nixpkgs.pkgs` is set.
Ignored when {option}`nixpkgs.pkgs` is set.
'';
};
overlays = mkOption {
default = [];
example = literalExpression
''
[
(self: super: {
openssh = super.openssh.override {
hpnSupport = true;
kerberos = self.libkrb5;
};
})
]
'';
type = types.listOf overlayType;
overlays = lib.mkOption {
default = [ ];
example = lib.literalExpression ''
[
(self: super: {
openssh = super.openssh.override {
hpnSupport = true;
kerberos = self.libkrb5;
};
})
]
'';
type = lib.types.listOf overlayType;
description = ''
List of overlays to use with the Nix Packages collection.
(For details, see the Nixpkgs documentation.) It allows
you to override packages globally. Each function in the list
takes as an argument the *original* Nixpkgs.
The first argument should be used for finding dependencies, and
the second should be used for overriding recipes.
List of overlays to apply to Nixpkgs.
This option allows modifying the Nixpkgs package set accessed through the `pkgs` module argument.
If `nixpkgs.pkgs` is set, overlays specified here
will be applied after the overlays that were already present
in `nixpkgs.pkgs`.
For details, see the [Overlays chapter in the Nixpkgs manual](https://nixos.org/manual/nixpkgs/stable/#chap-overlays).
If the {option}`nixpkgs.pkgs` option is set, overlays specified using `nixpkgs.overlays` will be applied after the overlays that were already included in `nixpkgs.pkgs`.
'';
};
hostPlatform = mkOption {
type = types.either types.str types.attrs; # TODO utilize lib.systems.parsedPlatform
example = { system = "aarch64-darwin"; config = "aarch64-apple-darwin"; };
hostPlatform = lib.mkOption {
type = lib.types.either lib.types.str lib.types.attrs; # TODO utilize lib.systems.parsedPlatform
example = {
system = "aarch64-darwin";
};
# Make sure that the final value has all fields for sake of other modules
# referring to this. TODO make `lib.systems` itself use the module system.
apply = lib.systems.elaborate;
@@ -179,15 +184,24 @@ in
'';
};
buildPlatform = mkOption {
type = types.either types.str types.attrs; # TODO utilize lib.systems.parsedPlatform
buildPlatform = lib.mkOption {
type = lib.types.either lib.types.str lib.types.attrs; # TODO utilize lib.systems.parsedPlatform
default = cfg.hostPlatform;
example = { system = "x86_64-darwin"; config = "x86_64-apple-darwin"; };
example = {
system = "x86_64-darwin";
};
# Make sure that the final value has all fields for sake of other modules
# referring to this.
apply = lib.systems.elaborate;
defaultText = literalExpression
''config.nixpkgs.hostPlatform'';
apply =
inputBuildPlatform:
let
elaborated = lib.systems.elaborate inputBuildPlatform;
in
if lib.systems.equals elaborated cfg.hostPlatform then
cfg.hostPlatform # make identical, so that `==` equality works; see https://github.com/NixOS/nixpkgs/issues/278001
else
elaborated;
defaultText = lib.literalExpression ''config.nixpkgs.hostPlatform'';
description = ''
Specifies the platform on which nix-darwin should be built.
By default, nix-darwin is built on the system where it runs, but you can
@@ -202,12 +216,11 @@ in
'';
};
system = mkOption {
type = types.str;
system = lib.mkOption {
type = lib.types.str;
example = "x86_64-darwin";
default =
if opt.hostPlatform.isDefined
then
if opt.hostPlatform.isDefined then
throw ''
Neither ${opt.system} nor any other option in nixpkgs.* is meant
to be read by modules and configurations.
@@ -232,9 +245,9 @@ in
# nix-darwin only
source = mkOption {
type = types.path;
defaultText = literalMD ''
source = lib.mkOption {
type = lib.types.path;
defaultText = lib.literalMD ''
`<nixpkgs>` or nix-darwin's `nixpkgs` flake input
'';
description = ''
@@ -247,8 +260,8 @@ in
'';
};
constructedByUs = mkOption {
type = types.bool;
constructedByUs = lib.mkOption {
type = lib.types.bool;
internal = true;
description = ''
Whether `pkgs` was constructed by this module. This is false when any of
@@ -266,40 +279,51 @@ in
# which is somewhat costly for Nixpkgs. With an explicit priority, we only
# evaluate the wrapper to find out that the priority is lower, and then we
# don't need to evaluate `finalPkgs`.
lib.mkOverride lib.modules.defaultOverridePriority
finalPkgs.__splicedPackages;
lib.mkOverride lib.modules.defaultOverridePriority finalPkgs.__splicedPackages;
};
nixpkgs.constructedByUs =
# We set it with default priority and it can not be merged, so if the
# pkgs module argument has that priority, it's from us.
(lib.modules.mergeAttrDefinitionsWithPrio options._module.args).pkgs.highestPrio
== lib.modules.defaultOverridePriority
== lib.modules.defaultOverridePriority
# Although, if nixpkgs.pkgs is set, we did forward it, but we did not construct it.
&& !opt.pkgs.isDefined;
&& !opt.pkgs.isDefined;
assertions = [
(
let
pkgsSystem = finalPkgs.stdenv.targetPlatform.system;
in {
in
{
assertion = cfg.constructedByUs -> !hasPlatform -> cfg.system == pkgsSystem;
message = "The nix-darwin nixpkgs.pkgs option was set to a Nixpkgs invocation that compiles to target system ${pkgsSystem} but nix-darwin was configured for system ${darwinExpectedSystem} via nix-darwin option nixpkgs.system. The nix-darwin system settings must match the Nixpkgs target system.";
message = "The nix-darwin nixpkgs.pkgs option was set to a Nixpkgs invocation that compiles to target system ${pkgsSystem} but nix-darwin was configured for system ${config.nixpkgs.system} via nix-darwin option nixpkgs.system. The nix-darwin system settings must match the Nixpkgs target system.";
}
)
{
assertion = cfg.constructedByUs -> hasPlatform -> legacyOptionsDefined == [];
assertion = cfg.constructedByUs -> hasPlatform -> legacyOptionsDefined == [ ];
message = ''
Your system configures nixpkgs with the platform parameter${optionalString hasBuildPlatform "s"}:
${hostPlatformLine
}${buildPlatformLine
}
Your system configures nixpkgs with the platform parameter${lib.optionalString hasBuildPlatform "s"}:
${hostPlatformLine}${buildPlatformLine}
However, it also defines the legacy options:
${concatMapStrings showOptionWithDefLocs legacyOptionsDefined}
${lib.concatMapStrings lib.showOptionWithDefLocs legacyOptionsDefined}
For a future proof system configuration, we recommend to remove
the legacy definitions.
'';
}
{
assertion = opt.pkgs.isDefined -> cfg.config == { };
message = ''
Your system configures nixpkgs with an externally created instance.
`nixpkgs.config` options should be passed when creating the instance instead.
Current value:
${lib.generators.toPretty { multiline = true; } cfg.config}
Defined in:
${lib.concatMapStringsSep "\n" (file: " - ${file}") opt.config.files}
'';
}
];
};
}
+49
View File
@@ -0,0 +1,49 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.programs._1password-gui;
in
{
options = {
programs._1password-gui = {
enable = lib.mkEnableOption "the 1Password GUI application";
package = lib.mkPackageOption pkgs "1Password GUI" {
default = [ "_1password-gui" ];
};
};
};
config = lib.mkIf cfg.enable {
# Based on https://github.com/reckenrode/nixos-configs/blob/22b8357fc6ffbd0df5ce50dc417c23a807a268a2/modules/by-name/1p/1password/darwin-module.nix
system.activationScripts.applications.text = lib.mkAfter ''
install -o root -g wheel -m0555 -d "/Applications/1Password.app"
rsyncFlags=(
# mtime is standardized in the nix store, which would leave only file size to distinguish files.
# Thus we need checksums, despite the speed penalty.
--checksum
# Converts all symlinks pointing outside of the copied tree (thus unsafe) into real files and directories.
# This neatly converts all the symlinks pointing to application bundles in the nix store into
# real directories, without breaking any relative symlinks inside of application bundles.
# This is good enough, because the make-symlinks-relative.sh setup hook converts all $out internal
# symlinks to relative ones.
--copy-unsafe-links
--archive
--delete
--chmod=-w
--no-group
--no-owner
)
${lib.getExe pkgs.rsync} "''${rsyncFlags[@]}" \
${cfg.package}/Applications/1Password.app/ /Applications/1Password.app
'';
};
}
+31
View File
@@ -0,0 +1,31 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.programs._1password;
in
{
options = {
programs._1password = {
enable = lib.mkEnableOption "the 1Password CLI tool";
package = lib.mkPackageOption pkgs "1Password CLI" {
default = [ "_1password-cli" ];
};
};
};
config = lib.mkIf cfg.enable {
# Integration with the 1Password GUI will only work if the CLI at `/usr/local/bin/op`
# Based on https://github.com/reckenrode/nixos-configs/blob/22b8357fc6ffbd0df5ce50dc417c23a807a268a2/modules/by-name/1p/1password/darwin-module.nix
system.activationScripts.applications.text = lib.mkAfter ''
install -o root -g wheel -m0555 -D \
${lib.getExe cfg.package} /usr/local/bin/op
'';
};
}
+41
View File
@@ -0,0 +1,41 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.programs.arqbackup;
in
{
options = {
programs.arqbackup = {
enable = lib.mkEnableOption "Arq backup";
# If `arq` is not available then we set `default` to `null` to prevent
# eval from breaking while `arq` hasn't been merged yet. Only if a user
# enables the module will they be required to set this option.
package = lib.mkPackageOption pkgs "arq" (lib.optionalAttrs (!pkgs ? arq) { default = null; });
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
launchd.daemons.arqagent = {
command = "${cfg.package}/Applications/Arq.app/Contents/Resources/ArqAgent.app/Contents/MacOS/ArqAgent";
serviceConfig.Label = "com.haystacksoftware.arqagent";
serviceConfig.RunAtLoad = true;
serviceConfig.KeepAlive = true;
};
launchd.user.agents.ArqMonitor = {
command = "${cfg.package}/Applications/Arq.app/Contents/Resources/ArqMonitor.app/Contents/MacOS/ArqMonitor";
serviceConfig.Label = "com.haystacksoftware.ArqMonitor";
serviceConfig.RunAtLoad = true;
serviceConfig.KeepAlive = true;
managedBy = "programs.arqbackup.enable";
};
};
}
+53
View File
@@ -0,0 +1,53 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.devenv;
hook = shell: "${lib.getExe cfg.package} hook ${shell}";
in
{
meta.maintainers = [
lib.maintainers.domenkozar or "domenkozar"
lib.maintainers.sandydoo or "sandydoo"
lib.maintainers.anish or "anish"
];
options.programs.devenv = {
enable = lib.mkEnableOption "devenv, fast, declarative, reproducible and composable developer environments";
package = lib.mkPackageOption pkgs "devenv" { };
enableBashIntegration = lib.mkEnableOption "auto-activation of devenv environments in Bash" // {
default = true;
};
enableFishIntegration = lib.mkEnableOption "auto-activation of devenv environments in Fish" // {
default = true;
};
enableZshIntegration = lib.mkEnableOption "auto-activation of devenv environments in Zsh" // {
default = true;
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
programs.bash.interactiveShellInit = lib.mkIf cfg.enableBashIntegration ''
eval "$(${hook "bash"})"
'';
programs.fish.interactiveShellInit = lib.mkIf cfg.enableFishIntegration ''
${hook "fish"} | source
'';
programs.zsh.interactiveShellInit = lib.mkIf cfg.enableZshIntegration ''
eval "$(${hook "zsh"})"
'';
};
}
+69 -23
View File
@@ -5,12 +5,19 @@
...
}: let
cfg = config.programs.direnv;
enabledOption =
x:
lib.mkEnableOption x
// {
default = true;
example = false;
};
format = pkgs.formats.toml {};
in {
meta.maintainers = [
lib.maintainers.mattpolzin or "mattpolzin"
];
options.programs.direnv = {
enable = lib.mkEnableOption ''
direnv integration. Takes care of both installation and
setting up the sourcing of the shell. Additionally enables nix-direnv
@@ -19,6 +26,22 @@ in {
package = lib.mkPackageOption pkgs "direnv" {};
finalPackage = lib.mkOption {
type = lib.types.package;
readOnly = true;
description = "The wrapped direnv package.";
};
enableBashIntegration = enabledOption ''
Bash integration
'';
enableZshIntegration = enabledOption ''
Zsh integration
'';
enableFishIntegration = enabledOption ''
Fish integration
'';
direnvrcExtra = lib.mkOption {
type = lib.types.lines;
default = "";
@@ -54,53 +77,76 @@ in {
package = lib.mkPackageOption pkgs "nix-direnv" {};
};
settings = lib.mkOption {
inherit (format) type;
default = {};
example = lib.literalExpression ''
{
global = {
log_format = "-";
log_filter = "^$";
};
}
'';
description = ''
Direnv configuration. Refer to {manpage}`direnv.toml(1)`.
'';
};
};
config = lib.mkIf cfg.enable {
programs = {
zsh.interactiveShellInit = ''
direnv = {
finalPackage = pkgs.symlinkJoin {
inherit (cfg.package) name;
paths = [cfg.package];
# direnv has a fish library which automatically sources direnv for some reason
postBuild = ''
rm -rf "$out/share/fish"
'';
meta.mainProgram = "direnv";
};
settings = lib.mkIf cfg.silent {
global = {
log_format = lib.mkDefault "-";
log_filter = lib.mkDefault "^$";
};
};
};
zsh.interactiveShellInit = lib.mkIf cfg.enableZshIntegration ''
if ${lib.boolToString cfg.loadInNixShell} || printenv PATH | grep -vqc '/nix/store'; then
eval "$(${lib.getExe cfg.package} hook zsh)"
eval "$(${lib.getExe cfg.finalPackage} hook zsh)"
fi
'';
#$NIX_GCROOT for "nix develop" https://github.com/NixOS/nix/blob/6db66ebfc55769edd0c6bc70fcbd76246d4d26e0/src/nix/develop.cc#L530
#$IN_NIX_SHELL for "nix-shell"
bash.interactiveShellInit = ''
bash.interactiveShellInit = lib.mkIf cfg.enableBashIntegration ''
if ${lib.boolToString cfg.loadInNixShell} || [ -z "$IN_NIX_SHELL$NIX_GCROOT$(printenv PATH | grep '/nix/store')" ] ; then
eval "$(${lib.getExe cfg.package} hook bash)"
eval "$(${lib.getExe cfg.finalPackage} hook bash)"
fi
'';
fish.interactiveShellInit = ''
fish.interactiveShellInit = lib.mkIf cfg.enableFishIntegration ''
if ${lib.boolToString cfg.loadInNixShell};
or printenv PATH | grep -vqc '/nix/store';
${lib.getExe cfg.package} hook fish | source
${lib.getExe cfg.finalPackage} hook fish | source
end
'';
};
environment = {
systemPackages =
if cfg.loadInNixShell then [cfg.package]
else [
#direnv has a fish library which sources direnv for some reason
(cfg.package.overrideAttrs (old: {
installPhase =
(old.installPhase or "")
+ ''
rm -rf $out/share/fish
'';
}))
];
systemPackages = [
cfg.finalPackage
];
variables = {
DIRENV_CONFIG = "/etc/direnv";
DIRENV_LOG_FORMAT = lib.mkIf cfg.silent "";
};
etc = {
"direnv/direnv.toml".source = lib.mkIf (cfg.settings != {}) (
format.generate "direnv.toml" cfg.settings
);
"direnv/direnvrc".text = ''
${lib.optionalString cfg.nix-direnv.enable ''
#Load nix-direnv
+17
View File
@@ -8,6 +8,10 @@ let
cfg = config.programs.fish;
fishAbbrs = concatStringsSep "\n" (
mapAttrsToList (k: v: "abbr -a ${k} -- ${escapeShellArg v}") cfg.shellAbbrs
);
fishAliases = concatStringsSep "\n" (
mapAttrsToList (k: v: "alias ${k} ${escapeShellArg v}")
(filterAttrs (k: v: v != null) cfg.shellAliases)
@@ -101,6 +105,18 @@ in
'';
};
shellAbbrs = mkOption {
default = {};
example = {
gco = "git checkout";
npu = "nix-prefetch-url";
};
description = ''
Set of fish abbreviations.
'';
type = with types; attrsOf str;
};
shellAliases = mkOption {
default = config.environment.shellAliases;
description = ''
@@ -217,6 +233,7 @@ in
# if we haven't sourced the interactive config, do it
status --is-interactive; and not set -q __fish_nix_darwin_interactive_config_sourced
and begin
${fishAbbrs}
${fishAliases}
${sourceEnv "interactiveShellInit"}
+24 -7
View File
@@ -1,8 +1,19 @@
{ config, lib, pkgs, ... }:
with lib;
{
config,
lib,
pkgs,
...
}:
let
inherit (lib)
getExe'
mkIf
mkOption
mkPackageOption
optionalString
types
;
cfg = config.programs.gnupg;
@@ -10,6 +21,8 @@ in
{
options.programs.gnupg = {
package = mkPackageOption pkgs "gnupg" { };
agent.enable = mkOption {
type = types.bool;
default = false;
@@ -29,9 +42,12 @@ in
};
config = mkIf cfg.agent.enable {
environment.systemPackages = [ cfg.package ];
launchd.user.agents.gnupg-agent.serviceConfig = {
ProgramArguments = [
"${pkgs.gnupg}/bin/gpg-connect-agent" "/bye"
(getExe' cfg.package "gpg-connect-agent")
"/bye"
];
RunAtLoad = cfg.agent.enableSSHSupport;
KeepAlive.SuccessfulExit = false;
@@ -40,12 +56,13 @@ in
environment.extraInit = ''
# Bind gpg-agent to this TTY if gpg commands are used.
export GPG_TTY=$(tty)
'' + (optionalString cfg.agent.enableSSHSupport ''
''
+ (optionalString cfg.agent.enableSSHSupport ''
# SSH agent protocol doesn't support changing TTYs, so bind the agent
# to every new TTY.
${pkgs.gnupg}/bin/gpg-connect-agent --quiet updatestartuptty /bye > /dev/null 2>&1
${getExe' cfg.package "gpg-connect-agent"} --quiet updatestartuptty /bye > /dev/null 2>&1
export SSH_AUTH_SOCK=$(${pkgs.gnupg}/bin/gpgconf --list-dirs agent-ssh-socket)
export SSH_AUTH_SOCK=$(${getExe' cfg.package "gpgconf"} --list-dirs agent-ssh-socket)
'');
};
}
+209
View File
@@ -0,0 +1,209 @@
{
config,
lib,
options,
pkgs,
...
}:
let
inherit (lib)
attrValues
concatStringsSep
escapeShellArg
getExe
literalExpression
mapAttrsToList
mkEnableOption
mkIf
mkOption
mkOptionDefault
mkPackageOption
optionalString
types
;
cfg = config.programs.mas;
apps = mapAttrsToList (name: id: { inherit name id; }) cfg.packages;
desiredIds = map (app: toString app.id) apps;
homebrewIds = map toString (attrValues config.homebrew.masApps);
hasWork = cfg.update || cfg.packages != { } || cfg.cleanup || homebrewIds != [ ];
activationScript =
if hasWork then
''
echo >&2 "setting up App Store apps (mas)..."
runAsUser() {
sudo \
--preserve-env=PATH \
--set-home \
--user=${escapeShellArg cfg.user} \
"$@"
}
listStatus=0
listOutput=$(
runAsUser ${getExe cfg.package} list 2>&1
) || listStatus=$?
if (( listStatus != 0 )); then
echo >&2 "warning: mas list failed (exit ''${listStatus}):"
echo >&2 "''${listOutput}"
if echo "''${listOutput}" | grep -qi "not signed in"; then
echo >&2 "login required; skipping App Store installs/updates/cleanup"
exit 0
fi
fi
# Only emit cleanup-only shell variables when cleanup is enabled; otherwise shellcheck
# treats them as unused and fails the activation script build.
installedIds=()
${if cfg.cleanup then
''
# Parse mas list output: "ID AppName (version)"
declare -A installedApps
while IFS= read -r line; do
[[ -z "$line" ]] && continue
line="''${line#"''${line%%[![:space:]]*}"}"
id="''${line%% *}"
rest="''${line#"$id"}"
rest="''${rest#"''${rest%%[![:space:]]*}"}"
name="''${rest% (*}"
name="''${name%"''${name##*[![:space:]]}"}"
[[ -n "$id" ]] && {
installedIds+=( "$id" )
installedApps["$id"]="$name"
}
done <<<"$listOutput"
''
else
''
while IFS= read -r line; do
[[ -z "$line" ]] && continue
line="''${line#"''${line%%[![:space:]]*}"}"
id="''${line%% *}"
[[ -n "$id" ]] && installedIds+=( "$id" )
done <<<"$listOutput"
''}
${optionalString cfg.update ''
runAsUser ${getExe cfg.package} update || true
''}
desiredIds=(
${concatStringsSep "\n " desiredIds}
)
is_installed() {
local needle=$1
for id in "''${installedIds[@]}"; do
if [[ "$id" == "$needle" ]]; then
return 0
fi
done
return 1
}
${optionalString (cfg.packages != { }) ''
for appId in "''${desiredIds[@]}"; do
if is_installed "$appId"; then
continue
fi
runAsUser ${getExe cfg.package} install "$appId" || true
done
''}
${optionalString cfg.cleanup ''
homebrewIds=(
${concatStringsSep "\n " homebrewIds}
)
keepIds=( "''${desiredIds[@]}" "''${homebrewIds[@]}" )
for installedId in "''${installedIds[@]}"; do
keep=false
for keepId in "''${keepIds[@]}"; do
if [[ "$installedId" == "$keepId" ]]; then
keep=true
break
fi
done
if ! $keep; then
appName="''${installedApps[$installedId]:-$installedId}"
echo >&2 "removing $appName from App Store"
runAsUser ${getExe cfg.package} uninstall "$installedId" || true
fi
done
''}
''
else
"";
in
{
options.programs.mas = {
enable = mkEnableOption "managing Mac App Store apps with mas";
user = mkOption {
type = types.str;
default = config.system.primaryUser;
defaultText = literalExpression "config.system.primaryUser";
description = ''
The user account that runs {command}`mas`. This user must be signed into the Mac App Store
for installs or updates to succeed.
'';
};
package = mkPackageOption pkgs "mas" { };
packages = mkOption {
type = types.attrsOf types.ints.positive;
default = { };
example = literalExpression ''
{
Xcode = 497799835;
"1Password for Safari" = 1569813296;
}
'';
description = ''
Applications to install from the Mac App Store. Attribute names are only for readability;
values must be the numeric identifiers used by {command}`mas`.
'';
};
update = mkOption {
type = types.bool;
default = true;
description = ''
Whether to run {command}`mas update` during system activation in addition to installing the
configured apps.
'';
};
cleanup = mkOption {
type = types.bool;
default = false;
description = ''
Whether to uninstall Mac App Store apps that are currently installed but not listed in
{option}`programs.mas.packages`. Apps listed in {option}`homebrew.masApps` are also preserved.
This runs before install/update; any app id not in either set will be removed.
'';
};
};
config = {
system.requiresPrimaryUser =
mkIf (cfg.enable && options.programs.mas.user.highestPrio == (mkOptionDefault { }).priority)
[
"programs.mas.enable"
];
environment.systemPackages = mkIf cfg.enable [ cfg.package ];
system.activationScripts.mas.text = mkIf cfg.enable activationScript;
};
}
@@ -1,14 +1,12 @@
{ config, lib, ... }:
with lib;
let
cfg = config.programs.ssh;
knownHosts = map (h: getAttr h cfg.knownHosts) (attrNames cfg.knownHosts);
knownHosts = builtins.attrValues cfg.knownHosts;
host =
{ name, ... }:
{ name, config, ... }:
{
options = {
certAuthority = lib.mkOption {
@@ -19,17 +17,30 @@ let
individual host's key.
'';
};
hostNames = mkOption {
type = types.listOf types.str;
default = [];
hostNames = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ name ] ++ config.extraHostNames;
description = ''
A list of host names and/or IP numbers used for accessing
the host's ssh service.
The set of system-wide known SSH hosts. To make simple setups more
convenient the name of an attribute in this set is used as a host name
for the entry. This behaviour can be disabled by setting
`hostNames` explicitly. You can use
`extraHostNames` to add additional host names without
disabling this default.
'';
};
publicKey = mkOption {
extraHostNames = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
description = ''
A list of additional host names and/or IP numbers used for
accessing the host's ssh service. This list is ignored if
`hostNames` is set explicitly.
'';
};
publicKey = lib.mkOption {
default = null;
type = types.nullOr types.str;
type = lib.types.nullOr lib.types.str;
example = "ecdsa-sha2-nistp521 AAAAE2VjZHN...UEPg==";
description = ''
The public key data for the host. You can fetch a public key
@@ -38,9 +49,9 @@ let
the key type and the key itself.
'';
};
publicKeyFile = mkOption {
publicKeyFile = lib.mkOption {
default = null;
type = types.nullOr types.path;
type = lib.types.nullOr lib.types.path;
description = ''
The path to the public key file for the host. The public
key file is read at build time and saved in the Nix store.
@@ -51,16 +62,13 @@ let
'';
};
};
config = {
hostNames = mkDefault [ name ];
};
};
# Taken from: https://github.com/NixOS/nixpkgs/blob/f4aa6afa5f934ece2d1eb3157e392d056be01617/nixos/modules/services/networking/ssh/sshd.nix#L46-L93
userOptions = {
options.openssh.authorizedKeys = {
keys = mkOption {
type = types.listOf types.str;
keys = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
description = ''
A list of verbatim OpenSSH public keys that should be added to the
@@ -73,8 +81,8 @@ let
'';
};
keyFiles = mkOption {
type = types.listOf types.path;
keyFiles = lib.mkOption {
type = lib.types.listOf lib.types.path;
default = [];
description = ''
A list of files each containing one OpenSSH public key that should be
@@ -89,29 +97,29 @@ let
};
authKeysFiles = let
mkAuthKeyFile = u: nameValuePair "ssh/nix_authorized_keys.d/${u.name}" {
mkAuthKeyFile = u: lib.nameValuePair "ssh/nix_authorized_keys.d/${u.name}" {
text = ''
${concatStringsSep "\n" u.openssh.authorizedKeys.keys}
${concatMapStrings (f: readFile f + "\n") u.openssh.authorizedKeys.keyFiles}
${builtins.concatStringsSep "\n" u.openssh.authorizedKeys.keys}
${lib.concatMapStrings (f: builtins.readFile f + "\n") u.openssh.authorizedKeys.keyFiles}
'';
};
usersWithKeys = attrValues (flip filterAttrs config.users.users (n: u:
length u.openssh.authorizedKeys.keys != 0 || length u.openssh.authorizedKeys.keyFiles != 0
usersWithKeys = builtins.attrValues (lib.flip lib.filterAttrs config.users.users (n: u:
lib.length u.openssh.authorizedKeys.keys != 0 || lib.length u.openssh.authorizedKeys.keyFiles != 0
));
in listToAttrs (map mkAuthKeyFile usersWithKeys);
in lib.listToAttrs (map mkAuthKeyFile usersWithKeys);
oldAuthorizedKeysHash = "5a5dc1e20e8abc162ad1cc0259bfd1dbb77981013d87625f97d9bd215175fc0a";
in
{
imports = [
(mkRemovedOptionModule [ "services" "openssh" "authorizedKeysFiles" ] "No `nix-darwin` equivalent to this NixOS option.")
(lib.mkRemovedOptionModule [ "services" "openssh" "authorizedKeysFiles" ] "No `nix-darwin` equivalent to this NixOS option.")
];
options = {
users.users = mkOption {
type = with types; attrsOf (submodule userOptions);
users.users = lib.mkOption {
type = with lib.types; attrsOf (submodule userOptions);
};
programs.ssh.extraConfig = lib.mkOption {
@@ -123,41 +131,47 @@ in
'';
};
programs.ssh.knownHosts = mkOption {
programs.ssh.knownHosts = lib.mkOption {
default = {};
type = types.attrsOf (types.submodule host);
type = lib.types.attrsOf (lib.types.submodule host);
description = ''
The set of system-wide known SSH hosts.
The set of system-wide known SSH hosts. To make simple setups more
convenient the name of an attribute in this set is used as a host name
for the entry. This behaviour can be disabled by setting
`hostNames` explicitly. You can use
`extraHostNames` to add additional host names without
disabling this default.
'';
example = literalExpression ''
[
{
hostNames = [ "myhost" "myhost.mydomain.com" "10.10.1.4" ];
example = lib.literalExpression ''
{
myhost = {
extraHostNames = [ "myhost.mydomain.com" "10.10.1.4" ];
publicKeyFile = ./pubkeys/myhost_ssh_host_dsa_key.pub;
}
{
hostNames = [ "myhost2" ];
};
"myhost2.net".publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILIRuJ8p1Fi+m6WkHV0KWnRfpM1WxoW8XAS+XvsSKsTK";
"myhost2.net/dsa" = {
hostNames = [ "myhost2.net" ];
publicKeyFile = ./pubkeys/myhost2_ssh_host_dsa_key.pub;
}
]
};
}
'';
};
};
config = {
assertions = flip mapAttrsToList cfg.knownHosts (name: data: {
assertions = lib.flip lib.mapAttrsToList cfg.knownHosts (name: data: {
assertion = (data.publicKey == null && data.publicKeyFile != null) ||
(data.publicKey != null && data.publicKeyFile == null);
message = "knownHost ${name} must contain either a publicKey or publicKeyFile";
});
environment.etc = authKeysFiles //
{ "ssh/ssh_known_hosts" = mkIf (builtins.length knownHosts > 0) {
text = (flip (concatMapStringsSep "\n") knownHosts
{ "ssh/ssh_known_hosts" = lib.mkIf (builtins.length knownHosts > 0) {
text = (lib.flip (lib.concatMapStringsSep "\n") knownHosts
(h: assert h.hostNames != [];
lib.optionalString h.certAuthority "@cert-authority " + concatStringsSep "," h.hostNames + " "
+ (if h.publicKey != null then h.publicKey else readFile h.publicKeyFile)
lib.optionalString h.certAuthority "@cert-authority " + builtins.concatStringsSep "," h.hostNames + " "
+ (if h.publicKey != null then h.publicKey else builtins.readFile h.publicKeyFile)
)) + "\n";
};
"ssh/ssh_config.d/100-nix-darwin.conf".text = config.programs.ssh.extraConfig;
+16 -2
View File
@@ -57,6 +57,17 @@ in
description = "Enable sensible configuration options for tmux.";
};
programs.tmux.reverseSplitBindings = mkOption {
type = types.bool;
default = config.system.stateVersion <= 6 && cfg.enableSensible;
defaultText = literalExpression "config.system.stateVersion <= 6 && config.programs.tmux.enableSensible";
example = true;
description = ''
Whether to reverse the `%` and `"` split-window key bindings
emitted by the tmux module.
'';
};
programs.tmux.enableMouse = mkOption {
type = types.bool;
default = false;
@@ -127,8 +138,6 @@ in
set -s escape-time 0
bind c new-window -c '#{pane_current_path}'
bind % split-window -v -c '#{pane_current_path}'
bind '"' split-window -h -c '#{pane_current_path}'
# TODO: make these interactive
bind C new-session
@@ -138,6 +147,11 @@ in
# set -g utf8 on
'';
programs.tmux.tmuxOptions.splitBindings.text = mkIf cfg.reverseSplitBindings ''
bind % split-window -v -c '#{pane_current_path}'
bind '"' split-window -h -c '#{pane_current_path}'
'';
programs.tmux.tmuxOptions.mouse.text = mkIf cfg.enableMouse ''
set -g mouse on
setw -g mouse on
+2 -2
View File
@@ -77,7 +77,7 @@ in
config = mkIf cfg.enable {
environment.systemPackages =
[ # Include vim_configurable package.
[ # Include vim-full package.
cfg.package
];
@@ -92,7 +92,7 @@ in
endif
'';
programs.vim.package = pkgs.vim_configurable.customize {
programs.vim.package = pkgs.vim-full.customize {
name = "vim";
vimrcConfig.customRC = config.environment.etc."vimrc".text;
vimrcConfig.vam = {
+34 -5
View File
@@ -59,6 +59,18 @@ in
description = "Shell script code used to initialise the zsh prompt.";
};
programs.zsh.histSize = mkOption {
type = types.int;
default = 2000;
description = "Change history size.";
};
programs.zsh.histFile = mkOption {
type = types.str;
default = "$HOME/.zsh_history";
description = "Change history file.";
};
programs.zsh.enableCompletion = mkOption {
type = types.bool;
default = true;
@@ -102,6 +114,12 @@ in
description = "Enable fzf keybinding for Ctrl-r history search.";
};
programs.zsh.enableAutosuggestions = mkOption {
type = types.bool;
default = false;
description = "Enable zsh-autosuggestions.";
};
programs.zsh.enableSyntaxHighlighting = mkOption {
type = types.bool;
default = false;
@@ -123,6 +141,7 @@ in
[ # Include zsh package
pkgs.zsh
] ++ optional cfg.enableCompletion pkgs.nix-zsh-completions
++ optional cfg.enableAutosuggestions pkgs.zsh-autosuggestions
++ optional cfg.enableSyntaxHighlighting pkgs.zsh-syntax-highlighting
++ optional cfg.enableFastSyntaxHighlighting pkgs.zsh-fast-syntax-highlighting;
@@ -182,10 +201,11 @@ in
if [ -n "$__ETC_ZSHRC_SOURCED" -o -n "$NOSYSZSHRC" ]; then return; fi
__ETC_ZSHRC_SOURCED=1
# history defaults
SAVEHIST=2000
HISTSIZE=2000
HISTFILE=$HOME/.zsh_history
# Setup command line history.
# Don't export these, otherwise other shells (bash) will try to use same HISTFILE.
SAVEHIST=${builtins.toString cfg.histSize}
HISTSIZE=${builtins.toString cfg.histSize}
HISTFILE=${cfg.histFile}
setopt HIST_IGNORE_DUPS SHARE_HISTORY HIST_FCNTL_LOCK
@@ -199,12 +219,16 @@ in
${optionalString cfg.enableGlobalCompInit "autoload -U compinit && compinit"}
${optionalString cfg.enableBashCompletion "autoload -U bashcompinit && bashcompinit"}
${optionalString cfg.enableAutosuggestions
"source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
}
${optionalString cfg.enableSyntaxHighlighting
"source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
}
${optionalString cfg.enableFastSyntaxHighlighting
"source ${pkgs.zsh-fast-syntax-highlighting}/share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh"
"source ${pkgs.zsh-fast-syntax-highlighting}/share/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh"
}
${optionalString cfg.enableFzfCompletion "source ${fzfCompletion}"}
@@ -220,18 +244,23 @@ in
environment.etc."zprofile".knownSha256Hashes = [
"db8422f92d8cff684e418f2dcffbb98c10fe544b5e8cd588b2009c7fa89559c5"
"0235d3c1b6cf21e7043fbc98e239ee4bc648048aafaf6be1a94a576300584ef2" # macOS
"f320016e2cf13573731fbee34f9fe97ba867dd2a31f24893d3120154e9306e92" # macOS 26b1 and higher
];
environment.etc."zshrc".knownSha256Hashes = [
"19a2d673ffd47b8bed71c5218ff6617dfc5e8533b240b9ba79142a45f8823c23"
"fb5827cb4712b7e7932d438067ec4852c8955a9ff0f55e282473684623ebdfa1" # macOS
"4d1ab5704f9d167a042fecac0d056c8a79a8ebd71e032d3489536c8db9ffe3e0" # macOS 26b1 and higher
"c5a00c072c920f46216454978c44df044b2ec6d03409dc492c7bdcd92c94a110" # official Nix installer
"40b0d8751adae5b0100a4f863be5b75613a49f62706427e92604f7e04d2e2261" # official Nix installer
"bf76c5ed8e65e616f4329eccf662ee91be33b8bfd33713ce9946f2fe94fea7fa" # official Nix installer (macOS 26b1 and higher)
"2af1b563e389d11b76a651b446e858116d7a20370d9120a7e9f78991f3e5f336" # DeterminateSystems installer
"27274e44b88a1174787f9a3d437d3387edc4f9aaaf40356054130797f5dc7912" # DeterminateSystems installer (macOS 26b1 and higher)
];
environment.etc."zshenv".knownSha256Hashes = [
"d07015be6875f134976fce84c6c7a77b512079c1c5f9594dfa65c70b7968b65f" # DeterminateSystems installer
"4e8f7cb9b699511f4ba5f9d5f8de1c9f5efb5c607de88faf5f58b8b9cb38edbf" # experimental official Nix installer 2.33.3
];
};
+88 -51
View File
@@ -1,69 +1,106 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.security.pam;
# Implementation Notes
#
# We don't use `environment.etc` because this would require that the user manually delete
# `/etc/pam.d/sudo` which seems unwise given that applying the nix-darwin configuration requires
# sudo. We also can't use `system.patchs` since it only runs once, and so won't patch in the
# changes again after OS updates (which remove modifications to this file).
#
# As such, we resort to line addition/deletion in place using `sed`. We add a comment to the
# added line that includes the name of the option, to make it easier to identify the line that
# should be deleted when the option is disabled.
mkSudoTouchIdAuthScript = isEnabled:
let
file = "/etc/pam.d/sudo";
option = "security.pam.enableSudoTouchIdAuth";
sed = "${pkgs.gnused}/bin/sed";
in ''
${if isEnabled then ''
# Enable sudo Touch ID authentication, if not already enabled
if ! grep 'pam_tid.so' ${file} > /dev/null; then
${sed} -i '2i\
auth sufficient pam_tid.so # nix-darwin: ${option}
' ${file}
fi
'' else ''
# Disable sudo Touch ID authentication, if added by nix-darwin
if grep '${option}' ${file} > /dev/null; then
${sed} -i '/${option}/d' ${file}
fi
''}
'';
cfg = config.security.pam.services.sudo_local;
in
{
imports = [
(lib.mkRemovedOptionModule [ "security" "pam" "enableSudoTouchIdAuth" ] ''
This option has been renamed to `security.pam.services.sudo_local.touchIdAuth` for consistency with NixOS.
'')
];
options = {
security.pam.enableSudoTouchIdAuth = mkEnableOption "" // {
description = ''
Enable sudo authentication with Touch ID.
security.pam.services.sudo_local = {
enable = lib.mkEnableOption "managing {file}`/etc/pam.d/sudo_local` with nix-darwin" // {
default = true;
example = false;
};
When enabled, this option adds the following line to
{file}`/etc/pam.d/sudo`:
text = lib.mkOption {
type = lib.types.lines;
default = "";
description = ''
Contents of {file}`/etc/pam.d/sudo_local`
'';
};
```
auth sufficient pam_tid.so
```
touchIdAuth = lib.mkEnableOption "" // {
description = ''
Whether to enable Touch ID with sudo.
::: {.note}
macOS resets this file when doing a system update. As such, sudo
authentication with Touch ID won't work after a system update
until the nix-darwin configuration is reapplied.
:::
'';
This will also allow your Apple Watch to be used for sudo. If this doesn't work,
you can go into `System Settings > Touch ID & Password` and toggle the switch for
your Apple Watch.
'';
};
watchIdAuth = lib.mkEnableOption "" // {
description = ''
Use Apple Watch for sudo authentication, for devices without Touch ID or
laptops with lids closed, consider using this.
When enabled, you can use your Apple Watch to authenticate sudo commands.
If this doesn't work, you can go into `System Settings > Touch ID & Password`
and toggle the switch for your Apple Watch.
'';
};
reattach = lib.mkEnableOption "" // {
description = ''
Whether to enable reattaching a program to the user's bootstrap session.
This fixes Touch ID for sudo not working inside tmux and screen.
This allows programs like tmux and screen that run in the background to
survive across user sessions to work with PAM services that are tied to the
bootstrap session.
'';
};
};
};
config = {
system.activationScripts.pam.text = ''
security.pam.services.sudo_local.text = lib.concatLines (
(lib.optional cfg.reattach "auth optional ${pkgs.pam-reattach}/lib/pam/pam_reattach.so")
++ (lib.optional cfg.touchIdAuth "auth sufficient pam_tid.so")
++ (lib.optional cfg.watchIdAuth "auth sufficient ${pkgs.pam-watchid}/lib/pam_watchid.so")
);
environment.etc."pam.d/sudo_local" = {
inherit (cfg) enable text;
};
system.activationScripts.pam.text =
let
file = "/etc/pam.d/sudo";
marker = "security.pam.services.sudo_local";
deprecatedOption = "security.pam.enableSudoTouchIdAuth";
sed = lib.getExe pkgs.gnused;
in
''
# PAM settings
echo >&2 "setting up pam..."
${mkSudoTouchIdAuthScript cfg.enableSudoTouchIdAuth}
# REMOVEME when macOS 13 no longer supported as macOS automatically
# nukes this file on system upgrade
# Always clear out older implementation if it is present
if grep '${deprecatedOption}' ${file} > /dev/null; then
${sed} -i '/${deprecatedOption}/d' ${file}
fi
${if cfg.enable then ''
# REMOVEME when macOS 13 no longer supported
# `sudo_local` is automatically included after macOS 14
if ! grep 'sudo_local' ${file} > /dev/null; then
${sed} -i '2iauth include sudo_local # nix-darwin: ${marker}' ${file}
fi
'' else ''
# Remove include line if we added it
if grep '${marker}' ${file} > /dev/null; then
${sed} -i '/${marker}/d' ${file}
fi
''}
'';
};
}
+45 -4
View File
@@ -1,5 +1,35 @@
{ config, lib, pkgs, ... }:
let
activationPath =
lib.makeBinPath (
[
pkgs.gnugrep
pkgs.coreutils
] ++ lib.optionals config.nix.enable [ config.nix.package ]
)
+ lib.optionalString (!config.nix.enable) ''
$(
# If `nix.enable` is off, there might be an unmanaged Nix
# installation (say in `/nix/var/nix/profiles/default`) that
# activation scripts (such as Home Manager) want to find on the
# `$PATH`. Search for it directly to avoid polluting the
# activation script environment with everything on the
# `environment.systemPath`.
if nixEnvPath=$(
PATH="${config.environment.systemPath}" command -v nix-env
); then
printf ':'
${lib.getExe' pkgs.coreutils "dirname"} -- "$(
${lib.getExe' pkgs.coreutils "readlink"} \
--canonicalize-missing \
-- "$nixEnvPath"
)"
fi
)''
+ ":/usr/bin:/bin:/usr/sbin:/sbin";
in
{
imports = [
(lib.mkRemovedOptionModule [ "services" "activate-system" "enable" ] "The `activate-system` service is now always enabled as it is necessary for a working `nix-darwin` setup.")
@@ -10,7 +40,17 @@
script = ''
set -e
set -o pipefail
export PATH="${pkgs.gnugrep}/bin:${pkgs.coreutils}/bin:@out@/sw/bin:/usr/bin:/bin:/usr/sbin:/sbin"
PATH="${activationPath}"
export PATH
export USER=root
export LOGNAME=root
export HOME=~root
export MAIL=/var/mail/root
export SHELL=$BASH
export LANG=C
export LC_CTYPE=UTF-8
systemConfig=$(cat ${config.system.profile}/systemConfig)
@@ -21,14 +61,15 @@
ln -sfn $(cat ${config.system.profile}/systemConfig) /run/current-system
# Prevent the current configuration from being garbage-collected.
ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
if [[ -d /nix/var/nix/gcroots ]]; then
ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
fi
${config.system.activationScripts.etcChecks.text}
${config.system.activationScripts.checks.text}
${config.system.activationScripts.etc.text}
${config.system.activationScripts.keyboard.text}
'';
serviceConfig.RunAtLoad = true;
serviceConfig.KeepAlive.SuccessfulExit = false;
};
};
}
+2
View File
@@ -199,6 +199,7 @@ in
type = enum [
"qwerty"
"dvorak"
"colemak"
];
default = "qwerty";
description = "Keymapping preset.";
@@ -253,6 +254,7 @@ in
KeepAlive = true;
RunAtLoad = true;
};
managedBy = "services.aerospace.enable";
};
}
);
+2 -2
View File
@@ -55,7 +55,7 @@ in
default = [];
description = ''
List of AutoSSH sessions to start as systemd services. Each service is
List of AutoSSH sessions to start as launchd daemon. Each daemon is
named 'autossh-{session.name}'.
'';
@@ -78,7 +78,7 @@ in
config = mkIf (cfg.sessions != []) {
launchd.daemons =
lib.fold ( s : acc : acc //
lib.foldr ( s : acc : acc //
{
"autossh-${s.name}" =
let
+10 -3
View File
@@ -227,14 +227,21 @@ in
{ path = cfg.runtimePackages ++ [ cfg.package pkgs.coreutils pkgs.darwin.DarwinTools ];
environment = {
HOME = cfg.dataDir;
NIX_REMOTE = "daemon";
inherit (config.environment.variables) NIX_SSL_CERT_FILE;
} // (if config.nix.useDaemon then { NIX_REMOTE = "daemon"; } else {});
};
## NB: maximum care is taken so that secrets (ssh keys and the CI token)
## don't end up in the Nix store.
script = let
sshDir = "${cfg.dataDir}/.ssh";
tagStr = lib.concatStringsSep "," (lib.mapAttrsToList (name: value: "${name}=${value}") cfg.tags);
tagStr =
name: value:
if lib.isList value then
lib.concatStringsSep "," (builtins.map (v: "${name}=${v}") value)
else
"${name}=${value}";
tagsStr = lib.concatStringsSep "," (lib.mapAttrsToList tagStr cfg.tags);
in
optionalString (cfg.privateSshKeyPath != null) ''
mkdir -m 0700 "${sshDir}"
@@ -244,7 +251,7 @@ in
token="$(cat ${toString cfg.tokenPath})"
name="${cfg.name}"
shell="${cfg.shell}"
tags="${tagStr}"
tags="${tagsStr}"
build-path="${cfg.dataDir}/builds"
hooks-path="${cfg.hooksPath}"
${cfg.extraConfig}
+8
View File
@@ -51,6 +51,14 @@ in {
};
config = mkIf cfg.enable {
# TODO: Upstream this to NixOS.
assertions = [
{
assertion = config.nix.enable;
message = ''`services.cachix-agent.enable` requires `nix.enable`'';
}
];
launchd.daemons.cachix-agent = {
script = ''
. ${cfg.credentialsFile}
+1
View File
@@ -126,6 +126,7 @@ in
serviceConfig.RunAtLoad = true;
serviceConfig.KeepAlive = true;
serviceConfig.ProcessType = "Interactive";
managedBy = "services.chunkwm.enable";
};
};
+81
View File
@@ -0,0 +1,81 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.dnscrypt-proxy;
format = pkgs.formats.toml { };
configFile = format.generate "dnscrypt-proxy.toml" cfg.settings;
in
{
options.services.dnscrypt-proxy = {
enable = lib.mkEnableOption "the dnscrypt-proxy service.";
package = lib.mkPackageOption pkgs "dnscrypt-proxy" { };
settings = lib.mkOption {
description = ''
Attrset that is converted and passed as TOML config file.
For available params, see: <https://github.com/DNSCrypt/dnscrypt-proxy/blob/${pkgs.dnscrypt-proxy.version}/dnscrypt-proxy/example-dnscrypt-proxy.toml>
'';
example = lib.literalExpression ''
{
sources.public-resolvers = {
urls = [ "https://download.dnscrypt.info/resolvers-list/v2/public-resolvers.md" ];
cache_file = "public-resolvers.md";
minisign_key = "RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3";
refresh_delay = 72;
};
}
'';
type = format.type;
default = { };
};
};
config = lib.mkIf cfg.enable {
users.users._dnscrypt-proxy = {
uid = config.ids.uids._dnscrypt-proxy;
gid = config.ids.gids._dnscrypt-proxy;
home = "/var/lib/dnscrypt-proxy";
createHome = true;
shell = "/usr/bin/false";
description = "System user for dnscrypt-proxy";
};
users.groups._dnscrypt-proxy = {
gid = config.ids.gids._dnscrypt-proxy;
description = "System group for dnscrypt-proxy";
};
users.knownUsers = [ "_dnscrypt-proxy" ];
users.knownGroups = [ "_dnscrypt-proxy" ];
launchd.daemons.dnscrypt-proxy = {
script = ''
${lib.getExe' cfg.package "dnscrypt-proxy"} -config ${configFile}
'';
serviceConfig =
let
logPath = config.users.users._dnscrypt-proxy.home + "/dnscrypt-proxy.log";
in
{
RunAtLoad = true;
KeepAlive = true;
StandardOutPath = logPath;
StandardErrorPath = logPath;
GroupName = "_dnscrypt-proxy";
UserName = "_dnscrypt-proxy";
};
};
};
}
+30 -6
View File
@@ -42,18 +42,42 @@ in
{ localhost = "127.0.0.1"; }
'';
};
services.dnsmasq.servers = mkOption {
type = types.listOf types.str;
default = [];
description = ''
List of upstream DNS servers to forward queries to.
If empty, dnsmasq will use the servers from /etc/resolv.conf.
Each entry can be:
- An IP address (e.g., "1.2.3.4")
- A domain-specific server (e.g., "/example.com/1.2.3.4")
- A server with port (e.g., "1.2.3.4#5353")
See dnsmasq(8) man page for --server option for full syntax.
'';
example = literalExpression ''
[
"8.8.8.8"
"8.8.4.4"
"/internal.example.com/192.168.1.1"
]
'';
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
launchd.daemons.dnsmasq = {
serviceConfig.ProgramArguments = [
"${cfg.package}/bin/dnsmasq"
"--listen-address=${cfg.bind}"
"--port=${toString cfg.port}"
"--keep-in-foreground"
] ++ (mapA (domain: addr: "--address=/${domain}/${addr}") cfg.addresses);
command = let
args = [
"--listen-address=${cfg.bind}"
"--port=${toString cfg.port}"
"--keep-in-foreground"
] ++ (mapA (domain: addr: "--address=/${domain}/${addr}") cfg.addresses)
++ (map (server: "--server=${server}") cfg.servers);
in
"${cfg.package}/bin/dnsmasq ${concatStringsSep " " args}";
serviceConfig.KeepAlive = true;
serviceConfig.RunAtLoad = true;
+1
View File
@@ -49,6 +49,7 @@ in {
RunAtLoad = true;
KeepAlive = true;
};
managedBy = "services.emacs.enable";
};
};
+2 -2
View File
@@ -262,8 +262,8 @@ in
};
nodeRuntimes = mkOption {
type = with types; nonEmptyListOf (enum [ "node20" ]);
default = [ "node20" ];
type = with types; nonEmptyListOf (enum [ "node20" "node24" ]);
default = [ "node24" ];
description = ''
List of Node.js runtimes the runner should support.
'';
+23 -21
View File
@@ -2,17 +2,22 @@
let
inherit (lib) any attrValues boolToString concatStringsSep escapeShellArg
flatten flip getExe getExe' hasAttr hasPrefix mapAttrsToList mapAttrs' mkBefore
mkDefault mkIf mkMerge nameValuePair optionalAttrs optionalString replaceStrings;
flatten flip getExe getExe' hasPrefix mapAttrsToList mapAttrs' mkBefore
mkDefault mkIf mkMerge nameValuePair optionalString replaceStrings;
mkSvcName = name: "github-runner-${name}";
mkStateDir = cfg: "/var/lib/github-runners/${cfg.name}";
mkLogDir = cfg: "/var/log/github-runners/${cfg.name}";
mkWorkDir = cfg: if (cfg.workDir != null) then cfg.workDir else "/var/lib/github-runners/_work/${cfg.name}";
mkWorkDir = cfg: if (cfg.workDir != null) then cfg.workDir else "/private/var/lib/github-runners/_work/${cfg.name}";
in
{
config.assertions = flatten (
flip mapAttrsToList config.services.github-runners (name: cfg: map (mkIf cfg.enable) [
# TODO: Upstream this to NixOS.
{
assertion = config.nix.enable;
message = ''`services.github-runners.${name}.enable` requires `nix.enable`'';
}
{
assertion = (cfg.user == null && cfg.group == null) || (cfg.user != null);
message = "`services.github-runners.${name}`: Either set `user` and `group` to `null` to have nix-darwin manage them or set at least `user` explicitly";
@@ -22,7 +27,7 @@ in
message = "`services.github-runners.${name}`: The `extraLabels` option is mandatory if `noDefaultLabels` is set";
}
{
assertion = cfg.workDir == null || !(hasPrefix "/run/" cfg.workDir || hasPrefix "/var/run/" cfg.workDir || hasPrefix "/private/var/run/");
assertion = cfg.workDir == null || !(hasPrefix "/run/" cfg.workDir || hasPrefix "/var/run/" cfg.workDir || hasPrefix "/private/var/run/" cfg.workDir);
message = "`services.github-runners.${name}`: `workDir` being inside /run is not supported";
}
])
@@ -49,32 +54,29 @@ in
in
{
launchd = mkIf cfg.enable {
text = mkBefore (''
text = mkBefore ''
echo >&2 "setting up GitHub Runner '${cfg.name}'..."
(
umask -S u=rwx,g=rx,o= > /dev/null
# shellcheck disable=SC2174
${getExe' pkgs.coreutils "mkdir"} -p -m u=rwx,g=rx,o= ${escapeShellArg (mkStateDir cfg)}
${getExe' pkgs.coreutils "chown"} ${user}:${group} ${escapeShellArg (mkStateDir cfg)}
${getExe' pkgs.coreutils "mkdir"} -p ${escapeShellArg (mkStateDir cfg)}
${getExe' pkgs.coreutils "chown"} ${user}:${group} ${escapeShellArg (mkStateDir cfg)}
# shellcheck disable=SC2174
${getExe' pkgs.coreutils "mkdir"} -p -m u=rwx,g=rx,o= ${escapeShellArg (mkLogDir cfg)}
${getExe' pkgs.coreutils "chown"} ${user}:${group} ${escapeShellArg (mkLogDir cfg)}
${getExe' pkgs.coreutils "mkdir"} -p ${escapeShellArg (mkLogDir cfg)}
# launchd will fail to start the service if the outer direction doesn't have sufficient permissions
${getExe' pkgs.coreutils "chmod"} o+rx ${escapeShellArg (mkLogDir { name = ""; })}
${getExe' pkgs.coreutils "chown"} ${user}:${group} ${escapeShellArg (mkLogDir cfg)}
${optionalString (cfg.workDir == null) ''
${getExe' pkgs.coreutils "mkdir"} -p ${escapeShellArg (mkWorkDir cfg)}
${getExe' pkgs.coreutils "chown"} ${user}:${group} ${escapeShellArg (mkWorkDir cfg)}
''}
)
'');
${optionalString (cfg.workDir == null) ''
# shellcheck disable=SC2174
${getExe' pkgs.coreutils "mkdir"} -p -m u=rwx,g=rx,o= ${escapeShellArg (mkWorkDir cfg)}
${getExe' pkgs.coreutils "chown"} ${user}:${group} ${escapeShellArg (mkWorkDir cfg)}
''}
'';
};
}));
config.launchd.daemons = flip mapAttrs' config.services.github-runners (name: cfg:
let
package = cfg.package.override (old: optionalAttrs (hasAttr "nodeRuntimes" old) { inherit (cfg) nodeRuntimes; });
package = cfg.package.override { inherit (cfg) nodeRuntimes; };
stateDir = mkStateDir cfg;
logDir = mkLogDir cfg;
workDir = mkWorkDir cfg;
+9 -7
View File
@@ -19,6 +19,7 @@ let
# make config file readable by service
chown -R --reference=$HOME $(dirname ${configPath})
'' else ''
set -e
export CONFIG_FILE=${configPath}
mkdir -p $(dirname ${configPath})
@@ -92,8 +93,8 @@ let
done
# update global options
remarshal --if toml --of json ${configPath} \
| jq -cM ${escapeShellArg (concatStringsSep " | " [
tomlq -t \
${escapeShellArg (concatStringsSep " | " [
".check_interval = ${toJSON cfg.checkInterval}"
".concurrent = ${toJSON cfg.concurrent}"
".sentry_dsn = ${toJSON cfg.sentryDSN}"
@@ -103,9 +104,9 @@ let
".session_server.session_timeout = ${toJSON cfg.sessionServer.sessionTimeout}"
"del(.[] | nulls)"
"del(.session_server[] | nulls)"
])} \
| remarshal --if json --of toml \
| sponge ${configPath}
])} ${configPath} \
> config.toml.new
mv config.toml.new ${configPath}
# make config file readable by service
chown -R --reference=$HOME $(dirname ${configPath})
@@ -551,14 +552,15 @@ in
launchd.daemons.gitlab-runner = {
environment = { #config.networking.proxy.envVars // {
HOME = "${config.users.users.gitlab-runner.home}";
NIX_REMOTE = "daemon";
NIX_SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
} // (if config.nix.useDaemon then { NIX_REMOTE = "daemon"; } else {});
};
path = with pkgs; [
bash
gawk
jq
moreutils
remarshal
yq
# util-linux
cfg.package
coreutils
@@ -22,6 +22,14 @@ in
};
config = mkIf cfg.enable {
# TODO: Upstream this to NixOS.
assertions = [
{
assertion = config.nix.enable;
message = ''`services.hercules-ci-agent.enable` requires `nix.enable`'';
}
];
launchd.daemons.hercules-ci-agent = {
script = "exec ${cfg.package}/bin/hercules-ci-agent --config ${cfg.tomlFile}";
@@ -74,7 +82,7 @@ in
darwin.label = config.system.darwinLabel;
darwin.revision = config.system.darwinRevision;
darwin.version = config.system.darwinVersion;
darwin.nix.daemon = config.nix.useDaemon;
darwin.nix.daemon = true;
darwin.nix.sandbox = config.nix.settings.sandbox;
};
};
+1
View File
@@ -64,6 +64,7 @@ in
StandardErrorPath = cfg.logFile;
EnvironmentVariables = {} // (optionalAttrs (cfg.ipfsPath != null) { IPFS_PATH = cfg.ipfsPath; });
};
managedBy = "services.ipfs.enable";
};
};
}
+2 -1
View File
@@ -22,7 +22,7 @@ in {
];
options.services.jankyborders = {
enable = mkEnableOption "Enable the jankyborders service.";
enable = mkEnableOption "the jankyborders service.";
package = mkPackageOption pkgs "jankyborders" {};
@@ -162,6 +162,7 @@ in {
++ (optionalArg "order" cfg.order);
serviceConfig.KeepAlive = true;
serviceConfig.RunAtLoad = true;
managedBy = "services.jankyborders.enable";
};
};
}
@@ -84,6 +84,7 @@ in
"${parentAppDir}/.Karabiner-VirtualHIDDevice-Manager.app/Contents/MacOS/Karabiner-VirtualHIDDevice-Manager" "activate"
];
serviceConfig.RunAtLoad = true;
managedBy = "services.karabiner-elements.enable";
};
# We need this to run every reboot as /run gets nuked so we can't put this
@@ -101,10 +102,11 @@ in
launchd.user.agents.karabiner_session_monitor = {
serviceConfig.ProgramArguments = [
"/bin/sh" "-c"
"/bin/wait4path /run/wrappers/bin &amp;&amp; /run/wrappers/bin/karabiner_session_monitor"
"/bin/wait4path /run/wrappers/bin && /run/wrappers/bin/karabiner_session_monitor"
];
serviceConfig.Label = "org.pqrs.karabiner.karabiner_session_monitor";
serviceConfig.KeepAlive = true;
managedBy = "services.karabiner-elements.enable";
};
environment.userLaunchAgents."org.pqrs.karabiner.agent.karabiner_grabber.plist".source = "${cfg.package}/Library/LaunchAgents/org.pqrs.karabiner.agent.karabiner_grabber.plist";
+3 -1
View File
@@ -33,7 +33,7 @@ in
services.khd.i3Keybindings = mkOption {
type = types.bool;
default = false;
description = "Wether to configure i3 style keybindings for kwm.";
description = "Whether to configure i3 style keybindings for kwm.";
};
};
@@ -57,6 +57,8 @@ in
SockType = "dgram";
SockFamily = "IPv4";
};
managedBy = "services.khd.enable";
};
};
+1
View File
@@ -47,6 +47,7 @@ in
SockType = "dgram";
SockFamily = "IPv4";
};
managedBy = "services.kwm.enable";
};
};
+11 -1
View File
@@ -29,7 +29,16 @@ in
};
config = mkIf cfg.enable {
# TODO: Upstream this to NixOS.
assertions = [
{
assertion = config.nix.enable;
message = ''`services.lorri.enable` requires `nix.enable`'';
}
];
environment.systemPackages = [ pkgs.lorri ];
launchd.user.agents.lorri = {
command = with pkgs; "${lorri}/bin/lorri daemon";
path = with pkgs; [ config.nix.package git gnutar gzip ];
@@ -41,6 +50,7 @@ in
StandardErrorPath = cfg.logFile;
EnvironmentVariables = { NIX_PATH = "nixpkgs=" + toString pkgs.path; };
};
managedBy = "services.lorri.enable";
};
};
}
}
+1
View File
@@ -56,6 +56,7 @@ in {
serviceConfig.StartInterval = cfg.startInterval;
serviceConfig.StandardErrorPath = "/var/log/offlineimap.log";
serviceConfig.StandardOutPath = "/var/log/offlineimap.log";
managedBy = "services.offlineimap.enable";
};
};
}
+7
View File
@@ -29,6 +29,12 @@ in {
default = "/var/log/netdata";
description = "Log directory for Netdata";
};
cacheDir = mkOption {
type = types.path;
default = "/var/cache/netdata";
description = "Cache directory for Netdata";
};
};
};
@@ -50,6 +56,7 @@ in {
system.activationScripts.preActivation.text = ''
mkdir -p ${cfg.workDir}
mkdir -p ${cfg.cacheDir}
'';
};
}
@@ -7,8 +7,8 @@
let
inherit (lib)
escapeShellArg
concatStringsSep
escapeShellArgs
getExe
mkEnableOption
mkIf
@@ -104,7 +104,8 @@ in {
]
++ (map (collector: "--collector.${collector}") cfg.enabledCollectors)
++ (map (collector: "--no-collector.${collector}") cfg.disabledCollectors)
) + escapeShellArgs cfg.extraFlags;
++ (map escapeShellArg cfg.extraFlags)
);
serviceConfig = let
logPath = config.users.users._prometheus-node-exporter.home
+ "/prometheus-node-exporter.log";
+3
View File
@@ -66,6 +66,9 @@ in {
KeepAlive = true;
RunAtLoad = true;
};
# https://github.com/influxdata/telegraf/issues/17607
environment.HOME = "/var/root";
};
};
}
+2
View File
@@ -41,6 +41,7 @@ in
serviceConfig.Program = "${cfg.package}/bin/mopidy";
serviceConfig.RunAtLoad = true;
serviceConfig.KeepAlive = true;
managedBy = "services.mopidy.enable";
};
})
(mkIf cfg.mediakeys.enable {
@@ -48,6 +49,7 @@ in
serviceConfig.Program = "${cfg.package}/bin/mpdkeys";
serviceConfig.RunAtLoad = true;
serviceConfig.KeepAlive = true;
managedBy = "services.mopidy.mediakeys.enable";
};
})
];
+1 -2
View File
@@ -30,8 +30,7 @@ in {
launchd.daemons.nextdns = {
path = [ nextdns ];
serviceConfig.ProgramArguments =
[ "${pkgs.nextdns}/bin/nextdns" "run" ] ++ cfg.arguments;
command = concatStringsSep " " (["${pkgs.nextdns}/bin/nextdns run"] ++ cfg.arguments);
serviceConfig.KeepAlive = true;
serviceConfig.RunAtLoad = true;
};
+9 -10
View File
@@ -3,17 +3,18 @@
let
cfg = config.services.nix-daemon;
inherit (lib) mkDefault mkIf mkMerge mkOption types;
inherit (lib) mkRemovedOptionModule mkDefault mkIf mkMerge mkOption types;
in
{
options = {
services.nix-daemon.enable = mkOption {
type = types.bool;
default = true;
description = "Whether to enable the nix-daemon service.";
};
imports = [
(mkRemovedOptionModule [ "services" "nix-daemon" "enable" ] ''
nix-darwin now manages nix-daemon unconditionally when
`nix.enable` is on.
'')
];
options = {
services.nix-daemon.enableSocketListener = mkOption {
type = types.bool;
default = false;
@@ -39,9 +40,7 @@ in
};
};
config = mkIf cfg.enable {
nix.useDaemon = true;
config = mkIf config.nix.enable {
launchd.daemons.nix-daemon = {
command = lib.getExe' config.nix.package "nix-daemon";
+9 -12
View File
@@ -14,6 +14,7 @@ in
(mkRemovedOptionModule [ "nix" "gc" "dates" ] "Use `nix.gc.interval` instead.")
(mkRemovedOptionModule [ "nix" "gc" "randomizedDelaySec" ] "No `nix-darwin` equivalent to this NixOS option.")
(mkRemovedOptionModule [ "nix" "gc" "persistent" ] "No `nix-darwin` equivalent to this NixOS option.")
(mkRemovedOptionModule [ "nix" "gc" "user" ] "The garbage collection service now always runs as `root`.")
];
###### interface
@@ -28,13 +29,6 @@ in
description = "Automatically run the garbage collector at a specific time.";
};
# Not in NixOS module
user = mkOption {
type = types.nullOr types.str;
default = null;
description = "User that runs the garbage collector.";
};
interval = mkOption {
type = launchdTypes.StartCalendarInterval;
default = [{ Weekday = 7; Hour = 3; Minute = 15; }];
@@ -62,15 +56,18 @@ in
###### implementation
config = mkIf cfg.automatic {
config = {
assertions = [
{
assertion = cfg.automatic -> config.nix.enable;
message = ''nix.gc.automatic requires nix.enable'';
}
];
launchd.daemons.nix-gc = {
launchd.daemons.nix-gc = mkIf cfg.automatic {
command = "${config.nix.package}/bin/nix-collect-garbage ${cfg.options}";
environment.NIX_REMOTE = optionalString config.nix.useDaemon "daemon";
serviceConfig.RunAtLoad = false;
serviceConfig.StartCalendarInterval = cfg.interval;
serviceConfig.UserName = cfg.user;
};
};
}
+9 -12
View File
@@ -20,6 +20,7 @@ in
{
imports = [
(mkRemovedOptionModule [ "nix" "optimise" "dates" ] "Use `nix.optimise.interval` instead.")
(mkRemovedOptionModule [ "nix" "optimise" "user" ] "The store optimisation service now always runs as `root`.")
];
###### interface
@@ -34,13 +35,6 @@ in
description = "Automatically run the nix store optimiser at a specific time.";
};
# Not in NixOS module
user = mkOption {
type = types.nullOr types.str;
default = null;
description = "User that runs the store optimisation.";
};
interval = mkOption {
type = launchdTypes.StartCalendarInterval;
default = [{ Weekday = 7; Hour = 4; Minute = 15; }];
@@ -58,17 +52,20 @@ in
###### implementation
config = mkIf cfg.automatic {
config = {
assertions = [
{
assertion = cfg.automatic -> config.nix.enable;
message = ''nix.optimise.automatic requires nix.enable'';
}
];
launchd.daemons.nix-optimise = {
environment.NIX_REMOTE = optionalString config.nix.useDaemon "daemon";
launchd.daemons.nix-optimise = mkIf cfg.automatic {
command = "${lib.getExe' config.nix.package "nix-store"} --optimise";
serviceConfig = {
RunAtLoad = false;
StartCalendarInterval = cfg.interval;
UserName = cfg.user;
};
};
};
}
+7
View File
@@ -46,6 +46,13 @@ in
};
config = mkIf cfg.enable {
assertions = [
{
assertion = config.nix.enable;
message = ''`services.ofborg.enable` requires `nix.enable`'';
}
];
warnings = mkIf (isDerivation cfg.configFile) [
"services.ofborg.configFile is a derivation, credentials will be world readable"
];
+108 -8
View File
@@ -1,18 +1,110 @@
{ config, lib, ... }:
{ config, lib, pkgs, ... }:
let
cfg = config.services.openssh;
hostKeyOpts = {
options = {
type = lib.mkOption {
type = lib.types.enum [ "dsa" "ecdsa" "ed25519" "rsa" ];
description = ''
Key type passed to `ssh-keygen -t`.
'';
};
path = lib.mkOption {
type = lib.types.str;
description = ''
Path to the private key file.
'';
};
bits = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = null;
description = ''
Key size in bits. If `null`, `ssh-keygen` uses the default
for the given key type (RSA=3072, ECDSA=256, ED25519=fixed).
'';
};
comment = lib.mkOption {
type = lib.types.str;
default = "";
description = ''
Comment for the key, passed to `ssh-keygen -C`.
Defaults to an empty string to match Apple's built-in host key
generation and avoid leaking the hostname.
'';
};
};
};
hostKeysConfig = lib.concatMapStringsSep "\n"
(k: "HostKey ${k.path}")
cfg.hostKeys;
keygenScript = lib.concatMapStrings (k:
let
escapedPath = lib.escapeShellArg k.path;
in ''
if ! [[ -s ${escapedPath} ]]; then
if ! [[ -L ${escapedPath} ]]; then
rm -f ${escapedPath}
fi
keygenArgs=(
-t ${lib.escapeShellArg k.type}
${lib.optionalString (k.bits != null) "-b ${toString k.bits}"}
-C ${lib.escapeShellArg k.comment}
-f ${escapedPath}
-N ""
)
mkdir -p "$(dirname ${escapedPath})"
chmod 0755 "$(dirname ${escapedPath})"
${lib.getExe' pkgs.openssh "ssh-keygen"} "''${keygenArgs[@]}"
fi
'') cfg.hostKeys;
in
{
options = {
services.openssh.enable = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Whether to enable Apple's built-in OpenSSH server.
services.openssh = {
enable = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Whether to enable Apple's built-in OpenSSH server.
The default is null which means let macOS manage the OpenSSH server.
'';
The default is null which means let macOS manage the OpenSSH server.
'';
};
extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
description = ''
Extra configuration text loaded in {file}`sshd_config`.
See {manpage}`sshd_config(5)` for help.
'';
};
hostKeys = lib.mkOption {
type = lib.types.listOf (lib.types.submodule hostKeyOpts);
default = [
{ type = "rsa"; path = "/etc/ssh/ssh_host_rsa_key"; }
{ type = "ecdsa"; path = "/etc/ssh/ssh_host_ecdsa_key"; }
{ type = "ed25519"; path = "/etc/ssh/ssh_host_ed25519_key"; }
];
description = ''
SSH host key declarations. Each entry specifies a key type and path.
`HostKey` directives are written to the sshd configuration for each
entry.
The default matches the keys that macOS automatically generates.
'';
};
};
};
@@ -29,5 +121,13 @@ in
launchctl disable system/com.openssh.sshd
fi
'');
environment.etc."ssh/sshd_config.d/099-host-keys.conf" = lib.mkIf (cfg.hostKeys != []) {
text = hostKeysConfig;
};
environment.etc."ssh/sshd_config.d/100-nix-darwin.conf".text = cfg.extraConfig;
system.activationScripts.openssh.text = lib.mkIf (cfg.hostKeys != []) keygenScript;
};
}
+1
View File
@@ -363,6 +363,7 @@ in
serviceConfig.EnvironmentVariables = {
PGDATA = cfg.dataDir;
};
managedBy = "services.postgresql.enable";
};
};
+1
View File
@@ -61,6 +61,7 @@ in
${cfg.package}/bin/privoxy /etc/privoxy-config
'';
serviceConfig.KeepAlive = true;
managedBy = "services.privoxy.enable";
};
};
}
+1
View File
@@ -67,6 +67,7 @@ in
launchd.user.agents.redis = {
command = "${cfg.package}/bin/redis-server /etc/redis.conf";
serviceConfig.KeepAlive = true;
managedBy = "services.redis.enable";
};
environment.etc."redis.conf".text = ''
+1
View File
@@ -54,6 +54,7 @@ in
++ optionals (cfg.config != "") [ "--config" "${configFile}" ];
serviceConfig.KeepAlive = true;
serviceConfig.RunAtLoad = true;
managedBy = "services.sketchybar.enable";
};
};
}
+2
View File
@@ -40,6 +40,8 @@ in
++ optionals (cfg.skhdConfig != "") [ "-c" "/etc/skhdrc" ];
serviceConfig.KeepAlive = true;
serviceConfig.ProcessType = "Interactive";
managedBy = "services.skhd.enable";
};
};
+4 -1
View File
@@ -22,11 +22,12 @@ in
services.spacebar.enable = mkOption {
type = bool;
default = false;
description = "Whether to enable the spacebar spacebar.";
description = "Whether to enable the spacebar.";
};
services.spacebar.package = mkOption {
type = path;
default = pkgs.spacebar;
description = "The spacebar package to use.";
};
@@ -69,6 +70,8 @@ in
serviceConfig.EnvironmentVariables = {
PATH = "${cfg.package}/bin:${config.environment.systemPath}";
};
managedBy = "services.spacebar.enable";
};
};
}
+1
View File
@@ -58,6 +58,7 @@ in
RunAtLoad = true;
ThrottleInterval = 30;
};
managedBy = "services.spotifyd.enable";
};
};
}
+1
View File
@@ -66,6 +66,7 @@ in
command = "${cfg.package}/bin/synapse --config ${configFile}";
serviceConfig.KeepAlive = true;
serviceConfig.RunAtLoad = true;
managedBy = "services.synapse-bt.enable";
};
};
+2
View File
@@ -130,6 +130,7 @@ in
serviceConfig.KeepAlive = true;
serviceConfig.RunAtLoad = cfg.client.autoStart;
serviceConfig.ProcessType = "Interactive";
managedBy = "services.synergy.client.enable";
};
})
@@ -145,6 +146,7 @@ in
serviceConfig.KeepAlive = true;
serviceConfig.RunAtLoad = cfg.server.autoStart;
serviceConfig.ProcessType = "Interactive";
managedBy = "services.synergy.server.enable";
};
})
];
+1
View File
@@ -42,6 +42,7 @@ in {
KeepAlive = true;
RunAtLoad = true;
};
managedBy = "services.trezord.enable";
};
};
}
+1 -1
View File
@@ -83,7 +83,7 @@ let
preDown = mkOption {
type = with types; coercedTo (listOf str) (concatStringsSep "\n") lines;
default = "";
description = "List of commadns to run before interface shutdown.";
description = "List of commands to run before interface shutdown.";
};
preUp = mkOption {

Some files were not shown because too many files have changed in this diff Show More