Synthetica9 / nix-linter

Linter for the Nix expression language
BSD 3-Clause "New" or "Revised" License
158 stars 16 forks source link

Builds package set instead of package #37

Closed cdfa closed 4 years ago

cdfa commented 4 years ago

Hi, I'm quite new to Nix, but I think your default.nix builds a new nixpkgs set instead of the package. I had quite a bit of trouble trying to install your package because of this.

What I expected to work:

{ pkgs ? import <nixpkgs> {} }:

let
  src = pkgs.fetchFromGitHub {
    owner  = "Synthetica9";
    repo   = "nix-linter";
    rev    = "8f1037ddb3c03a12f285b4a9702e73c0eb15f972"; # master at time of writing
    sha256 = "0ghlr8pvhps75y4c4nxkdfkl0v0rrk7mc1n5nwp3cfyyn2zl6w94";
  };

  nix-linter = import "${src}/default.nix" {};
in
pkgs.mkShell {
  buildInputs = [ nix-linter ];
}

This results in the following error:

error: cannot coerce a set to a string, at /nix/store/wsm38vyj402knlizqlihhnj042l14bj5-nixpkgs-20.09pre240426.f9567594d5a/nixpkgs/pkgs/build-support/mkshell/default.nix:28:3
(use '--show-trace' to show detailed location information)

What does work:

{ pkgs ? import <nixpkgs> {} }:

let
  src = pkgs.fetchFromGitHub {
    owner  = "Synthetica9";
    repo   = "nix-linter";
    rev    = "8f1037ddb3c03a12f285b4a9702e73c0eb15f972"; # master at time of writing
    sha256 = "0ghlr8pvhps75y4c4nxkdfkl0v0rrk7mc1n5nwp3cfyyn2zl6w94";
  };

  nix-linter-pkgs = import "${src}/default.nix" {}; # <-- ###################################
in
pkgs.mkShell {
  buildInputs = [ nix-linter-pkgs.nix-linter ]; # <-- ###################################
}
ryantm commented 4 years ago

default.nix files don't have a set interface. When you use one you always have to look at it to see what interface it provides. This packages interface is quite common.

Note, you could simplify

 import "${src}/default.nix"

to

 import "${src}"
cdfa commented 4 years ago

Hmm, allright. I had not come across it so far. Thanks for the suggestion :)

ryantm commented 4 years ago

One example you must have come across is nixpkgs :)

cdfa commented 4 years ago

Hahaha, fair.😅