You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not opening this as an issue, because I'm not totally sure if it is an issue or potentially a botched understanding of mine of flake.nix and default.nix.
I already started getting into Nix before zero-to-nix came along, so I know a little bit, but this knowledge unfortunately confused me quite a lot during the first chapters of the quick start guide.
It used the nixpkgs#ponysay flake reference to pull in some Nix code and targeted a specific flake output (more on this later).
As someone who has already started learning a little bit of Nix, this was very confusing, because most resources are starting with default.nix, so I was interested how a complete flake.nix would look like in this case, so I went to https://search.nixos.org/flakes? to search for ponysay and didn't find it there. Going to https://github.com/erkin/ponysay also didn't show me a flake.nix so I already was confused where the flake of ponysay was located.
Let's start by building bat, a syntax-highlighted version of cat written in Rust, using Nix in an empty directory:
mkdir build-nix-package && cd build-nix-package
nix build "nixpkgs#bat"
Here, nixpkgs is a flake reference to the NixOS/nixpkgs repository on GitHub, while #bat indicates that we're building the bat output from the Nixpkgs flake.
The same thing in this example, I was unable to find a batflake.nix when searching on nixos.org. Following the link https://github.com/NixOS/nixpkgs also didn't show me a flake.nix for bat, the only thing I found was the default.nix for bat, which is not a flake. At first I thought that maybe nix run is "backwards compatible" with default.nix so I tried to run it manually, which of course did not work.
It took me quite a while before I figured out (I think?) why this actually works, even though bat hasn't any flake.nix file anywhere.
So my question is if it potentially may be a good idea to add a disclosure somewhere which explains this or makes it more clear that nix run is not actually loading the default.nix of the corresponding package but that it is loaded via the flake.nix in the root of the nixpkgs repo (which in turn loads /pkgs/release.nix which loads all the package definitions).
Again, it is not impossible that my confusion came from a misunderstanding of some of the things I already learned previously about Nix, so I wanted to start this discussion.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm not opening this as an issue, because I'm not totally sure if it is an issue or potentially a botched understanding of mine of flake.nix and default.nix.
I already started getting into Nix before zero-to-nix came along, so I know a little bit, but this knowledge unfortunately confused me quite a lot during the first chapters of the quick start guide.
Ex. on https://zero-to-nix.com/start/nix-run:
https://zero-to-nix.com/start/nix-run
...
As someone who has already started learning a little bit of Nix, this was very confusing, because most resources are starting with default.nix, so I was interested how a complete flake.nix would look like in this case, so I went to https://search.nixos.org/flakes? to search for ponysay and didn't find it there. Going to https://github.com/erkin/ponysay also didn't show me a flake.nix so I already was confused where the flake of ponysay was located.
Ex. on https://zero-to-nix.com/start/nix-build-nixpkgs:
The same thing in this example, I was unable to find a bat flake.nix when searching on nixos.org. Following the link https://github.com/NixOS/nixpkgs also didn't show me a flake.nix for bat, the only thing I found was the default.nix for bat, which is not a flake. At first I thought that maybe
nix run
is "backwards compatible" with default.nix so I tried to run it manually, which of course did not work.It took me quite a while before I figured out (I think?) why this actually works, even though bat hasn't any flake.nix file anywhere.
So my question is if it potentially may be a good idea to add a disclosure somewhere which explains this or makes it more clear that
nix run
is not actually loading the default.nix of the corresponding package but that it is loaded via the flake.nix in the root of the nixpkgs repo (which in turn loads /pkgs/release.nix which loads all the package definitions).Again, it is not impossible that my confusion came from a misunderstanding of some of the things I already learned previously about Nix, so I wanted to start this discussion.
Beta Was this translation helpful? Give feedback.
All reactions