I have tried following this post, explaining how to pin nixpkgs versions: Nix Haskell Development (2020)
For generating the json file of the version to be pinned, I used the command:
nix-prefetch-git https://github.com/nixos/nixpkgs-channels.git refs/heads/nixos-19.09 > nix/nixos-19-09.json
Then I have made this default.nix file
let
hostNix = import <nixpkgs> {};
nixpkgsPin = hostNix.pkgs.lib.importJSON ./nix-pins/nixos-19-09.json;
pinnedPkgs = hostNix.pkgs.fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs-channels";
inherit (nixpkgsPin) rev sha256;
};
in
with import pinnedPkgs;
stdenv.mkDerivation rec {
name = "env";
env = buildEnv { name = name; paths = buildInputs; };
buildInputs = [
hello
python36Packages.pims
python36Packages.moviepy
python36Packages.imageio
python36Packages.imageio-ffmpeg
python36Packages.pygame
];
}
However, when I launch nix-shell
I get the error: “error: value is a function while a set was expected”
Any idea what’s wrong ? What/where should I start looking for ?
1 Like
Seems like you’re missing the {}
in import pinnedPkgs {}
Also: if you’re doing mostly python development it’s probably best to use
...
with import pinnedPkgs;
python36.pkgs.buildPythonPackage rec {
propagatedBuildInputs = with python36.pkgs; [
pims
moviepy
...
];
}
This one will automatically start the python setup.py develop
mode when your project is setuptools based.
There’s some more examples in the nixpkgs manual Nixpkgs 23.11 manual | Nix & NixOS
1 Like
Not the first time I made this same mistake… But this error message is not extraordinarily helpful 
I know this seems like a simple mistake that might not be helpful to others, but I strongly suspect that another person has run into this exact error and wished someone had posted online how to fix it. If you wouldn’t mind could we keep this here so others might find it when they look for that error message?
@Skyfold Maybe in this case I should rename the title of the topic ? Because the mistake I made, currently is not related to pinning to a nixpkgs version.
Maybe you could go with:
“error: value is a function while a set was expected” when importing package set
That way it has the error in the title and mentions importing a package set, which is usually when you would run into this issue.
1 Like