Skip to content

Commit a35fddb

Browse files
committed
fix: prefer Darwin on arm64
1 parent 22ec9f1 commit a35fddb

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

Makefile

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
NIX_FILES := $(shell find . -name '*.nix')
44
UNAME := $(shell uname)
5+
ARCH := $(shell uname -m)
56
WSL_DISTRO := $(strip $(WSL_DISTRO_NAME))
67

78
fmt:
@@ -14,17 +15,31 @@ update:
1415

1516
dry-run:
1617
ifeq ($(UNAME), Darwin)
17-
# Darwin
18+
ifeq ($(ARCH), arm64)
19+
# Darwin (arm64)
1820
home-manager build --dry-run --flake '.#henry@darwin'
21+
else ifeq ($(ARCH), x86_64)
22+
# Darwin (x86_64)
23+
home-manager build --dry-run --flake '.#henry@darwin-legacy'
24+
else
25+
$(error Unsupported architecture)
26+
endif
1927
else
2028
# WSL & VM
2129
home-manager build --dry-run --flake '.#nixos@all'
2230
endif
2331

2432
switch:
2533
ifeq ($(UNAME), Darwin)
26-
# Darwin
34+
ifeq ($(ARCH), arm64)
35+
# Darwin (arm64)
2736
home-manager switch --flake '.#henry@darwin'
37+
else ifeq ($(ARCH), x86_64)
38+
# Darwin (x86_64)
39+
home-manager switch --flake '.#henry@darwin-legacy'
40+
else
41+
$(error Unsupported architecture)
42+
endif
2843
else
2944
# WSL & VM
3045
home-manager switch --flake '.#nixos@all'
@@ -36,7 +51,7 @@ os/dry-run:
3651
ifdef WSL_DISTRO
3752
sudo nixos-rebuild dry-build --flake ".#wsl" --impure
3853
else ifeq ($(UNAME), Darwin)
39-
$(info Darwin is not supported)
54+
$(error Darwin is not supported)
4055
else ifeq ($(UNAME), Linux)
4156
sudo nixos-rebuild dry-build --flake ".#vm" --impure
4257
endif
@@ -45,7 +60,7 @@ os/switch:
4560
ifdef WSL_DISTRO
4661
sudo nixos-rebuild switch --flake ".#wsl" --impure
4762
else ifeq ($(UNAME), Darwin)
48-
$(info Darwin is not supported)
63+
$(error Darwin is not supported)
4964
else ifeq ($(UNAME), Linux)
5065
sudo nixos-rebuild switch --flake ".#vm" --impure
5166
endif

flake.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,16 @@
5151
extraSpecialArgs = { inherit inputs outputs; };
5252
modules = [ ./home-manager/linux ];
5353
};
54-
"henry@darwin" = home-manager.lib.homeManagerConfiguration {
54+
"henry@darwin-legacy" = home-manager.lib.homeManagerConfiguration {
5555
pkgs = nixpkgs.legacyPackages.x86_64-darwin; # Home-manager requires 'pkgs' instance
5656
extraSpecialArgs = { inherit inputs outputs; };
5757
modules = [ ./home-manager/darwin ];
5858
};
59+
"henry@darwin" = home-manager.lib.homeManagerConfiguration {
60+
pkgs = nixpkgs.legacyPackages.aarch64-darwin; # Home-manager requires 'pkgs' instance
61+
extraSpecialArgs = { inherit inputs outputs; };
62+
modules = [ ./home-manager/darwin ];
63+
};
5964
};
6065
};
6166
}

0 commit comments

Comments
 (0)