nmattia / niv

Easy dependency management for Nix projects
https://github.com/nmattia/niv
MIT License
1.58k stars 77 forks source link

niv tries to unpack local dependency #337

Open yaitskov opened 2 years ago

yaitskov commented 2 years ago

Hi, niv revision "e0ca65c81a2d7a4d82a189f1e23a48d59ad42070"

sources.json:

    "prune-juice": {
        "type": "local",
        "path": "/home/dan/pro/prune-juice"
    },

Error

unpacking source archive /home/dan/pro/prune-juice
do not know how to unpack source archive /home/dan/pro/prune-juice
builder for '/nix/store/bvhjyi9p3hxi87zjl7f6xbr1xjy7yc8q-prune-juice-0.6.drv' failed with exit code 1
git clone git@github.com:dfithian/prune-juice.git

It was working before.

refnil commented 2 years ago

Hi @yaitskov ,

I made a small demo that use a local source just fine without unpacking. In fact, I don't think niv is ever unpacking any sources. I would recommend checking how you are using this prune-juice source. You could share it here so I can take a look.

{ sources ? import ./nix/sources.nix
, nixpkgs ? import sources.nixpkgs {}
, juice ? sources.juice
}:
{
  test-command = nixpkgs.writeScriptBin "test-niv" ''
    #! ${nixpkgs.bash}/bin/bash
    echo '${juice}'
  '';
}
yaitskov commented 2 years ago

How to run the snippet above?

nix-shell pj.nix

I think it is worth to mention nixpkgs repo version. I took master because I need HLS 1.4

    "nixpkgs": {
        "branch": "master",
        "description": "Nix Packages collection",
        "homepage": "",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "4217614266efccf9c5f8817532fbcbdbf31001e2",
        "sha256": "0xiiprzxm72xw0jrgr1fgz0lxkhhl0n6gk08wv2hn8l0ms5w2yl7",
        "type": "tarball",
        "url": "https://github.com/NixOS/nixpkgs/archive/4217614266efccf9c5f8817532fbcbdbf31001e2.tar.gz",
        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
    },

I suspect the issue is caused by changes in nixpkgs itself.

refnil commented 2 years ago

How to run the snippet above?

First, you should copy the script in the same folder containing the nix folder with sources.json and sources.nix. Then, you could change sources.juice in the script by sources.prune-juice to use the problematic source. To run it, you could do run it with

nix-shell -p "(import ./test.nix {}).test_command" --run test_niv

or

nix-build test.nix && result/bin/test_niv

Note that my file is named test.nix while yours is pj.nix (I think).