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

unpinned nixpkgs-unstable channel new revision downloads although I pinned nixpkgs in my shell.nix file #1401

Closed
tnielens opened this issue Jan 27, 2025 · 5 comments

Comments

@tnielens
Copy link

tnielens commented Jan 27, 2025

I'm new to nix and am interested in it for portable dev envs.

I started with the detsys nix installer and am running macos 15.1.1. I'm working a lot in large repositories and found NixOS/nix#6530 . This performance issue makes flakes unsuable for me for devenvs source controlled together with my work projects.

I fell back to classic shell.nix. Downloading newer versions of nixpkgs is very slow (around ~5minutes, a macos issue?) so I'm pinning the nixpkgs revision in our shell.nix. Despite that, new revisions from the channel nixpkgs-unstable were downloaded regularly, making for a poor experience. I resolved the issue by removing the extra-nix-path section in nix.conf, more by trial and error than understanding that configuration setting.

Not downloading latest revisions of nixpkgs-unstable in pinned shell.nix by default would make for a better experience.

shell.nix

let
  # release 24.11, pinned
  nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/archive/9b6cdf829fdef63efed466cf537c838dc685da41.tar.gz";
  pkgs = import nixpkgs { config = {}; overlays = []; };
in

pkgs.mkShellNoCC {
  packages = with pkgs; [
    yq-go
    kubernetes-helm
    bash
  ];
}

Problem reproduced at 2025-01-29T21:00, with this relevant log section for the command nix-shell --debug my-project/shell.nix

fetching flake search path element 'nixpkgs''
using cache entry 'file:{"name":"flake-registry.json","store":"/nix/store","url":"https://channels.nixos.org/flake-registry.json"}' -> '{"etag":"W/\"1d6d5f942245b7e17320219962c68f04949edf88d99fc58a5a3b076165562d30\"","storePath":"245nl9ad8inws9pi63nj5pqjdgsb4b5r-flake-registry.json","url":"https://channels.nixos.org/flake-registry.json"}'
performing daemon worker op: 11
performing daemon worker op: 1
using cache entry 'file:{"name":"flake-registry.json","store":"/nix/store","url":"https://channels.nixos.org/flake-registry.json"}' -> '{"etag":"W/\"1d6d5f942245b7e17320219962c68f04949edf88d99fc58a5a3b076165562d30\"","url":"https://channels.nixos.org/flake-registry.json"}', '/nix/store/245nl9ad8inws9pi63nj5pqjdgsb4b5r-flake-registry.json'
downloading 'https://channels.nixos.org/flake-registry.json'...
starting download of https://channels.nixos.org/flake-registry.json
finished download of 'https://channels.nixos.org/flake-registry.json'; curl status = 0, HTTP status = 304, body = 0 bytes, duration = 0.22 s
performing daemon worker op: 11
performing daemon worker op: 12
looked up 'flake:nixpkgs' -> 'github:NixOS/nixpkgs/nixpkgs-unstable'
using cache entry 'file:{"name":"source","store":"/nix/store","url":"https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable"}' -> '{"etag":"W/\"541151bfd6bb6c5c10833c5feac86a53820aee7add420fcc9dec79d602449708\"","storePath":"yc8v2zlsdgim5dnyi8mrn763hjdriwr8-source","url":"https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable"}'
performing daemon worker op: 11
performing daemon worker op: 1
using cache entry 'file:{"name":"source","store":"/nix/store","url":"https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable"}' -> '{"etag":"W/\"541151bfd6bb6c5c10833c5feac86a53820aee7add420fcc9dec79d602449708\"","url":"https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable"}', '/nix/store/yc8v2zlsdgim5dnyi8mrn763hjdriwr8-source'
downloading 'https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable'...
starting download of https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable
finished download of 'https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable'; curl status = 0, HTTP status = 200, body = 2214 bytes, duration = 0.28 s
performing daemon worker op: 39
locking path '/nix/store/428f3qq5f9ggcz2rgil2qy08ignlbkl2-source'
lock acquired on '/nix/store/428f3qq5f9ggcz2rgil2qy08ignlbkl2-source.lock'
lock released on '/nix/store/428f3qq5f9ggcz2rgil2qy08ignlbkl2-source.lock'
HEAD revision for 'github:NixOS/nixpkgs/nixpkgs-unstable' is 9a5db3142ce450045840cc8d832b13b8a2018e0c
did not find cache entry for 'gitRevToTreeHash:{"rev":"9a5db3142ce450045840cc8d832b13b8a2018e0c"}'
unpacking 'github:NixOS/nixpkgs/9a5db3142ce450045840cc8d832b13b8a2018e0c' into the Git cache...
downloading 'https://github.com/NixOS/nixpkgs/archive/9a5db3142ce450045840cc8d832b13b8a2018e0c.tar.gz'...
starting download of https://github.com/NixOS/nixpkgs/archive/9a5db3142ce450045840cc8d832b13b8a2018e0c.tar.gz```
@cole-h
Copy link
Member

cole-h commented Jan 27, 2025

If the revision is pinned, then it should not have been downloading anything other than the pinned version. extra-nix-path and NIX_PATH essentially only affect imports from angled brackets (i.e. import <nixpkgs> {}). If you pinned your Nixpkgs revision with something like builtins.fetchTarball, then it should only ever download and use that version.

If you have a shell.nix handy, I could take a look at why that's not doing what you expected.

@tnielens tnielens changed the title extra-nix-path = nixpkgs=flake:nixpkgs makes for a bad beginner experience with shell.nix shells unpinned nixpkgs-unstable channel new revision downloads although I pinned nixpkgs in my shell.nix file Jan 27, 2025
@tnielens
Copy link
Author

@cole-h thanks for the reply. I added my shell.nix file in the description above.

I forget to mention that the shell loads with nix-direnv installed with home-manager. There might be unpinned usage of nixpkgs in those tools. I'll have a further look in the debug log to locate such usage.

@tnielens
Copy link
Author

I added a log section in the description above for further details.

@tnielens
Copy link
Author

Ok I think I found a possible reason. From nix-shell --help, there is

       •  NIX_BUILD_SHELL

          Shell used to start the interactive environment. Defaults to the bash found in <nixpkgs>, falling back to the bash found in PATH if not found.

With the defaults from the installer, extra-nix-path = nixpkgs=flake:nixpkgs, this leads to frequent downloads of nixpkgs-unstable revisions.

Is this extra-nix-path configured by the detsys installer? There is maybe a better default that'd avoid the use of the unpinned nixpkgs-unstable channel.

@tnielens
Copy link
Author

tnielens commented Feb 4, 2025

Closing the issue as this is expected behavior. Can serve as input for beginner experience discussions.

@tnielens tnielens closed this as completed Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants