Custom parameter for home manager depending on flake host

I want to use nix on both with NixOS and without. I am currently using home-manager for packages, but some of them, I only want to add if I am using NixOS. How can I add a parameter for if the current setup is nixos-system or not? This is my current config: I am building it with sudo nixos-rebuild switch --flake .#. Sorry if this is super nooby:)

I have this as flake.nix:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };
  outputs = { self, nixpkgs, home-manager, ... }:
  let
    name = "herman";
  in {
    nixosConfigurations = {
      hostOne = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          ./hosts/hostOne/configuration.nix
          home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.users.${name} = import ./home-manager;
          }
        ];
      };
      hostTwo = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          ./hosts/hostTwo/configuration.nix
          home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.users.${name} = import ./home-manager;
          }
        ];
      };
      nonNixos = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.users.${name} = import ./home-manager;
          }
        ];
      };
    };
  };
}

And this as home-manager/default.nix

{ pkgs, ... }:
{
  home.stateVersion = "22.11";

  programs.home-manager.enable = true;

  home.packages = with pkgs; [
    neovim
  ] ++ (if nixos-system then [
    firefox
  ] else []);
}

Standalone HM (especially when using flakes) can not know whether it’s on nixos or not.

You have to tell it.

A system module HM could check for the existence of nixosConfig in the modules argument set.

Thank you for the fast reply! How would I do this? (sorry for being a noob)

How would you do what exactly?

How can I add a parameter to flake.nix, so that I can check for existance of nixosConfig module argument inside home-manager/default.nix

You don’t. The attribute will exist automatically when you use HM as a nixos module.

How can I check if it is set, and then do something like inside home-manager/default.nix:

  home.packages = with pkgs; [
    neovim
  ] ++ (if nixos-system then [
    firefox
  ] else []);
home.packages = lib.mkMerge [
  [ ... ]
  (lib.mkIf (args ? "nixosConfig") [ ... ])
];

And at the top change the { ... }: to args@{ ... }