edolstra / flake-compat

MIT License
254 stars 71 forks source link

nix-build silently failing and still returning exit code 0 #48

Open martyall opened 2 years ago

martyall commented 2 years ago

Running nix build successfully builds the artifacts and links them in the newly created results/bin. When I ran nix-build --debug, I got the following output:

evaluating file '/nix/store/jb9wd23mwynz6k168gg52hysyh5xag1s-source/default.nix'
warning: Git tree '/home/martin/code/iog/stablecoin-plutus' is dirty
acquiring write lock on '/nix/var/nix/temproots/303423'
evaluating file '/nix/store/4wqylrpk95rxrkmppn0ndgp0g8bq5j01-source/flake.nix'
using substituted/cached input 'github:numtide/flake-utils/5aed5285a952e0b949eb3ba02c12fa4fcfef535f' in '/nix/store/sk4ga2wy0b02k7pnzakwq4r3jdknda4g-source'
evaluating file '/nix/store/sk4ga2wy0b02k7pnzakwq4r3jdknda4g-source/flake.nix'
evaluating file '/nix/store/sk4ga2wy0b02k7pnzakwq4r3jdknda4g-source/default.nix'
evaluating attribute 'checks'
evaluating attribute 'devShells'
evaluating attribute 'inputs'
evaluating attribute 'lastModified'
evaluating attribute 'lastModifiedDate'
evaluating attribute 'legacyPackages'
evaluating attribute 'narHash'
evaluating attribute 'outPath'
evaluating attribute 'outputs'
evaluating attribute 'packages'
evaluating attribute 'revCount'
evaluating attribute 'sourceInfo'
evaluating attribute 'submodules'
querying info about missing paths...
starting pool of 24 threads
querying info about missing paths...
starting pool of 24 threads
entered goal loop

which resulted in an exit code 0 but does not build / link any artifacts (I checked this multiple times). In the end the problem was that the README says to put the following into my default.nix

(import
  (
    let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
    fetchTarball {
      url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
      sha256 = lock.nodes.flake-compat.locked.narHash;
    }
  )
  { src = ./.; }
).defaultNix

which references the rev of the flake-compat object in the lock file. However, because of previous dependencies, the flake-compat object in the lock file refers to a fork of flake-compat from IOHK

    "flake-compat": {
      "flake": false,
      "locked": {
        "lastModified": 1647532380,
        "narHash": "sha256-wswAxyO8AJTH7d5oU8VK82yBCpqwA+p6kLgpb1f1PAY=",
        "owner": "input-output-hk",
        "repo": "flake-compat",
        "rev": "7da118186435255a30b5ffeabba9629c344c0bec",
        "type": "github"
      },

whereas flake-compat_11 (and several other variants) did refer to a commit by @edolstra's repo. When I replaced flake-compat with (for example) flake-compat_11, everything worked as intended.

This actually seems like a nix bug but I figured I would put it here first. The reason being that the result dir was not created, there definitely was an error because I was trying to import some probably non-existent nix file, yet the process finishes with exit code 0.