Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

injecting a dependency does not add proper dependencies/sources for injection #104

Closed
tgunnoe opened this issue Mar 16, 2022 · 6 comments
Closed

Comments

@tgunnoe
Copy link
Contributor

tgunnoe commented Mar 16, 2022

original error:

error: attribute 'prom-client' missing

       at /nix/store/aamp3d520rnanjbvcx3nwcs1b2d0588f-source/src/builders/nodejs/granular/default.nix:158:13:

          157|       deps
          158|       (dep: allPackages."${dep.name}"."${dep.version}");
             |             ^
          159|

simple flake that injects a dependency for yarn pure:

  {
    inputs.dream2nix.url = "github:nix-community/dream2nix";
    outputs = { self, dream2nix }@inputs:
      let
        dream2nix = inputs.dream2nix.lib.init {
          systems = [ "x86_64-linux" ];
          config.projectRoot = ./. ;
        };
      in dream2nix.makeFlakeOutputs {
        source = ./.;
        inject = {
          express-prom-bundle."6.4.1" = [
            ["prom-client" "13.1.0"]
          ];
        };
      };
  }

package.json:

{
  "name": "test2",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "express-prom-bundle": "^6.4.1"
  }
}

result:

  {
    _generic = {
      defaultPackage = "test2";
      location = "";
      packages = {
        test2 = "1.0.0";
      };
      sourcesAggregatedHash = null;
      subsystem = "nodejs";
    };
    _subsystem = { nodejsVersion = "14"; };
    cyclicDependencies = { };
    decompressed = true;
    dependencies = {
      ee-first = { "1.1.1" = [ ]; };
      express-prom-bundle = {
        "6.4.1" = [
          { name = "on-finished"; version = "2.4.1"; }
          { name = "url-value-parser"; version = "2.1.0"; }
          { name = "prom-client"; version = "13.1.0"; }
        ];
      };
      on-finished = {
        "2.4.1" = [
          { name = "ee-first"; version = "1.1.1"; }
        ];
      };
      test2 = {
        "1.0.0" = [
          { name = "express-prom-bundle"; version = "6.4.1"; }
        ];
      };
      url-value-parser = {
        "2.1.0" = [ ];
      };
    };
    sources = {
      ee-first = {
        "1.1.1" = {
          hash = "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=";
          type = "http";
          url = "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz";
        };
      };
      express-prom-bundle = {
        "6.4.1" = {
          hash = "sha512-Sg0svLQe/SS5z1tHDTVfZVjNumobiDlXM0jmemt5Dm9K6BX8z9yCwEr93zbko6fNMR4zKav77iPfxUWi6gAjN  A==";
          type = "http";
          url = "https://registry.yarnpkg.com/express-prom-bundle/-/express-prom-bundle-6.4.1.tgz";
        };
      };
      on-finished = {
        "2.4.1" = {
          hash = "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+k  g==";
          type = "http";
          url = "https://registry.yarnpkg.com/on-finished/-/on-finished-2.4.1.tgz";
        };
      };
      test2 = {
        "1.0.0" = {
          path = "/nix/store/b4zlnjwd3aaph1xav090bd04zr60f23m-crh0vxqmg4zd3bj1i2g0cyc73jg9g2kg-source";
          type = "path";
        };
      };
      url-value-parser = {
        "2.1.0" = {
          hash = "sha512-gIYPWXujdUdwd/9TGCHTf5Vvgw6lOxjE5Q/k+7WNByYyS0vW5WX0k+xuVlhvPq6gRNhzXVv/ezC+OfeAet5Kc  w==";
          type = "http";
          url = "https://registry.yarnpkg.com/url-value-parser/-/url-value-parser-2.1.0.tgz";
        };
      };
    };
  }
@tgunnoe tgunnoe changed the title injecting a dependency does not add proper sources for injection injecting a dependency does not add proper dependencies/sources for injection Mar 21, 2022
@tgunnoe
Copy link
Contributor Author

tgunnoe commented Mar 24, 2022

I'll just add a similar issue in the same place. If I add prom-client manually:
yarn add prom-client
the error will change to:
error: attribute '13.1.0' missing
(the injection package exists and is found, but the version doesn't match the version added). I suppose this may not be an issue, because the specified injection for express-prom-bundle."6.4.1" should be added separately, if another prom-client already exists.

@tgunnoe
Copy link
Contributor Author

tgunnoe commented Mar 24, 2022

As per @DavHau's suggestion that it may be error handling related and that I should add a source override, I tried this:

  {
    inputs.dream2nix.url = "github:nix-community/dream2nix";
    outputs = { self, dream2nix }@inputs:
      let
        dream2nix = inputs.dream2nix.lib2.init {
          systems = [ "x86_64-linux" ];
          config.projectRoot = ./. ;
        };
      in dream2nix.makeFlakeOutputs {
        source = ./.;
        inject = {
          express-prom-bundle."6.4.1" = [
            ["prom-client" "13.1.0"]
          ];
        };
        sourceOverrides = oldSources: {
          "prom-client"."13.1.0" = builtins.fetchurl {
            url = "https://github.com/siimon/prom-client/archive/v13.1.0.tar.gz";
            sha256 = "0nvxj4sz2hvqqlksp9fkxhx32qdwhf3g8ibglyfa38ljlk2mqdfk";
          };
        };
      };
  }

Still the same error as above error: attribute 'prom-client' missing.

@DavHau
Copy link
Member

DavHau commented Apr 3, 2022

Hey I was not able to reproduce the the error with the given flake. The flake does not specify the source project. Could you please provide a flake that manages the source via flake input or share the whole repo?

@tgunnoe
Copy link
Contributor Author

tgunnoe commented Apr 3, 2022

@DavHau

    {
      inputs.dream2nix.url = "github:nix-community/dream2nix";
      inputs.src.url = "github:tgunnoe/dream2nix-inject-test";
      inputs.src.flake = false;
      outputs = { self, dream2nix, src }@inputs:
        let
          dream2nix = inputs.dream2nix.lib.init {
            systems = [ "x86_64-linux" ];
            config.projectRoot = ./. ;
          };
        in dream2nix.makeFlakeOutputs {
          source = src;
          inject = {
            express-prom-bundle."6.4.1" = [
              ["prom-client" "13.1.0"]
            ];
          };
        };
    }

@DavHau DavHau closed this as completed in 0ceb2b9 Apr 4, 2022
@DavHau
Copy link
Member

DavHau commented Apr 4, 2022

Thanks a lot for providing the flake. Now it's fixed

@tgunnoe
Copy link
Contributor Author

tgunnoe commented Apr 4, 2022

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants