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 []);
}