Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

default.nix assumes directory is under git source control #12

Closed
leotaku opened this issue Mar 29, 2019 · 9 comments
Closed

default.nix assumes directory is under git source control #12

leotaku opened this issue Mar 29, 2019 · 9 comments
Labels
more data needed Some party needs to provide more information

Comments

@leotaku
Copy link

leotaku commented Mar 29, 2019

The current default.nix file assumes that lorri is always installed from the project git directory. This causes major headaches when trying to use lorri with tools like niv or packaging it.

Maybe it would be possible to support an alternative "portable" default.nix file?

@Profpatsch
Copy link
Collaborator

Can you elaborate on your use case?

@Profpatsch Profpatsch added the more data needed Some party needs to provide more information label Mar 29, 2019
@leotaku
Copy link
Author

leotaku commented Mar 29, 2019

@Profpatsch I use the niv tool to keep my dependencies organized. It avoids downloading the entire git repository and instead just fetches the specified rev.

I prefer this approach to manually keeping several git repositories updated, because it is reproducible and requires much less maintenance.

@Profpatsch
Copy link
Collaborator

Oh, you mean src = ./.?

You can overwrite the source with an argument: nix-build …/lorri/default.nix --arg src /path/to/lorri.

@leotaku
Copy link
Author

leotaku commented Mar 29, 2019

@Profpatsch this command unfortunately fails for me.

nix-build lorri/default.nix --arg src /full/path/to/lorri
these derivations will be built:
  /nix/store/wy37hnd66xhxfd6sm9vw4p6hd95rrxpq-lorri.drv
building '/nix/store/wy37hnd66xhxfd6sm9vw4p6hd95rrxpq-lorri.drv'...
unpacking sources
unpacking source archive /nix/store/llk09dv6pvszl0gl3kzg9k96aj389615-lorri
do not know how to unpack source archive /nix/store/llk09dv6pvszl0gl3kzg9k96aj389615-lorri
builder for '/nix/store/wy37hnd66xhxfd6sm9vw4p6hd95rrxpq-lorri.drv' failed with exit code 1
error: build of '/nix/store/wy37hnd66xhxfd6sm9vw4p6hd95rrxpq-lorri.drv' failed

This is kind of my problem: There does not seem to be an obvious way to build/install lorri from a directory that isn't git version-controlled.

What does the fetchGit function achieve in default.nix?

@Profpatsch
Copy link
Collaborator

You have to replace the paths by the paths you need of course.

$ wget https://github.com/target/lorri/archive/e943fa403234f1a5e403b6fdc112e79abc1e29ba.tar.gz
$ ls
default.nix  e943fa403234f1a5e403b6fdc112e79abc1e29ba.tar.gz  lorri-e943fa403234f1a5e403b6fdc112e79abc1e29ba
$  cp -r lorri-e943fa403234f1a5e403b6fdc112e79abc1e29ba/nix lorri-e943fa403234f1a5e403b6fdc112e79abc1e29ba/default.nix .
$ nix-build default.nix --arg src ./lorri-e943fa403234f1a5e403b6fdc112e79abc1e29ba --arg pkgs 'import ./nixpkgs.nix {}'

We don’t have a .git directory in the tarball, it works.

@leotaku
Copy link
Author

leotaku commented Mar 30, 2019

Interesting. Trying to build lorri seems to fail in ways that I don't fully comprehend. I suspect it might have to do with the files being stored in the nix store, or symlinking issues. (related to my personal setup)

Still, I am interested in why lorri chooses to have fetchGit in its default.nix as I have never seen that in any other nix project.
Maybe someone could explain this to me?

In any case, this is no longer relevant to the original issue.
@Profpatsch thank you for helping me, I will now close this issue.

@leotaku leotaku closed this as completed Mar 30, 2019
@Profpatsch
Copy link
Collaborator

Still, I am interested in why lorri chooses to have fetchGit in its default.nix as I have never seen that in any other nix project.

It’s a default argument.

let f = { a ? "foo" }: a
in f {}

will be "foo", while

let f = { a ? "foo" }: a
in f { a = "bar" }

will be "bar".

You can try it out in nix repl.

@leotaku
Copy link
Author

leotaku commented Apr 2, 2019

@Profpatsch Yes I understand that. But why would you even try to fetchGit a local directory? It doesn't make sense to me.

@Profpatsch
Copy link
Collaborator

But why would you even try to fetchGit a local directory? It doesn't make sense to me.

You have to ask @grahamc ;). I agree with you that it’s not a great solution, because fetchGit caches your source for up to an hour, meaning any changes are not picked up.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
more data needed Some party needs to provide more information
Projects
None yet
Development

No branches or pull requests

2 participants