Nix flakes path '/nix/store/(...)-source/(...)' does not exist

I’m trying to create a Nix flake to ease the reproduction of Google’s fuzzing tutorial environment, which is described by the following steps:

# Install git and get this tutorial
sudo apt-get --yes install git
git clone https://github.com/google/fuzzing.git fuzzing

# Get fuzzer-test-suite
git clone https://github.com/google/fuzzer-test-suite.git FTS

./fuzzing/tutorial/libFuzzer/install-deps.sh  # Get deps
./fuzzing/tutorial/libFuzzer/install-clang.sh # Get fresh clang binaries

As it is, it’s not ideal to install the Clang binaries in one’s system (it can create conflicts with packet-manager-installed Clangs), and also I’d like to anchor specific commits of both Github repos to ensure that future updates don’t break the tutorial.

So I defined the following flake.nix:

{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
  };

  outputs = { self, nixpkgs }: {

    packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello;

    packages.x86_64-linux.default = self.packages.x86_64-linux.hello;

  };
}
{
  description = "Nix flake for Google Fuzzing Tutorial";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; # Or a specific commit
    # Add other inputs if needed, e.g., for specific fuzzing tools
    # or libraries not in nixpkgs.
  };

  outputs = { self, nixpkgs }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};

      googleFuzzing = pkgs.fetchFromGitHub {
        # https://github.com/google/fuzzing
        owner = "google";
        repo = "fuzzing";
        # Last commit hash
        rev = "734e55f3cfed1adbb51bf6cb5c65b4c1197b7089";
        # Hash of all the contents of the repo
        sha256 = "1y0wkij39rbz8diqm3x23h8qc6nlr35gv2jflcm4xks3qhjlabkr";
      };

      googleFTS = pkgs.fetchFromGitHub {
        # https://github.com/google/fuzzer-test-suite
        owner = "google";
        repo = "fuzzer-test-suite";
        # Last commit hash
        rev = "6955fc97efedfda7dcc0979658b169d7eeb5ccd6";
        # Hash of all the contents of the repo
        sha256 = "0r9ml1iv20ac8b1d94r5l7i40fy7x8ivzj5mlihk93spkrw47cj3";
      };

      pythonPackages = pkgs.python311Packages;

      requirements = builtins.readFile ./requirements.txt;
      pythonEnv = pythonPackages.buildEnv {
        name = "fuzz-env";
        requirements = requirements;
      };


    in {
      devShells.default = pkgs.mkShell {
        buildInputs = [
          pythonEnv
          pkgs.gdb
        ];

        shellHook = ''
		  export PYTHONPATH="${pythonEnv}/lib/python3.11/site-packages:$PYTHONPATH"
  		export FUZZ_REPRO_DIR="${self}/google-tutorial"

	'';
      };
      # Inside the Nix flake,
      # install the right version of DEPS and Clang
      apps.default = {
        type = "app";
        program = ''
          #!/bin/bash
          ./fuzzing/tutorial/libFuzzer/install-deps.sh  # Get deps
          ./fuzzing/tutorial/libFuzzer/install-clang.sh # Get fresh clang binaries
        '';
      };
    };
}

The problem is that I cannot run it:

error: path '/nix/store/s8rba2yf2150msydbpb9i067hypzc19c-source/google-tutorial/flake.nix' does not exist

Does anyone knows why does this happen? So far, I have tried nix-collect-garbage -d, to try to make a nix update, etc, and I have the experimental-features activated, but it doesn’t work anyway. It’s my first attempt on writing a flake in Nix so far.

It should be flake.nix.

GC is not a debugging tool, don’t use it as one. (unless you like longer rebuilds for no reason)

1 Like

It should be flake.nix.

it was a typo, sorry – corrected in the original post.

Delete this first part, a flake.nix should be one attrset, not two

Also if you’re in a git repo, git-add your files.