Overlay trouble (no flakes involved!)

I’m trying to revert my NixOS configuration back to the non-flakes version. Unfortunately, I’m having a problem trying to include some Haskell programs I wote.

My NixOS configuration includes the following:

  nixpkgs.overlays = [
    (import ./overlays/default.nix)
  ];

  . . .

   environment.systemPackages = [
    # My custom packages
    jot
    pandoc-select-code
    # Standard packages
   . . .

When I rebuild my configuration, I get the following error:

$ sudo nixos-rebuild switch --upgrade
[sudo] password for amy:
unpacking channels...
building Nix...
building the system configuration...
error: attribute 'jot' missing

       at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:389:28:

          388|         builtins.addErrorContext (context name)
          389|           (args.${name} or config._module.args.${name})
             |                            ^
          390|       ) (lib.functionArgs f);
(use '--show-trace' to show detailed location information)

Here’s ./overlays/default.nix:

final: prev: {
  jot = final.haskellPackages.callPackage ./jot {};
  pandoc-select-code = final.haskellPackages.callPackage ./pandoc-select-code {};
}

I know that ./overlays/default.nix is getting read, because if I add some garbage text to it, I get a syntax error.

Here’s ./overlays/jot/default.nix. I know this is not getting read, because the error message I get is not a syntax error.

THIS TEXT WILL CAUSE A SYNTAX ERROR, WHICH LETS ME KNOW THIS FILE IS BEING READ
{ mkDerivation, base, cmdargs, directory, fetchgit, filepath
, process, lib, time
}:
mkDerivation {
  pname = "jot";
  version = "1.4";
  src = fetchgit {
    url = "https://github.com/mhwombat/jot.git";
    sha256 = "1slnsh2jmqbhrsll6xlwa7nks35agmx2hrwxiy26shvnnfcv6m0d";
    rev = "006ac6d2d97e2cfdf42baa0e6d18dd9eb06c0c05";
    fetchSubmodules = true;
  };
  isLibrary = false;
  isExecutable = true;
  executableHaskellDepends = [
    base cmdargs directory filepath process time
  ];
  license = lib.licenses.publicDomain;
}

I even tried putting an absolute path to jot in ./overlays/default.nix, but it made no difference.

My entire configuration is available at GitHub - mhwombat/nixos-config: My NixOS configuration.

since you dont have environment.systemPackages = with pkgs; [ where would it be pulling jot from?

1 Like

This is actually an error from your packages.nix module trying to get jot as a module argument. Its happening due to the first line in nixos-config/packages.nix at ace23f299ee6822bd439e7abf052c753517d70bb · mhwombat/nixos-config · GitHub.

I think there’s some confusion on the difference between modules and packages. Modules (configuration.nix, packages.nix, etc) accept a few defined arguments, { config, pkgs, options, ... }:. While packages can accept any argument that is also a package, this is only possible because of the use of callPackage.

The fix is to replace the first line of your packages.nix with { config, pkgs, ... }: and then refer to jot and any other package as pkgs.jot. Or, optionally, you could preface the envrionment.systemPackages line with with pkgs; [ so that entire list has items pulled from pkgs.

1 Like