Function called without required argument "mkDerivation"

I get this error when I callPackage my derivation of sddm-sugar-dark in my system packages list in configuration.nix and when I run nix-build -A sddm-sugar-dark in the root dir of my local nixpkgs repo.

nixpkgs/pkgs/data/themes/sddm-sugar-dark/default.nix:

{ fetchFromGitHub
, lib
, mkDerivation
, qtquickcontrols2
, qtsvg
}:

mkDerivation rec {
  pname = "sddm-sugar-dark";
  version = "1.2";
  dontBuild = true;

  buildInputs = [
    qtsvg
    qtquickcontrols2
  ];

  installPhase = ''
    mkdir -p $out/share/sddm/themes
    cp -aRv . $out/share/sddm/themes/sugar-dark
  '';

  src = fetchFromGitHub {
    owner = "MarianArlt";
    repo = "sddm-sugar-dark";
    rev = "v${version}";
    sha256 = "0gx0am7vq1ywaw2rm1p015x90b75ccqxnb1sz3wy8yjl27v82yhb";
  };

  meta = with lib; {
    description = "The sweetest dark theme around for SDDM";
    license = licenses.gpl3Plus;
    platforms = platforms.linux;
    homepage = "https://github.com/MarianArlt/sddm-sugar-dark";
  };
}

Error:

error: Function called without required argument "mkDerivation" at /home/<user>/clonedrepos/nixpkgs/pkgs/data/themes/sddm-sugar-dark/default.nix:3

I don’t know if by “function called” it means the function that calls the derivation in all-packages.nix but my entry for sddm-sugar-dark in this file is just sddm-sugar-dark = callPackage ../data/themes/sddm-sugar-dark { };

The derivation was working until I added the qt deps specified in the sddm-sugar-dark gh repo:

I don’t really know if the way I’ve done it is correct but I did something similar before which worked fine.

It’s supposed to be stdenv, no?

@@ -1,11 +1,11 @@
 { fetchFromGitHub
 , lib
-, mkDerivation
+, stdenv
 , qtquickcontrols2
 , qtsvg
 }:

-mkDerivation rec {
+stdenv.mkDerivation rec {
   pname = "sddm-sugar-dark";
   version = "1.2";
   dontBuild = true;
1 Like

Also could be that you need to use the qt specific mkDerivation. I think its qt5.mkDerivation

libsForQt5 has a standalone mkDerivation attribute, but don’t use it as it’s deprecated (and therefore gone in qt6Packages).

Use stdenv.mkDerivation, and add wrapQtAppsHook to nativeBuildInputs instead.

1 Like

Taking all your advice on board, I changed it to stdenv.mkDerivation and added wrapQtAppsHook to nativeBuildInputs, but now I’m getting:

error: Function called without required argument "qtgraphicaleffects" at /home/<user>/clonedrepos/nixpkgs/pkgs/data/themes/sddm-sugar-dark/default.nix:3

When I comment out qtgraphicaleffects in default.nix, I get a similar error:

error: Function called without required argument "qtquickcontrols2" at /home/<user>/clonedrepos/nixpkgs/pkgs/data/themes/sddm-sugar-dark/default.nix:4

default.nix:

{ fetchFromGitHub
, lib
#, qtgraphicaleffects
, qtquickcontrols2
, qtsvg
, stdenv
, wrapQtAppsHook
}:

stdenv.mkDerivation rec {
  pname = "sddm-sugar-dark";
  version = "1.2";
  dontBuild = true;

  buildInputs = [
    qtsvg
    qtquickcontrols2
#    qtgraphicaleffects
  ];

  nativeBuildInputs = [ wrapQtAppsHook ];

...

EDIT: I’m looking through other derivations that use these qt packages. Eg. pineapple-pictures uses qtgraphicaleffects and also uses cmake as a nativeBuildInput. I don’t know what I’m doing so I tried including it in my derivation but to no effect. Including qtbase gets an error of a different sort:

error: Function called without required argument "qtbase" at /home/mips/clonedrepos/nixpkgs/pkgs/data/themes/sddm-sugar-dark/default.nix:3, did you mean "hbase", "qtpass" or "xbase"?

Your callPackage line should look like

sddm-sugar-dark = libsForQt5.callPackage ... { };

The libsForQt5 is important because the callPackage on this package set will let you resolve the qt libraries.

1 Like

When I include libsForQt5 the derivation in my local nixpkgs repo builds correctly, thanks.

On my system, the rebuild is also successful but when I log out, I get the default SDDM theme with an error:

The current theme cannot be loaded due to the errors below, please select another theme.

file:///run/current-system/sw/share/sddm/themes/sugar-dark/Main.qml:28:1: module “QtGraphicalEffects” is not installed

It is though, and when I previously didn’t include the deps in the derivation but installed them separately along with the derivations, it worked fine.

sddm.nix (part of configuration.nix that has SDDM settings):

{ config, pkgs, ... }:

{
  services.xserver.displayManager.sddm = {
    enable = true;
    theme = "sugar-dark";
  };

  environment.systemPackages = with pkgs; [
    (libsForQt5.callPackage ./pkgs/sddm-sugar-candy/default.nix {})
    (libsForQt5.callPackage ./pkgs/sddm-sugar-dark/default.nix {})
  ];
 }