Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input=path:./<some> does not resolve as flake.nix-relative path if no flake.lock is present (upstream nix issue) #140

Open
benneti opened this issue Feb 26, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@benneti
Copy link
Contributor

benneti commented Feb 26, 2021

add an input to pkgs/flake.nix, try to run a nix command from outside the devos/nixos configuration repository.
making it into an absolute path fixes it but will probably provide issues when installing.

sudo nixos-rebuild test --flake "/etc/nixos#$(hostname)" && rm result
[sudo] password for benneti:
warning: Git tree '/etc/nixos' is dirty
building the system configuration...
warning: Git tree '/etc/nixos' is dirty
error: --- SysError ------------------------------------------------------------------------------------------------------------------------------------------------------ nix
getting status of '/home/benneti/pkgs': No such file or directory

This will probably be an easy fix as soon as one of the upstream projects provides a solution; relevant links:
NixOS/nix#4218
edolstra/flake-compat#18

also I think the added convenience for updates even now outweighs the issue to have to cd into the nix store to do updates and so on.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@benneti benneti added the bug Something isn't working label Feb 26, 2021
@benneti
Copy link
Contributor Author

benneti commented Feb 26, 2021

Some further short commings are that we cannot use this for arbitrary files (I tried it for an AppImage) and also go modules seem to lead to problems (I think they dislike that the source is read only).

@nrdxp
Copy link
Collaborator

nrdxp commented Feb 26, 2021

There is an issue with the lock file not updating on pkg/flake.nix automatically. Have you ran flk update srcs after adding your input? I ask, because I don't seem to be experiencing this issue as srcs is locked to a /nix/store location

@benneti
Copy link
Contributor Author

benneti commented Feb 28, 2021

the point is the initial error won't happen with flk as then you are in the correct directory, but when I am for example in my $HOME and want to rebuild my configuration in /etc/nixos then the above happens.
The problem is that the path:. gets expanded to the current directory right now not to the directory the flake.nix file is in.

@nrdxp
Copy link
Collaborator

nrdxp commented Feb 28, 2021

I understand, I was asking for some additional context because this isn't happening when I try to replicate. I figured the first possibility is that the lock file has not been updated.

@benneti
Copy link
Contributor Author

benneti commented Mar 1, 2021

Ah sorry, I misunderstood in that case.
Indeed if the flake is up to date it works as expected, still it is surprising that the . in the flake input is expanded to $pwd in the inputs and in the remaining nix parts is expanded to relative directories to the files:
The more correct problem in this case would be, that . in the root of the flake should be expanded to the FLAKE-URL not to $pwd, or is this a wrong assumption on my end?
(But as I said I am not sure whether anything in devos is at fault here or something upstream does not behave as I expect or I did something funky)

nix flake update --update-input "srcs" "/etc/nixos/"
Found existing alias for "nix". You should use: "n"
error (ignored): error: --- Error --------------------------------------------------------------------------------------------------------------------------------------------------------- nix
bad archive: input doesn't look like a Nix archive
error: --- SysError ------------------------------------------------------------------------------------------------------------------------------------------------------ nix
getting status of '/home/benneti/pkgs': No such file or directory

@nrdxp
Copy link
Collaborator

nrdxp commented Mar 1, 2021

This is definitely an upstream issue with Nix. A flake should always consider a relative path from it's root dir, for purities sake. I'll file an upstream issue on this at some point. Just want to see if perhaps I can dig up a fix first.

@benneti
Copy link
Contributor Author

benneti commented Mar 2, 2021

Ok, this was basically my question, whether it was triggered by something in devos I overlooked or was a problem upstream.

@blaggacao blaggacao changed the title new pkgs/flake.nix leads to sideeffects depending on pwd input=path:./<some> does not resolve as relative paht if no flake.lock is present (upstream nix issue) Apr 26, 2021
@blaggacao blaggacao changed the title input=path:./<some> does not resolve as relative paht if no flake.lock is present (upstream nix issue) input=path:./<some> does not resolve as flake.nix-relative path if no flake.lock is present (upstream nix issue) Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants