# Mixing stable and unstable packages on flake-based NixOS system

**URL:** https://discourse.nixos.org/t/mixing-stable-and-unstable-packages-on-flake-based-nixos-system/50351
**Category:** Help
**Created:** [August 9, 2024, 4:26am UTC](https://discourse.nixos.org/t/mixing-stable-and-unstable-packages-on-flake-based-nixos-system/50351 "2024-08-09T04:26:02Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![waffle8946](https://discourse.nixos.org/user_avatar/discourse.nixos.org/waffle8946/32/27221_2.png) [@waffle8946](https://discourse.nixos.org/u/waffle8946)
#### Post date: [August 9, 2024, 12:16pm UTC](https://discourse.nixos.org/t/mixing-stable-and-unstable-packages-on-flake-based-nixos-system/50351/4 "2024-08-09T12:16:18Z")

</div>

_EDIT: Huge caveat - I strongly recommend not mixing stable with unstable on the same system. It’s unsupported and can lead to confusing errors when going to run programs, due to glibc and graphics driver mismatches._

**Never set `pkgs` directly in the NixOS module system,** as the other answers are indicating.

Here’s a couple of concepts you need to know:

1. If you want to access some inputs, or some other value across your config without creating an explicit option for it, use `specialArgs` or `_module.args`. (For things that you `import`, you must pass them in `specialArgs` specifically to avoid infrec.)
2. Changing `pkgs` requires an overlay; however, for this application, you may not necessarily need one if you are willing to get away from the `pkgs.unstable` syntax specifically.

Which means the following:

1. Add an entry to your `inputs`, and pass them to your config via `specialArgs`, in your `flake.nix`:

2. Since you need an unfree package specifically, allow the unfree package somewhere in your NixOS config:

3. Then, use that config when importing the unstable nixpkgs, and then use the appropriate module arg in your package list.  
a. EITHER create a new module arg:

I’m personally against 3b, because an overlay for this is completely unnecessary and will likely slow down eval.

PS this has got to be one of the most-asked questions, it’s silly that we are still having to rewrite the answers from scratch in 2024…

---

_[View the full topic](https://discourse.nixos.org/t/mixing-stable-and-unstable-packages-on-flake-based-nixos-system/50351)._
