!NhAsaYbbgmzHtXTPQJ:funklause.de

Nix NodeJS

201 Members
60 Servers

Load older messages


SenderMessageTime
5 Feb 2024
@ThorHop:matrix.org@ThorHop:matrix.org left the room.22:46:57
6 Feb 2024
@tensor5:matrix.orgNicola Squartini Hi, I'm trying to put a flake.nix in a NextJS project, that contains a very basic packages.default output with buildNpmPackage 10:41:30
@tensor5:matrix.orgNicola Squartini the problem is that whenever I use a revative import to a local .ts file I get error Module not found: Can't resolve './<file name>' 10:43:36
@tensor5:matrix.orgNicola Squartini although npm run build work normally when I run it from the shell 10:44:29
@tensor5:matrix.orgNicola Squartini to reproduce you can create a Next project with npx create-next-app@latest and accept the defaults 10:46:50
@tensor5:matrix.orgNicola Squartiniand then add an import to a local file10:47:19
@9hp71n:matrix.orgghpzin Did you git add that file ? 10:49:59
@tensor5:matrix.orgNicola Squartini

yes, here is the flake:

{
  description = "Blog";

  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
  };

  outputs = { flake-utils, nixpkgs, self }:
    flake-utils.lib.eachDefaultSystem (system:
      let pkgs = import nixpkgs { inherit system; }; in
      {
        devShells.default = pkgs.mkShell {
          packages = with pkgs; [
            nodejs_21
            prefetch-npm-deps
          ];
        };
        formatter = pkgs.nixpkgs-fmt;
        packages.default =
          let
            packageJson = builtins.fromJSON (builtins.readFile ./package.json);
          in
          pkgs.buildNpmPackage {
            pname = packageJson.name;
            version = packageJson.version;
            npmDepsHash = "sha256-gjQCVQI7Tp+L6ZF9phJFZQaaPwtPDp0xVOYMF+CPHIg=";

            src = ./.;

            BUILD_ID = self.rev or self.dirtyRev;
            NEXT_TELEMETRY_DISABLED = 1;

            #installPhase = ''
            #  runHook preInstall
            #  cp -r out $out
            #  runHook postInstall
            #'';
          };
      }
    );
}
10:50:29
@tensor5:matrix.orgNicola Squartininix build works as long as I don't add local imports10:51:02
@tensor5:matrix.orgNicola Squartiniimports from node_modules don't have issues10:51:38
@tensor5:matrix.orgNicola Squartini
In reply to @9hp71n:matrix.org
Did you git add that file ?
ahh, you are right! I actually forgot to add that fiel
10:54:29
@tensor5:matrix.orgNicola Squartinisorry about that10:55:04
@tensor5:matrix.orgNicola Squartinithank you so much 🙏10:56:39
8 Feb 2024
@adis:blad.is@adis:blad.is Is there any rationale for keeeping buildNpmPackage around anymore?
Imo it should be dropped in favour of just using stdenv.mkDerivation
01:26:21
@kranzes:matrix.org@kranzes:matrix.orgExplain 03:12:07
@kranzes:matrix.org@kranzes:matrix.orgIs this because of npmHooks?03:12:36
@kranzes:matrix.org@kranzes:matrix.orgOr whatever that's called 03:12:47
@kranzes:matrix.org@kranzes:matrix.orgI don't mind buildNpmPackage03:13:12
@adis:blad.is@adis:blad.is
In reply to @kranzes:matrix.org
Is this because of npmHooks?
This is because it's not really doing much, so it's a functional stdenv abstraction for not much gain
04:11:08
@adis:blad.is@adis:blad.is

Essentially it's just this:

stdenv.mkDerivation (args // {
  inherit npmDeps npmBuildScript;

  nativeBuildInputs = nativeBuildInputs
    ++ [ nodejs npmConfigHook npmBuildHook npmInstallHook nodejs.python ]
    ++ lib.optionals stdenv.isDarwin [ darwin.cctools ];
  buildInputs = buildInputs ++ [ nodejs ];

  strictDeps = true;

  # Stripping takes way too long with the amount of files required by a typical Node.js project.
  dontStrip = args.dontStrip or true;

  meta = (args.meta or { }) // { platforms = args.meta.platforms or nodejs.meta.platforms; };
})
04:11:32
@adis:blad.is@adis:blad.isMy take is: Just use the hooks04:12:49
@adis:blad.is@adis:blad.is stdenv.mkDerivation wrappers are an anti-pattern 04:13:19
@adis:blad.is@adis:blad.isUsing the hooks is more composable as well04:14:06
@adis:blad.is@adis:blad.isIt makes it possible to for example build a Go application backend and the web frontend all in one derivation04:14:58
@adis:blad.is@adis:blad.isThat's already possible mind you04:15:36
@adis:blad.is@adis:blad.is But because we have buildNpmPackage that's not as obvious as it could be 04:15:42
10 Feb 2024
@drupol:matrix.orgPolHey, I'm trying to build a NPM package here: https://github.com/NixOS/nixpkgs/pull/287527 Can you have a look at the build log in the first post and give some pointers and/or documentation ?08:45:01
@julia:the-apothecary.club@julia:the-apothecary.clublooks like you solved your issue?09:35:04
@sandro:supersandro.deSandro 🐧Reducing dependencies of applications that use yarn https://github.com/NixOS/nixpkgs/pull/28190213:17:17
@drupol:matrix.orgPol
In reply to @julia:the-apothecary.club
looks like you solved your issue?
Not yet.
22:50:40

Show newer messages


Back to Room ListRoom Version: 6