How to use both unstable-nixpkgs and stable-nixpkgs in your flake.nix and configuration.nix

7 months ago by yboutros to c/nixos

I had an issue with building so I decided to move one package from the unstable repo to the 25.11 repo. My default channel is unstable so this guide adds the 25.11 repo into my flake and configuration. It can easily be substituted if you're running stable as the default pkgs and want some unstable-pkgs.

  1. add the url to your flake inputs
 inputs = {
    stable-nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
    ...
}
  1. update the arguments in the outputs function to include the new variable
outputs = { self, nixpkgs, stable-nixpkgs, ... }@inputs: {
...
}
  1. import the repo into your configuration.nix
{ config, pkgs, inputs, lib, ... }:  let
pkgs-stable = import inputs.stable-nixpkgs { system = "x86_64-linux"; config.allowUnfree = true; };
in
{
...
}
  1. Add the package you want from this repo
enrionment.systemPackages = [ 
  pkgs.vim 
  pkgs-stable.heroic 
]
quarterstar 2 points 7 months ago

You can combine this with Nixhub to find the precise commit of nixpkgs, if you need a copy of stable for a specific package! For example, I needed to get draw.io before it changed its license to a non-FOSS, so I pinned it to a specific commit hash.

The commit hash goes in the configuration like this (example): nixpkgs-lvm.url = "github:nixos/nixpkgs/2fbfb1d73d239d2402a8fe03963e37aab15abe8b";

path: 0 22972990, hotness: undefined, score: 2, children: 0
nixos
nixos

@infosec.pub

login for more options
1421
87
28

NixOS is a Linux distribution built on top of the Nix package manager. Its declarative configuration allows reliable system upgrades via several official channels of stability and size.

This community discusses NixOS, Nix, and everything related.

go to feed...