Skip to content

flake always eval binary data file dependency #16004

@loynoir

Description

@loynoir

Describe the bug

flake always eval binary data file dependency

Steps To Reproduce

/tmp/reproduce/flake.nix

{
  description = "A minimal flake using builtins.derivation in mkShell";

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

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

      binary_data = builtins.derivation {
        name = "binary_data";
        builder = "${pkgs.bash}/bin/bash";
        args = [
          "-c"
          # simulate build binary data file under network
          ''echo -ne '\x01\x02\x03\x04\x05\x06\x07' > $out''
        ];
        inherit system;
        outputHashMode = "flat";
        outputHashAlgo = "sha256";
        outputHash = "32bbe378a25091502b2baf9f7258c19444e7a43ee4593b08030acd790bd66e6a";
      };
    in
    {
      devShells.${system}.default = pkgs.mkShell {
        buildInputs = [ binary_data ];
        shellHook = ''
          echo foo build from --file ${binary_data}
        '';
      };
    };
}

flake always eval binary data file dependency

$ nix develop /tmp/reproduce
(trigger post-build-hook, upload to s3)
error: Cannot build '/nix/store/lwxqqix9al4pywwr8kidzf7fgxzndfxd-nix-shell-env.drv'.
       Reason: builder failed with exit code 127.
       Output paths:
         /nix/store/7pvdjzjh2pbzrx1wk6d8xi20jp3q05jx-nix-shell-env
       Last 1 log lines:
       > /nix/store/lhwqm1ccncv81jxw29vnzbhiy20h5ldp-binary_data: line 1: $'\001\002\003\004\005\006\a': command not found
       For full logs, run:
         nix log /nix/store/lwxqqix9al4pywwr8kidzf7fgxzndfxd-nix-shell-env.drv

Expected behavior

flake able to not eval binary data file dependency

$ nix develop /tmp/reproduce
(trigger post-build-hook, upload to s3)
foo build from --file /nix/store/XXX-binary_data

Metadata

Additional context

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions