Noob Building Derivation

so i wanted to learn nix flakes but then i learned that nix derivations is the core of nix os and started learning it . i went through the nix os basic tutorials and also the nix pills to learn as much as i can about nix derivations.

i built the first derivation of icat from the nix documentation and after that i want to build a software of swi prolog derivation so i wrote the derivation in swipl.nix file llike following

{lib,
  stdenv,
  fetchzip,
  cmake,
  ninja,
  zlib,
  libarchive
}:

stdenv.mkDerivation {
  name = "swipl";

  src = fetchzip {
    url = "https://www.swi-prolog.org/download/stable/src/swipl-9.0.4.tar.gz";
    sha256 = "sha256-xsh2gJCpQiAbhjs6ZV9Zra8nXxaexaFrFilMvZBMjF4=" ;
  };
  nativeBuildInputs = [cmake ninja zlib];
  cmakeFlags = [
    "-DCMAKE_INSTALL_PREFIX=$out -G Ninja"
  ];
  buildPhase = ''
   cmake
   ninja
'';
  installPhase = ''
   ninja install
'';
}

i am getting an error when building this deravation it goes something like this

-- Could NOT find Qt5Widgets (missing: Qt5Widgets_DIR)
-- Could NOT find X11 (missing: X11_X11_INCLUDE_PATH X11_X11_LIB) 
-- Could NOT find Libedit (missing: LIBEDIT_LIBRARIES LIBEDIT_INCLUDE_DIR) 
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH) 
-- Could NOT find Readline (missing: Readline_INCLUDE_DIR Readline_LIBRARY) 
-- Finding default package generator
-- Found both apt and dnf.  Setting DEB generator
-- Setup for packaging with DEB
-- Configuring done (13.7s)
-- Generating done (0.1s)
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_EXPORT_NO_PACKAGE_REGISTRY
    CMAKE_INSTALL_BINDIR
    CMAKE_INSTALL_DOCDIR
    CMAKE_INSTALL_INCLUDEDIR
    CMAKE_INSTALL_INFODIR
    CMAKE_INSTALL_LIBDIR
    CMAKE_INSTALL_LIBEXECDIR
    CMAKE_INSTALL_LOCALEDIR
    CMAKE_INSTALL_MANDIR
    CMAKE_INSTALL_OLDINCLUDEDIR
    CMAKE_INSTALL_SBINDIR
    CMAKE_POLICY_DEFAULT_CMP0025


-- Build files have been written to: /build/source/build
cmake: enabled parallel building
cmake: enabled parallel installing
building
ninja: error: 'man/ssl', needed by 'man/lib/prologpack.tex', missing and no known rule to make it
error: builder for '/nix/store/qfwzwpxnmhswczbwn5md2y2pxa1lpfrh-swipl.drv' failed with exit code 1;
       last 10 log lines:
       >     CMAKE_INSTALL_OLDINCLUDEDIR
       >     CMAKE_INSTALL_SBINDIR
       >     CMAKE_POLICY_DEFAULT_CMP0025
       >
       > 
       > -- Build files have been written to: /build/source/build
       > cmake: enabled parallel building
       > cmake: enabled parallel installing
       > building
       > ninja: error: 'man/ssl', needed by 'man/lib/prologpack.tex', missing and no known rule to make it
       For full logs, run 'nix log /nix/store/qfwzwpxnmhswczbwn5md2y2pxa1lpfrh-swipl.drv'.

what do i do now
to build this derivation i am using callpackage in the default.nix file any help would be appreciated.

The error would seem to indicate that you are missing libssl. Maybe add openssl to the nativeBuildInputs? But I am just guessing hereā€¦

We already have swi-prolog packaged. And yes, it requires openssl:

Note that cmake is already executed as a part of configurePhase (automatically added when you add cmake to nativeBuildInputs):

Similarly, ninja will already handle the default buildPhase and installPhase:

Runtime dependencies like zlib should go to buildInputs, nativeBuildInputs is mainly for software that should run on the build platform (e.g. cmake).

yes we already have the swi prolog packaged but i am trying to use swi-prolog with emacs . so in emacs there is support for prolog. so i wanted to use the sweeprolog package for emacs but the swi prolog that i use from nix store does not have the sweep.h header file in the package to communicate with the sweeprolog package. to avoid this issue i need to build swi prolog from source thats why i cant use the already packaged swiprolog .