Skip to content

Commit aef4011

Browse files
authored
Merge branch 'nix-darwin:master' into master
2 parents f94e4cb + e04a388 commit aef4011

File tree

9 files changed

+172
-146
lines changed

9 files changed

+172
-146
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ cd /etc/nix-darwin
5050

5151
# To use Nixpkgs unstable:
5252
nix flake init -t nix-darwin/master
53-
# To use Nixpkgs 24.11:
54-
nix flake init -t nix-darwin/nix-darwin-24.11
53+
# To use Nixpkgs 25.05:
54+
nix flake init -t nix-darwin/nix-darwin-25.05
5555

5656
sed -i '' "s/simple/$(scutil --get LocalHostName)/" flake.nix
5757
```
5858

59-
Make sure to change `nixpkgs.hostPlatform` to `aarch64-darwin` if you are using Apple Silicon.
59+
Make sure to check if `nixpkgs.hostPlatform` is set to either `x86_64-darwin` for Intel or `aarch64-darwin` for Apple Silicon.
6060

6161
</details>
6262

@@ -71,9 +71,9 @@ Add the following to `flake.nix` in the same folder as `configuration.nix`:
7171
description = "John's darwin system";
7272
7373
inputs = {
74-
# Use `github:NixOS/nixpkgs/nixpkgs-24.11-darwin` to use Nixpkgs 24.11.
74+
# Use `github:NixOS/nixpkgs/nixpkgs-25.05-darwin` to use Nixpkgs 25.05.
7575
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
76-
# Use `github:nix-darwin/nix-darwin/nix-darwin-24.11` to use Nixpkgs 24.11.
76+
# Use `github:nix-darwin/nix-darwin/nix-darwin-25.05` to use Nixpkgs 25.05.
7777
nix-darwin.url = "github:nix-darwin/nix-darwin/master";
7878
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
7979
};
@@ -99,8 +99,8 @@ Unlike NixOS, `nix-darwin` does not have an installer, you can just run `darwin-
9999
```bash
100100
# To use Nixpkgs unstable:
101101
sudo nix run nix-darwin/master#darwin-rebuild -- switch
102-
# To use Nixpkgs 24.11:
103-
sudo nix run nix-darwin/nix-darwin-24.11#darwin-rebuild -- switch
102+
# To use Nixpkgs 25.05:
103+
sudo nix run nix-darwin/nix-darwin-25.05#darwin-rebuild -- switch
104104
```
105105

106106
### Step 3. Using `nix-darwin`
@@ -143,8 +143,8 @@ Copy the [simple](./modules/examples/simple.nix) example to `/etc/nix-darwin/con
143143
```bash
144144
# If you use Nixpkgs unstable (the default):
145145
sudo nix-channel --add https://github.com/nix-darwin/nix-darwin/archive/master.tar.gz darwin
146-
# If you use Nixpkgs 24.11:
147-
sudo nix-channel --add https://github.com/nix-darwin/nix-darwin/archive/nix-darwin-24.11.tar.gz darwin
146+
# If you use Nixpkgs 25.05:
147+
sudo nix-channel --add https://github.com/nix-darwin/nix-darwin/archive/nix-darwin-25.05.tar.gz darwin
148148

149149
sudo nix-channel --update
150150
```

modules/homebrew.nix

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ let
5454
# Submodules -------------------------------------------------------------------------------------
5555
# Option values and descriptions of Brewfile entries are sourced/derived from:
5656
# * `brew` manpage: https://docs.brew.sh/Manpage
57-
# * `brew bundle` source files (at https://github.com/Homebrew/homebrew-bundle/tree/9fffe077f1a5a722ed5bd26a87ed622e8cb64e0c):
58-
# * lib/bundle/dsl.rb
59-
# * lib/bundle/{brew,cask,tap}_installer.rb
60-
# * spec/bundle/{brew,cask,tap}_installer_spec.rb
57+
# * `brew bundle` source files (at https://github.com/Homebrew/brew/tree/master/Library/Homebrew/bundle):
58+
# * dsl.rb
59+
# * {brew,cask,tap}_installer.rb
60+
# * ../test/bundle/{brew,cask,tap}_installer_spec.rb
6161

6262
onActivationOptions = { config, ... }: {
6363
options = {
@@ -234,7 +234,7 @@ let
234234
options = {
235235
name = mkOption {
236236
type = types.str;
237-
example = "homebrew/cask-fonts";
237+
example = "apple/apple";
238238
description = ''
239239
When {option}`clone_target` is unspecified, this is the name of a formula
240240
repository to tap from GitHub using HTTPS. For example, `"user/repo"`
@@ -502,7 +502,9 @@ let
502502
[](#opt-homebrew.caskArgs) for the available options.
503503
'';
504504
};
505-
greedy = mkNullOrBoolOption {
505+
greedy = mkOption {
506+
type = types.nullOr types.bool;
507+
default = cfg.greedyCasks;
506508
description = ''
507509
Whether to always upgrade this cask regardless of whether it's unversioned or it updates
508510
itself.
@@ -605,10 +607,10 @@ in
605607
type = with types; listOf (coercedTo str (name: { inherit name; }) (submodule tapOptions));
606608
default = [ ];
607609
example = literalExpression ''
608-
# Adapted examples from https://github.com/Homebrew/homebrew-bundle#usage
610+
# Adapted from https://docs.brew.sh/Brew-Bundle-and-Brewfile
609611
[
610612
# `brew tap`
611-
"homebrew/cask"
613+
"apple/apple"
612614
613615
# `brew tap` with custom Git URL and arguments
614616
{
@@ -642,11 +644,18 @@ in
642644
'';
643645
};
644646

647+
greedyCasks = mkNullOrBoolOption {
648+
description = ''
649+
Whether to always upgrade casks listed in [](#opt-homebrew.casks) regardless
650+
of whether it's unversioned or it updates itself.
651+
'';
652+
};
653+
645654
brews = mkOption {
646655
type = with types; listOf (coercedTo str (name: { inherit name; }) (submodule brewOptions));
647656
default = [ ];
648657
example = literalExpression ''
649-
# Adapted examples from https://github.com/Homebrew/homebrew-bundle#usage
658+
# Adapted from https://docs.brew.sh/Brew-Bundle-and-Brewfile
650659
[
651660
# `brew install`
652661
"imagemagick"
@@ -680,7 +689,7 @@ in
680689
type = with types; listOf (coercedTo str (name: { inherit name; }) (submodule caskOptions));
681690
default = [ ];
682691
example = literalExpression ''
683-
# Adapted examples from https://github.com/Homebrew/homebrew-bundle#usage
692+
# Adapted from https://docs.brew.sh/Brew-Bundle-and-Brewfile
684693
[
685694
# `brew install --cask`
686695
"google-chrome"
@@ -802,8 +811,10 @@ in
802811
if [ -f "${cfg.brewPrefix}/brew" ]; then
803812
PATH="${cfg.brewPrefix}:${lib.makeBinPath [ pkgs.mas ]}:$PATH" \
804813
sudo \
814+
--preserve-env=PATH \
805815
--user=${escapeShellArg cfg.user} \
806816
--set-home \
817+
env \
807818
${cfg.onActivation.brewBundleCmd}
808819
else
809820
echo -e "\e[1;31merror: Homebrew is not installed, skipping...\e[0m" >&2

modules/module-list.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
./system/version.nix
5050
./time
5151
./networking
52+
./networking/applicationFirewall.nix
5253
./nix
5354
./nix/linux-builder.nix
5455
./nix/nix-darwin.nix
@@ -113,7 +114,7 @@
113114
./programs/man.nix
114115
./programs/info
115116
./programs/nix-index
116-
./programs/ssh
117+
./programs/ssh.nix
117118
./programs/tmux.nix
118119
./programs/vim.nix
119120
./programs/zsh
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{ config, lib, ... }:
2+
let
3+
cfg = config.networking.applicationFirewall;
4+
5+
socketfilterfw =
6+
option: value:
7+
lib.concatStringsSep " " [
8+
"/usr/libexec/ApplicationFirewall/socketfilterfw"
9+
"--${option}"
10+
(if value then "on" else "off")
11+
];
12+
in
13+
{
14+
meta.maintainers = [
15+
(lib.maintainers.prince213 or "prince213")
16+
];
17+
18+
options.networking.applicationFirewall = {
19+
enable = lib.mkOption {
20+
type = lib.types.nullOr lib.types.bool;
21+
default = null;
22+
example = true;
23+
description = "Whether to enable application firewall.";
24+
};
25+
blockAllIncoming = lib.mkEnableOption "blocking all incoming connections";
26+
allowSigned = lib.mkEnableOption "built-in software to receive incoming connections" // {
27+
default = true;
28+
};
29+
allowSignedApp =
30+
lib.mkEnableOption "downloaded signed software to receive incoming connections"
31+
// {
32+
default = true;
33+
};
34+
enableStealthMode = lib.mkEnableOption "stealth mode";
35+
};
36+
37+
config = {
38+
system.activationScripts.networking.text = ''
39+
echo "configuring application firewall..." >&2
40+
41+
${lib.optionalString (cfg.enable != null) (socketfilterfw "setglobalstate" cfg.enable)}
42+
${lib.optionalString (cfg.enable == true) (socketfilterfw "setblockall" cfg.blockAllIncoming)}
43+
${socketfilterfw "setallowsigned" cfg.allowSigned}
44+
${socketfilterfw "setallowsignedapp" cfg.allowSignedApp}
45+
${socketfilterfw "setstealthmode" cfg.enableStealthMode}
46+
'';
47+
};
48+
}

modules/nix/default.nix

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,14 @@ in
443443
nixPath = mkOption {
444444
type = nixPathType;
445445
inherit (managedDefault "nix.nixPath" (
446-
lib.optionals cfg.channel.enable [
447-
# Include default path <darwin-config>.
448-
{ darwin-config = "${config.environment.darwinConfig}"; }
449-
"/nix/var/nix/profiles/per-user/root/channels"
450-
]
446+
lib.optionals cfg.channel.enable (
447+
lib.optionals (config.environment.darwinConfig != null) [
448+
# Include default path <darwin-config>.
449+
{ darwin-config = "${config.environment.darwinConfig}"; }
450+
] ++ [
451+
"/nix/var/nix/profiles/per-user/root/channels"
452+
]
453+
)
451454
)) default;
452455

453456
defaultText = lib.literalExpression ''

0 commit comments

Comments
 (0)