diff --git a/Makefile b/Makefile index 2f154fd..de75a3d 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +HOSTNAME := $(shell hostname -s) all: if [[ "`uname`" == 'Darwin' ]]; then \ @@ -14,7 +15,7 @@ nixos: macos: sudo ls # cache sudo # The `TERM` needs to be set to workaround kitty issue: `tput: unknown terminal "xterm-kitty"` - TERM=xterm $$(nix build --extra-experimental-features "flakes nix-command" .#darwinConfigurations.air.system --no-link --json | jq -r '.[].outputs.out')/sw/bin/darwin-rebuild switch --flake . + TERM=xterm $$(nix build --extra-experimental-features "flakes nix-command" .#darwinConfigurations.$(HOSTNAME).system --no-link --json | nix --extra-experimental-features "flakes nix-command" run ${WITHEXP} nixpkgs#jq -- -r '.[].outputs.out')/sw/bin/darwin-rebuild switch --flake . freeupboot: # Delete all but the last few generations diff --git a/README.md b/README.md index f3142db..1c5f4ca 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,11 @@ make darwin # Or, just `make` - Hetzner dedicated from Linux Rescue system: https://github.com/serokell/nixos-install-scripts/pull/1#pullrequestreview-746593205 - Digital Ocean: https://github.com/elitak/nixos-infect - X1 Carbon: https://www.srid.ca/x1c7-install -- macOS: https://github.com/LnL7/nix-darwin +- macOS: + - Install Nix normally (multi-user) + - Install [nix-darwin](https://github.com/LnL7/nix-darwin) + - This will create a `~/.nixpkgs/darwin-configuration.nix`, but we do not need that. + - Edit `flake.nix` and add your Mac's [hostname](https://support.apple.com/en-ca/guide/mac-help/mchlp2322/mac) in the `darwinConfigurations` set. + - Run `make`.[^cleanup] That's it. Re-open your shell. + +[^cleanup]: You might have to `rm -rf /etc/nix/nix.conf`, so our flake.nix can do its thing. diff --git a/flake.nix b/flake.nix index b99af1c..3a571a2 100644 --- a/flake.nix +++ b/flake.nix @@ -122,44 +122,51 @@ }; # Configurations for macOS systems (using nix-darwin) - darwinConfigurations."air" = + darwinConfigurations = let system = "aarch64-darwin"; mkMacosSystem = darwin.lib.darwinSystem; - in - mkMacosSystem { - inherit system; - specialArgs = { - inherit inputs system; - rosettaPkgs = import nixpkgs { system = "x86_64-darwin"; }; + defaultMacosSystem = mkMacosSystem { + inherit system; + specialArgs = { + inherit inputs system; + rosettaPkgs = import nixpkgs { system = "x86_64-darwin"; }; + }; + modules = [ + overlayModule + ./hosts/darwin.nix + ./features/caches/oss.nix + home-manager.darwinModules.home-manager + { + home-manager.extraSpecialArgs = { inherit system inputs; }; + home-manager.users.srid = { pkgs, ... }: { + imports = [ + ./home/git.nix + ./home/tmux.nix + ./home/neovim.nix + ./home/email.nix + ./home/terminal.nix + ./home/direnv.nix + ./home/starship.nix + ]; + programs.zsh = { + enable = true; + initExtra = '' + export PATH=$HOME/.nix-profile/bin:/run/current-system/sw/bin/:$PATH + ''; + } // (import ./home/shellcommon.nix { inherit pkgs; }); + home.stateVersion = "21.11"; + }; + } + ]; }; - modules = [ - overlayModule - ./hosts/darwin.nix - ./features/caches/oss.nix - home-manager.darwinModules.home-manager - { - home-manager.extraSpecialArgs = { inherit system inputs; }; - home-manager.users.srid = { pkgs, ... }: { - imports = [ - ./home/git.nix - ./home/tmux.nix - ./home/neovim.nix - ./home/email.nix - ./home/terminal.nix - ./home/direnv.nix - ./home/starship.nix - ]; - programs.zsh = { - enable = true; - initExtra = '' - export PATH=$HOME/.nix-profile/bin:/run/current-system/sw/bin/:$PATH - ''; - } // (import ./home/shellcommon.nix { inherit pkgs; }); - home.stateVersion = "21.11"; - }; - } - ]; + in + { + # These are indexed, by convention, using hostnames. + # For example, if `sky.local` is the hostname of your Mac, then use + # `sky` here. + air = defaultMacosSystem; + sky = defaultMacosSystem; }; };