Help writing package derivation and NixOS module for PHP package (Invoice Ninja)

I writing a package derivation and NixOS module for Invoice Ninja. Currently I have a working derivation and I’m working on the module definition. I’m trying to test the module locally. I want to change the module file to have the invoice-ninja variable hold the derivation. I’ve included the head of my module file currently. How can I fix the import at the invoice-ninja variable?

{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.invoice-ninja;
  user = cfg.user;
  group = cfg.group;
  invoice-ninja = (import ./default.nix { }).override { inherit dataDir runtimeDir; };
  phpPackage = cfg.phpPackage.buildEnv {
    extensions = {}: enabled ++ (with all;
      [bcmath ctype curl fileinfo gd gmp iconv mbstring mysqli openssl pdo tokenizer zip]
    );

    extraConfig = "memory_limit = 1024M";
  };
in
{
  options.services.invoice-ninja = {
    enable = mkEnableOption "invoice-ninja";

    package = mkPackageOption pkgs "invoice-ninja" { };

    phpPackage = mkPackageOptionMD pkgs "php" { };

I’ve figured it out. I used pkgs.callPackage. I included the updated head of my module file:

{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.invoice-ninja;
  user = cfg.user;
  group = cfg.group;
  testing = pkgs.callPackage ./default.nix { inherit lib;php=pkgs.php;fetchFromGitHub=pkgs.fetchFromGitHub; };
  invoice-ninja = testing.override { inherit (cfg) dataDir runtimeDir; };
1 Like