Unstable and stable inputs on flake.nix

Recently I couldn’t to build my unstable system because I have qutebrowse and ollama, I don’t know why, the unstable version of these packages does not build anymore. I read some posts to mix unstable and stable and home-manager, but I could not see the flake version for that mix.

The main motivation for this post was some people complain about It is not possible anymore to build the Plasma 6.1 (unstable) with packages like ollama (just the stable could be built).

If we have a better nix way to do this, please, help me.

The flake.nix file

{
    inputs = {
        nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
        nix-stable.url = "github:nixos/nixpkgs/nixos-24.05";
        home-manager = {
            url = "github:nix-community/home-manager";
            inputs.nixpkgs.follows = "nixpkgs";
        };
    };
    outputs = inputs@{ nixpkgs, nix-stable, home-manager, ... }:
    let
        system = "x86_64-linux";
        pkgs = import nixpkgs {
            inherit system;
	        config.allowUnfree = true;
	    };
        stable = import nix-stable {
            inherit system;
            config.allowUnfree = true;
        };
    in
    {
        nixosConfigurations = {
            myhost = nixpkgs.lib.nixosSystem {
                system = "x86_64-linux";
                modules = [
                    ./configuration.nix
                    {
                        _module.args = { inherit stable; };
                    }
                    home-manager.nixosModules.home-manager
                    {
                        home-manager.useGlobalPkgs = true;
                        home-manager.useUserPackages = true;
                        home-manager.extraSpecialArgs = { inherit stable; };
                        home-manager.users.myuser = import ./home.nix;
                    }
                ];
            };
        };
    };
}

And on the home.nix or configuration.nix files

{ pkgs, stable, lib, ... }:
{
    # Standard configuration ...
    # Example, use stable package for qutebrowser
    programs.qutebrowser = {
        enable = true;
        package = stable.qutebrowser;
    };
    # environment.systenPackages = with stable; [ # on configuration.nix
    home.packages = with stable; [ # on home.nix
        # firefox from stable
        firefox
        # firefox from unstable
        pkgs.firefox
    ];
}

Does this work or not?

Nicer UX is to add an overlay in your main nixpkgs

Call it stable and do pkgs.stable.X

ollama not building could be related to [Framework16]Can't install ollama unstable on 24.05 - #3 by Aleksanaa which is fixed

For qutebrowser, what errors do you get when you try to build?

I wrote the post after build my system by that way, it works, but maybe a overlay is better, like the @fzakaria’s answer

After to try nixos-rebuild with qutebrowser package from usntable, the erro masssage was

error: builder for '/nix/store/1w0f9sx43mwjzi25v0f29vjlcqw7k04k-source.drv' failed with exit code 1;
       last 23 log lines:
       > sourcing setup hook '/nix/store/dv5vgsw8naxnkcc88x78vprbnn1pp44y-patchelf-0.15.0/nix-support/setup-hook'
       > sourcing setup hook '/nix/store/i4iynx9axbq23sd0gyrc5wdb46zz6z8l-update-autotools-gnu-config-scripts-hook/nix-support/setup-hook'
       > sourcing setup hook '/nix/store/h9lc1dpi14z7is86ffhl3ld569138595-audit-tmpdir.sh'
       > sourcing setup hook '/nix/store/m54bmrhj6fqz8nds5zcj97w9s9bckc9v-compress-man-pages.sh'
       > sourcing setup hook '/nix/store/wgrbkkaldkrlrni33ccvm3b6vbxzb656-make-symlinks-relative.sh'
       > sourcing setup hook '/nix/store/5yzw0vhkyszf2d179m0qfkgxmp5wjjx4-move-docs.sh'
       > sourcing setup hook '/nix/store/fyaryjvghbkpfnsyw97hb3lyb37s1pd6-move-lib64.sh'
       > sourcing setup hook '/nix/store/kd4xwxjpjxi71jkm6ka0np72if9rm3y0-move-sbin.sh'
       > sourcing setup hook '/nix/store/pag6l61paj1dc9sv15l7bm5c17xn5kyk-move-systemd-user-units.sh'
       > sourcing setup hook '/nix/store/jivxp510zxakaaic7qkrb7v1dd2rdbw9-multiple-outputs.sh'
       > sourcing setup hook '/nix/store/ilaf1w22bxi6jsi45alhmvvdgy4ly3zs-patch-shebangs.sh'
       > sourcing setup hook '/nix/store/cickvswrvann041nqxb0rxilc46svw1n-prune-libtool-files.sh'
       > sourcing setup hook '/nix/store/xyff06pkhki3qy1ls77w10s0v79c9il0-reproducible-builds.sh'
       > sourcing setup hook '/nix/store/aazf105snicrlvyzzbdj85sx4179rpfp-set-source-date-epoch-to-latest.sh'
       > sourcing setup hook '/nix/store/gps9qrh99j7g02840wv5x78ykmz30byp-strip.sh'
       >
       > trying https://github.com/libkeepass/pykeepass/archive/refs/tags/v4.1.0-post1.tar.gz
       >   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
       >                                  Dload  Upload   Total   Spent    Left  Speed
       >   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
       >   0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
       > curl: (22) The requested URL returned error: 404
       > error: cannot download source from any mirror
       For full logs, run 'nix log /nix/store/1w0f9sx43mwjzi25v0f29vjlcqw7k04k-source.drv'.
error: 1 dependencies of derivation '/nix/store/jscd98zw883yy47rkamf0y3rgqwkzfk7-python3.12-pykeepass-4.1.0-post1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/yf02gf9hbasv8dabdhx6a2lb2fpg1jdq-qutebrowser-3.2.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/kq4nx63gsf11vfb148cly7gwjpm8virr-home-manager-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/1gqva3zzl9ycsjmffd7w91z1407wvk99-man-paths.drv' failed to build
error: 1 dependencies of derivation '/nix/store/f3vz672q81wfghqslkdcl7cmaniqynhy-qutebrowser-3.2.1-fish-completions.drv' failed to build
error: 1 dependencies of derivation '/nix/store/gz8s95qlvp3fv07kr43qg18dpi4mgy9q-home-manager-generation.drv' failed to build
error: 1 dependencies of derivation '/nix/store/i3033mrrz1mrmbh8b7aja52152cpjkhi-user-environment.drv' failed to build
error: 1 dependencies of derivation '/nix/store/k28myb071hfzkvy9g6mj8yxw4n334qqr-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/1ljazdy4ms309smr49zibmgvqg7zd5n7-nixos-system-nixos-24.11.20240731.9f918d6.drv' failed to build

I try to do this via

# ... previous flake inputs lines

  outputs = inputs@{ nixpkgs, nix-stable, home-manager, ... }:
  let
  	system = "x86_64-linux";
	pkgs = import nixpkgs {
	    inherit system;
	    config.allowUnfree = true;
        overlays = [
            (final: prev: {
                stable = import nix-stable {
                    system = prev.system;
                };
            })
        ];
     };

# another flake lines...

but I got stable missing error when call pkgs.stable.X on home.nix or on configuration.nix, I find just some help to use unstable and stable inputs, no tutorial like to use overlays on nixpkgs for stable or unstable. Some help?

This was apparently caused by a wrong pykeepass version, which was fixed in PR #331310.

Considering the qutebrowser version in stable and unstable is the same (3.2.1), I guess it wouldn’t be a problem to use the stable one until the fix reaches nixos-unstable.

Alternatively, you can patch this in an overlay.

Sometimes I delete the stable lines to try to rebuild the totaly unstable system again. But I am not familiar with overlays, I think they do not propagate from flake.nix to configuration.nix or home.nix files, we always need to give specialArgs or extraSpecialArgs. Am I correct?

That looks correct hmm

  # be accessible through 'pkgs.unstable'
  unstable-packages = final: _prev: {
    unstable = import inputs.nixpkgs-unstable {
      system = final.system;
      config.allowUnfree = true;
    };
  };

You can see my config here: GitHub - fzakaria/nix-home at framework-laptop
(framework-laptop branch is my main branch)

Oh I see what you mean now, you can just do overlays in you configuraiton.nix like this:

# configuration.nix
  nixpkgs.overlays = [
    (final: prev: rec {
      python3 = prev.python3.override {
        packageOverrides = python-final: python-prev: {
          pykeepass = python-prev.pykeepass.overrideAttrs (
            finalAttrs: _: {
              version = "4.1.0.post1";
              src = prev.fetchFromGitHub {
                owner = "libkeepass";
                repo = "pykeepass";
                rev = "refs/tags/v${finalAttrs.version}";
                hash = "sha256-64is/XoRF/kojqd4jQIAQi1od8TRhiv9uR+WNIGvP2A=";
              };
            }
          );
        };
      };
      python3Packages = python3.pkgs;
    })
  ];

Exactly, I could see the @fzakaria configuration file, and he gives inputs as specialArgs, and the ovelays will be accessible throug pkgs.unstable, or pkgs.stable in my case. Maybe the stable + unstable approuch without overlays is the way to use less lines of configuration.