Closed tcurdt closed 7 months ago
What is the output of the following commands?
printenv NIX_PATH
nix-instantiate --eval --expr '<nixpkgs>'
# printenv NIX_PATH
/root/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
# nix-instantiate --eval --expr '<nixpkgs>'
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos' does not exist, ignoring
error:
… while calling the 'findFile' builtin
at «string»:1:1:
1| <nixpkgs>
| ^
error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)
Looking at this, it feels more like a newbie (me) getting stuck in between channels and flakes rather than a nix-init
problem.
Why do you think that's the problem? Did you remove any channels?
EDIT: Also why running the commands as root (#) ?
Why do you think that's the problem? Did you remove any channels?
My channels were empty at some stage. The system is setup via flake. But I re-added unstable to give it a try.
nix-channel --list
unstable https://nixos.org/channels/nixpkgs-unstable
# nix-channel --update
But that didn't help
EDIT: Also why running the commands as root (#) ?
No particular reason. It's just a throw-away vm for now.
But I am getting the same error as user
[tcurdt@nixos:~]$ nix-instantiate --eval --expr '<nixpkgs>'
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos' does not exist, ignoring
error:
… while calling the 'findFile' builtin
at «string»:1:1:
1| <nixpkgs>
| ^
error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)
TBH I don't understand the per-user/root
when I am user tcurdt
Root's channels are propagated to regular users
This helped
$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
$ nix-channel --list
nixpkgs https://nixos.org/channels/nixpkgs-unstable
$ nix-channel --update nixpkgs
$ nix-instantiate --eval --expr '<nixpkgs>'
/root/.nix-defexpr/channels/nixpkgs
Can't say I understand the problem/fix yet, but I now have a default.nix
🥳
{ lib
, buildGoModule
, fetchFromGitHub
}:
buildGoModule rec {
pname = "release-go";
version = "1.0.3";
src = fetchFromGitHub {
owner = "tcurdt";
repo = "release-go";
rev = "v${version}";
hash = "sha256-Ai4uvLkl4e4Z6x1wZb5BzpLvWhxHhg4D1QpCdSjwQ5I=";
};
vendorHash = null;
ldflags = [
"-s"
"-w"
"-X=main.version=${version}"
"-X=main.commit=${src.rev}"
"-X=main.date=1970-01-01T00:00:00Z"
"-X=main.treeState=false"
"-X=main.builtBy=goreleaser"
];
meta = with lib; {
description = "";
homepage = "https://github.com/tcurdt/release-go";
license = licenses.unfree; # FIXME: nix-init did not find a license
maintainers = with maintainers; [ ];
mainProgram = "release-go";
};
}
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/making-packages-projects-available-to-nixos/38462/4
Should the issue be closed?
I am still stuck actually getting the build to work - but that's probably another more unrelated matter. Let's close it.
I am trying to generate a first nix config from a go project.
What's the problem?