I’m a returning newbie to Nix, trying to set up home-manager on two Macs as a brew replacement.
Since I’m starting from scratch this time, I’m using flakes with Nix 2.8.1 (macOS 12.3.1).
I’m getting things working on my personal Intel Mac mini at the moment and have this working config for my flake.nix:
{
description = "My Home Manager flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { home-manager, ... }:
let
system = "x86_64-darwin";
username = "myusername";
in {
homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
# Specify the path to your home configuration here
configuration = import ./home.nix;
inherit system username;
homeDirectory = "/Users/${username}";
# Update the state version as needed.
# See the changelog here:
# https://nix-community.github.io/home-manager/release-notes.html#sec-release-21.05
stateVersion = "21.11";
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
};
};
}
This works well. However, I am going to be getting a M1 MacBook Pro for work soon, so I will need to support both x86_64-darwin and aarch64-darwin systems. Note that my username will be the same on both and I expect that the contents of home.nix will be the same on both too (if everything I need is available for aarch64). How do I set up (and call) two different home-manager configs where only the system value is different?
Also, if it possible to configure things in such a way that on the M1 Mac, Nix will try first to build for aarch64 then fall back to the x86_64 version (which I can run with Rosetta) if the program cannot be built for aarch64 yet?
Thanks in advance for any help!