numtide / flake-utils

Pure Nix flake utility functions [maintainer=@zimbatm]
MIT License
1.15k stars 79 forks source link

flake-utils.lib.mkApp is broken with nix 2.8 #61

Closed Lunarequest closed 2 years ago

Lunarequest commented 2 years ago

Describe the bug

To Reproduce

Steps to reproduce the behavior:

  1. use nix run on a repo with the an app made with flake-utils.lib.mkApp
  2. errors with error: attribute 'defaultApp.x86_64-linux' should have type 'derivation'

Expected behavior the app executes normally

System information nix 2.8.0 linux

Additional context nix 2.8.0 has more strictness the nix 2.7 which has broken flake-utils

zimbatm commented 2 years ago

is that fixed?

TristanCacqueray commented 2 years ago

This issue is still happening when using defaultApp = flake-utils.lib.mkApp { drv = package; }; with nix-2.8 . This seems to work though: apps.default = flake-utils.lib.mkApp { drv = package; }.

tv42 commented 2 years ago

It does not seem like this issue should have been closed.

johnrichardrinehart commented 2 years ago

EDIT: Discovered that the problem I was describing underneath the divider, below, was because I wasn't conforming to https://github.com/numtide/flake-utils/commit/c0e246b9b83f637f4681389ecabcb2681b4f3af0 . After respecting that commit and moving my defaultApp value to apps.default nix run . works fine.

        apps = rec {
          go_1_18-fips = flake-utils.lib.mkApp { drv = packages.go_1_18-fips;  exePath = "/bin/go";};
          default = go_1_18-fips;
        };

I have a bunch of files in $out/bin and trying to select only one for defaultApp with exePath or name fails with the above error. It doesn't matter if I try apps.defaultApp or defaultApp.

        apps.defaultApp =  flake-utils.lib.mkApp { drv = packages.go_1_18-fips;  name = "go";};

However, the below works just fine as nix run .#go_1_18-fips

        apps.go_1_18-fips = flake-utils.lib.mkApp { drv = packages.go_1_18-fips;  name = "go";};

It's possible this has been the case for as long as nix 2.8. But, in my case

$ nix --version
nix (Nix) 2.10.3
$ cat flake.lock | grep numtide -C 10
{
  "nodes": {
    "flake-utils": {
      "locked": {
        "lastModified": 1659877975,
        "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },