# Creating a nix derivation for wxchartdir

**URL:** https://discourse.nixos.org/t/creating-a-nix-derivation-for-wxchartdir/58725
**Category:** Help
**Created:** [January 13, 2025, 2:39am UTC](https://discourse.nixos.org/t/creating-a-nix-derivation-for-wxchartdir/58725 "2025-01-13T02:39:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Sammyalhashe](https://discourse.nixos.org/user_avatar/discourse.nixos.org/sammyalhashe/32/27000_2.png) [@Sammyalhashe](https://discourse.nixos.org/u/Sammyalhashe)
#### Post date: [January 13, 2025, 2:39am UTC](https://discourse.nixos.org/t/creating-a-nix-derivation-for-wxchartdir/58725/1 "2025-01-13T02:39:15Z")

</div>

Hi everyone!

There is this niche library associate with wxWidgets (available in nixpkgs as wxGTK32) and I noticed no package is available in nixpkgs. I wanted to take a stab at doing this myself for both practice/learning. The library is called wxchartdir ([GitHub - utelle/wxchartdir: wxChartDir - Support for using the ChartDirector charting library in wxWidgets applications](https://github.com/utelle/wxchartdir))

Although before that, I decided to make a derivation that can be installed, etc… However going this way I have run into wits end 😆 and am asking the community for some guidance/ideas here.

You can see what I have so far below in my `default.nix`, but I have two main questions:

1. Does what I’m doing so far seem okay? I got this far with a bunch of google-foo and doc-foo and this may be as far as I can go on my own 🙂
2. It currently is stuck because some of the files I add to `$out` aren’t in an expected ELF format. What is the expected format? How do I do this? Do I need the patch phase (why is is necessary?).

```nix
with import <nixpkgs> {};
stdenv.mkDerivation {
    name = "wxchartdir";
    src = fetchFromGitHub {
        owner = "utelle";
        repo = "wxchartdir";
        rev = "d612cc6b8d463c3c11d4374291e493c74039aac1";
        hash = "sha256-3MfNtkgmQs8UMz99ZRlkNqaHO62tNssYUVrTh9xMV20=";
    };
    enableParallelBuilding = true;
    doInstallCheck = false;
    dontPatch = true;
    nativeBuildInputs = with pkgs; [autoreconfHook];
    buildInputs = with pkgs; [autoconf automake gnumake wxGTK32];
    configurePhase = ''
        ./configure
    '';
    buildPhase = ''
        make
    '';
    installPhase = ''
        mkdir $out
        cp -r include $out
        cp -r lib $out
        cp -r libtool $out
        cp -r *.la $out
        cp -r *.pc $out
        cp -r *.m4 $out
        cp -r wxdemo $out
    '';
}

```

If you can help me out once more, I am trying to make this derivation digestable by a cmake project. Building this produces a package-config file (`.pc`), some `.la` file, some `.m4` file, and `.lo` files, all of which I have never heard of (except package-config of course). Do I really need to include all of these files to make it digestible for a cmake project?

Thanks everyone! Apologies for such a noobie question! 🙂

---

<div class="post-metadata">

### Author: ![waffle8946](https://discourse.nixos.org/user_avatar/discourse.nixos.org/waffle8946/32/27221_2.png) [@waffle8946](https://discourse.nixos.org/u/waffle8946)
#### Post date: [January 13, 2025, 9:35pm UTC](https://discourse.nixos.org/t/creating-a-nix-derivation-for-wxchartdir/58725/2 "2025-01-13T21:35:09Z")

</div>

> `autoconf automake gnumake`

- These should all go in `nativeBuildInputs` (and `stdenv` [already includes `gnumake`](https://nixos.org/manual/nixpkgs/unstable/#sec-tools-of-stdenv))

- Keep the pre-/post-phase hooks ([Packaging existing software with Nix — nix.dev documentation](https://nix.dev/tutorials/packaging-existing-software.html#phases-and-hooks)). This is not pedantry, nor is it something to put off until later, this **will** affect your build.

- You can probably drop the `buildPhase` iirc

- Post the actual full error without paraphrasing.
