Skip Navigation

Search

Nix / NixOS @programming.dev

Network access while building a derivation?

edit: for the solution, see my comment below

I'm trying to package a go application (beszel) that bundles a bunch of html stuff built with bun (think, npm).

The html is generated by running bun install and bun run and then embedded in the go binary with //go:embed.

Being completely ignorant of the javascript ecosystem, my first idea was to just replicate what they do in the Makefile

 nix
    
postConfigure = ''
bun install --cwd ./site
bun run     --cwd ./site build
'' 

  

but, since bun install downloads dependencies from the net, that fails.

I guess the "clean" solution would be to look for buildNpmPackage or similar (assuming that exists) and let nix manage all the dependencies, but... it's some 800+ dependencies (at least, bun install ... --dry-run lists 800+ things) so that's a hard pass.

I then tried to look at how buildGoPackage handles the vendoring of dependencies, with the idea of replicating that (it dowloads what's n

Nix / NixOS @programming.dev

Help with haskell package that lives in a subdirectory of src

edit: for the solution, see my comment below

I need/want to build aeson and its subproject attoparsec-aeson from source (it's a fork of the "official" aeson), but I'm stuck... can you help out?

The sources of attoparsec-aeson live in a subdirectory of the aeson ones, so I have the sources:

 nix
    
aeson-src = fetchFromGitHub {
  ...
};


  

and the "main" aeson library:

 nix
    
aeson = haskellPackages.mkDerivation {
  pname = "aeson";
  src = aeson-src;
  ...
};


  

When I get to attoparsec-aeson however I run into a wall: I tried to follow the documentation about sourceRoot:

 undefined
    
attoparsec-aeson = haskellPackages.mkDerivation {
  pname = "attoparsec-aeson";
  src = aeson-src;
  sourceRoot = "./attoparsec-aeson"; # maybe this should be "${aeson-src}/attoparsec-aeson"?
                                     # (it doesn't work either way)
  ...
};


  

but I get ``