I'm trying to create a flake for the peer to peer web browser, agregore ( https://github.com/AgregoreWeb/agregore-browser ). It's my first flake and I'm having major difficulties.
Here's the full flake, which I have placed in a clone of the above agregore git repo. I think the relevant section is all just this:
packages.default = stdenv.mkDerivation {
pname = "agregore";
version = (builtins.fromJSON (builtins.readFile ./package.json)).version;
buildInputs = [
pkgs.git
pkgs.nodejs
pkgs.nodePackages.node-gyp
pkgs.nodePackages.npm
pkgs.yarn
];
buildPhase = ''
git submodule update --init --recursive
yarn
'';
installPhase = ''
mkdir -p $out/bin
#TODO find the build output
ln -s build/agregore $out/bin/agregore
'';
src = ./.;
};
Logs produced:
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/va0hnynmqf8h29f580sb6h7d3z9kxcpm-1q603n538l>
source root is 1q603n538laqf3nvkgb5mdr6am8apbda-source
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
no configure script, doing nothing
@nix { "action": "setPhase", "phase": "buildPhase" }
building
fatal: not a git repository (or any of the parent directories): .git
I've tried inserting commands like ls .git/ > out.txt
into the buildPhase, and this produces ls: cannot access '.git/': No such file or directory
, so they are indeed not being copied over to nix's temporary build directory for this flake (and running the same command with build/
instead of .git/
doesn't produce this error.). I can't understand why this would be.
The same command, git submodule update --init --recursive
, works fine in the original project dir (and I'm running nixos btw), also within a nix develop
session, so the .git directory really should to be there?
I believe mkDerivation
by default cleans .git
from the source, because it's not appropriate to include it in a reproducible build (.git
contains things like dangling references to old branches and the like which are completely client-specific). That said, in my opinion git submodule update --init --recursive
doesn't really belong in the Nix code, because the Nix code assumes that it's operating on a "sane" source structure.