Commit graph

1412 commits

Author SHA1 Message Date
Ethan Turkeltaub
b07a4c8be5
Fix ShellCheck issue in nixPath check 2025-06-03 16:19:03 -04:00
Michael Hoang
cd6a8a796d config/system-path: restructure to mirror NixOS
2795c506fe/nixos/modules/config/system-path.nix
2025-05-25 14:06:56 +10:00
Michael Hoang
5374405a01 config/terminfo: init module 2025-05-25 09:24:12 +10:00
Michael Hoang
7347f72507 programs/arqbackup: init module 2025-05-24 15:16:24 +10: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
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
Siddhartha Sahu
24952f03f9
Update default.nix 2025-05-17 12:15:49 -04:00
Siddhartha Sahu
a4cc54778d
Update repo link 2025-05-17 12:14:14 -04: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
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 Hoang
14737a9676 defaults: add com.apple.iCal for managing Calendar.app 2025-05-16 12:52:49 +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 Hoang
f2753a4ca6 _1password{,-gui}: fix package not being used 2025-05-15 17:01:26 +10:00
Michael Hoang
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
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 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 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 Hoang
751a96bc1f networking: backport domain, fqdn and fqdnOrHostName options
f675531bc7/nixos/modules/tasks/network-interfaces.nix (L580-L618)
2025-04-12 19:11:10 +02:00
Michael Hoang
113883e37d
Merge pull request #1388 from ivankovnatsky/master
services/netdata: add cacheDir option
2025-04-09 20:44:32 +02:00
Michael Hoang
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‮
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‮
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
Emily
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
Emily
ce5a3b9db9 treewide: point to the new GitHub organization 2025-03-27 17:07:57 +00:00
‮rekcäH nitraM‮
fe728cfb5a autossh: Fix incorrect reference to systemd
Darwin has LaunchD.
2025-03-23 08:39:49 +01:00
Emily
e9f41de2a8
Merge pull request #1375 from dwt/fix-docs-2
Docs: Fix references to NixOS
2025-03-21 22:10:55 +00:00
Michael Hoang
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 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 Hoang
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 Hoang
4d8a451649
Merge pull request #1355 from toodeluna/fix/profile-name
fix: use correct username for profile
2025-03-14 07:46:59 +09:00
Niklas Ravnsborg
feecfd97cd
update nextdns to use command instead of serviceConfig.ProgramArguments 2025-03-12 15:52:45 +01: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
Yifei Sun
d06cf700ee
homebrew: remove --no-lock flag
https://github.com/Homebrew/homebrew-bundle/pull/1630
2025-03-04 12:09:11 -05:00