Skip to content

Commit

Permalink
fix: prefer Darwin on arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
henry40408 committed Jun 13, 2024
1 parent 22ec9f1 commit a35fddb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
23 changes: 19 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

NIX_FILES := $(shell find . -name '*.nix')
UNAME := $(shell uname)
ARCH := $(shell uname -m)
WSL_DISTRO := $(strip $(WSL_DISTRO_NAME))

fmt:
Expand All @@ -14,17 +15,31 @@ update:

dry-run:
ifeq ($(UNAME), Darwin)
# Darwin
ifeq ($(ARCH), arm64)
# Darwin (arm64)
home-manager build --dry-run --flake '.#henry@darwin'
else ifeq ($(ARCH), x86_64)
# Darwin (x86_64)
home-manager build --dry-run --flake '.#henry@darwin-legacy'
else
$(error Unsupported architecture)
endif
else
# WSL & VM
home-manager build --dry-run --flake '.#nixos@all'
endif

switch:
ifeq ($(UNAME), Darwin)
# Darwin
ifeq ($(ARCH), arm64)
# Darwin (arm64)
home-manager switch --flake '.#henry@darwin'
else ifeq ($(ARCH), x86_64)
# Darwin (x86_64)
home-manager switch --flake '.#henry@darwin-legacy'
else
$(error Unsupported architecture)
endif
else
# WSL & VM
home-manager switch --flake '.#nixos@all'
Expand All @@ -36,7 +51,7 @@ os/dry-run:
ifdef WSL_DISTRO
sudo nixos-rebuild dry-build --flake ".#wsl" --impure
else ifeq ($(UNAME), Darwin)
$(info Darwin is not supported)
$(error Darwin is not supported)
else ifeq ($(UNAME), Linux)
sudo nixos-rebuild dry-build --flake ".#vm" --impure
endif
Expand All @@ -45,7 +60,7 @@ os/switch:
ifdef WSL_DISTRO
sudo nixos-rebuild switch --flake ".#wsl" --impure
else ifeq ($(UNAME), Darwin)
$(info Darwin is not supported)
$(error Darwin is not supported)
else ifeq ($(UNAME), Linux)
sudo nixos-rebuild switch --flake ".#vm" --impure
endif
7 changes: 6 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,16 @@
extraSpecialArgs = { inherit inputs outputs; };
modules = [ ./home-manager/linux ];
};
"henry@darwin" = home-manager.lib.homeManagerConfiguration {
"henry@darwin-legacy" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-darwin; # Home-manager requires 'pkgs' instance
extraSpecialArgs = { inherit inputs outputs; };
modules = [ ./home-manager/darwin ];
};
"henry@darwin" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.aarch64-darwin; # Home-manager requires 'pkgs' instance
extraSpecialArgs = { inherit inputs outputs; };
modules = [ ./home-manager/darwin ];
};
};
};
}

0 comments on commit a35fddb

Please # to comment.