I’m a faithful user of NixOS’ traditional channel system (via nix-channel), and now I’m trying to work with flakes (because I want to use nix develop to try to debug a package). The question is: how do I use my current system nixos channel as an input in my flake?
I don’t want to pin to a specific GitHub release, I don’t want to use flake registry, I don’t want to fetch a channel independently, I just want to use the NixPkgs tree that’s already in my system, retrieved by the latest nix-channel --update. This should be easy, right? Right?..
I tried nixpkgs.url = “path:/nix/var/nix/profiles/per-user/root/channels/nixos”, it produces:
error: path '//nix/var/nix/profiles/per-user/root/channels' is a symlink
I tried nixpkgs.url = /nix/var/nix/profiles/per-user/root/channels/nixos, it produces:
error: input attribute path '/nix/var/nix/profiles/per-user/root/channels/nixos' at /nix/store/20haszddrziqlijz17p8fpgyz0w2zq7b-source/flake.nix:6:5 must be in the same source tree as /nix/store/20haszddrziqlijz17p8fpgyz0w2zq7b-source
I don’t use flakes myself if I can help it, but my understanding is that no, this is more or less prohibited by design. Flakes are intended to capture their inputs in a fully reproducible way, and a reference to the current value of your channels would violate that. In theory, maybe there could be an input type that follows channels and flake lock files could capture the URL to which the channel currently redirects. But the experimental flakes API seems to prefer ditching the concept of channels entirely.
My advice, suboptimal though it is, is to let third-party flakes do flakes things and download extra copies of Nixpkgs as they desire. Store optimization may help with the disk usage, somewhat.
Is this a learning experience or is there some technical aspect that causes you to need to use nix develop instead of nix-shell to debug a package? And/or is there a reason why you need to use a flake with nix develop?
It’s a “I had no idea what to do and was trying various things from Internet” experience.
I tried with nix-shell first, but I couldn’t get it to work. With nix develop, I was eventually able to move forward.
Is there a way to use nix develop without flake.nix? When I run nix develop, it complains that it can’t find flake.nix, so I assumed it required a flake.
I had a custom Perl package created with buildPerlPackage that started failing tests under NixOS 26.05, so I wanted to manually and repeatedly run package building stages and to make changes to source files in between, in order to ultimately produce patches that would allow the package to be built.
I do not work with Perl packages but I believe that buildPerlPackage is essentially an extension of stdenv.mkDerivation so it should still have a genericBuild that looks like
# output of `declare -f genericBuild`
genericBuild ()
{
export GZIP_NO_TIMESTAMPS=1;
if [ -f "${buildCommandPath:-}" ]; then
source "$buildCommandPath";
return;
fi;
if [ -n "${buildCommand:-}" ]; then
eval "$buildCommand";
return;
fi;
definePhases;
for curPhase in ${phases[*]};
do
runPhase "$curPhase";
what I would normally do is nix-shell /path/to/package or nix-shell '<nixpkgs/default.nix>' -A package and then essentially step through phases. I personally tend to definePhases and inspect $phases then manually runPhase [phase].