nix-community / dream2nix

Simplified nix packaging for various programming language ecosystems [maintainer=@DavHau]
https://dream2nix.dev
MIT License
972 stars 122 forks source link

error: The option `public.drvPath' is used but not defined. #1025

Open winston0410 opened 1 month ago

winston0410 commented 1 month ago

I have a flake like this, where there is a simple npm project(it is sveltekit, but doesn't matter I guess) in the root directory

{
  description = "closesource repo flake";

  inputs = {
    dream2nix.url = "github:nix-community/dream2nix";
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixpkgs-24.05-darwin";
    unstable.url = "github:nixos/nixpkgs?ref=nixpkgs-unstable";

    flake-utils.url =
      "github:numtide/flake-utils?rev=ff7b65b44d01cf9ba6a71320833626af21126384";
  };

  outputs = { self, nixpkgs, unstable, flake-utils, dream2nix, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          overlays = [ ];
        };

        unstablePkgs = unstable.legacyPackages.${system};

        buildInputs = with pkgs; [
          nodejs_20
          deno
        ];
      in {
        packages = {
          defaultPackage = pkgs.buildEnv {
            name = "ezdrop";
            paths = buildInputs;
          };

          sveltekit = dream2nix.lib.evalModules {
            packageSets.nixpkgs = nixpkgs.legacyPackages.${system};
            modules = [
              {
                paths.projectRoot = ./.;
                paths.projectRootFile = "flake.nix";
                paths.package = ./.;
              }
            ];
          };
        };

        devShell = (({ pkgs, ... }:
          pkgs.mkShell {
            buildInputs = buildInputs;

            shellHook = ''

            '';
          }) { inherit pkgs; });
      });
}

When I run nix build .#sveltekit, I get the following error:

warning: Git tree '/Users/hugosum/Desktop/ezdrop' is dirty
error:
       … while calling the 'head' builtin

         at /nix/store/g2ysyzdx76m4z7lnmyddcwdz25lx7kn1-source/lib/attrsets.nix:1575:11:

         1574|         || pred here (elemAt values 1) (head values) then
         1575|           head values
             |           ^
         1576|         else

       … while evaluating the attribute 'value'

         at /nix/store/g2ysyzdx76m4z7lnmyddcwdz25lx7kn1-source/lib/modules.nix:821:9:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          822|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `public.drvPath' is used but not defined.

Do I need to define drvPath myself? Where should I do that?

winston0410 commented 1 month ago

My nix version is ❯ nix --version nix (Nix) 2.17.0

DavHau commented 1 month ago

You need to import a module like nodejs-package-lock-v3, etc. See some examples under dream2nix/examples.