Using the same `home.nix` file for Linux and macOS [Home-manager]

I’m using the same home.nix file for both Linux and macOS.
So far, I’m using mkIf isLinux for configurations exclusive to Linux, but I couldn’t find any way to configure the home.packages option yet, as I can’t seem to be able to duplicate it to have a Linux and mac version, since some packages are needed for both systems.

I’m attempting to achieve something like this: (this syntax is invalid)

home.packages = with pkgs; [
    (isLinux ? eyedropper)      # Color Picker (Linux only)
    (isLinux ? epiphany)        # Web Browser (Linux only)
    neovim
    gh

Is there a way to do this that actually works?
Thanks advanced!

Try:

home.packages = with pkgs; [
  gh
  neovim
]
++ lib.optionals pkgs.stdenv.isLinux [ eyedropper epiphany ]
++ lib.optional (!pkgs.stdenv.isLinux) some-mac-specific-app;
1 Like

Thank you so much, it works perfectly!