1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-06 16:57:08 +00:00
Commit graph

1336 commits

Author SHA1 Message Date
Emily
fc9367a9ec nix-gc: check for nix.enable
This was added to Nixpkgs in eb8b70c020e6693b29634660fa173d7f14f882eb.
2025-02-11 20:10:55 +00:00
Emily
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
Emily
a36049dac5
Merge pull request #1329 from emilazy/push-nlxwnqymuupk
homebrew: use `mas` from Nixpkgs
2025-02-10 23:20:29 +00:00
Emily
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
Emily
3f4351d233
Merge pull request #1327 from emilazy/push-vunnqlmqnzts
checks: fix macOS version check exit code
2025-02-08 14:32:00 +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
Emily
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
dc1c716ded nixpkgs: format with nixfmt 2025-02-03 20:44:32 +00:00
Emily
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
Emily
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
Emily
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
Emily
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
Emily
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
Emily
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
Emily
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
Emily
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
tarc
f1cf8c4f5a checks: fix sw_vers parameter for macOSVersion (--productVersion, not -productVersion) 2025-01-30 12:46:25 -03: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
Emily
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
Emily
5c12a6f4a1
Merge pull request #1303 from emilazy/push-ulxuwyrnkwpq
{activation-scripts,activate-system}: purify environment
2025-01-27 23:11:51 +00:00
Emily
2733527a58 {environment,readme}: default configuration path to /etc/nix-darwin 2025-01-27 23:10:14 +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
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
Emily
65cc1fa8e3
Merge pull request #1283 from emilazy/push-nynpmzrmmozu
checks: remove `runLink`
2025-01-22 00:01:16 +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
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
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
e1976612f0 system: tweak ShellCheck settings 2025-01-18 19:34:21 +00:00
Emily
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
Emily
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
Emily
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