[solved] nix shell and nix profile not using the branch defined in flake.nix?

Yes I know that there are workarounds for them to set to use the flake inputs but still… I have set nixpkgs version to 23.11 stable release and that’s good, but if I try to use nix shell, nix profile or even nix-env, they all seem to use the latest master/unstable branch to install the packages by default.

Just want to know why aren’t they just default to use whatever is defined in flake.nix file? <OR> will it be implemented to use it by default in the near future?

Reason as to why I am asking -> This is what I am using to match nix shell and flake inputs, but as you can see they are just workarounds, plus seem to cause more errors and whatnot, plus by ideology one shouldn’t need to specially define it to use some version when everything is already defined.

mobsenpai,
@mobsenpai@lemmy.world avatar

Its solved, see the mentioned link.

hallettj, (edited )
@hallettj@leminal.space avatar

It’s possible (and I think advisable) to set your flake nixos config to set the system flake registry to point to the same nixpkgs revision that your flake uses. The nixos-starter-configs standard template has two lines that do this:


<span style="color:#323232;"># Opinionated: make flake registry and nix path match flake inputs
</span><span style="color:#323232;">registry = lib.mapAttrs (_: flake: {inherit flake;}) flakeInputs;
</span><span style="color:#323232;">nixPath = lib.mapAttrsToList (n: _: "${n}=flake:${n}") flakeInputs;
</span>

That actually adds all of your flake inputs to the system flake registry. So for example if in addition to your nixpkgs input you also have an input you named nixpkgs-unstable then can also reference that with stuff like nix shell. For example:


<span style="color:#323232;">nix shell nixpkgs#hello nixpkgs-unstable#cowsay
</span>
mobsenpai,
@mobsenpai@lemmy.world avatar

Yeah that’s what I am using currently but I was told that by default it follows whatever nixpkgs version is in flake.nix and doing the registry thing is an extra step to make it more systematic. For now I will keep using that.

rutrum, (edited )
@rutrum@lm.paradisus.day avatar

You want to look at the registry. Run nix registry list. You’ll see that nixpkgs by default points to unstable. You override this in your config. I’ve done that, where nixpkgs is stable and “unstable” is unstable.

EDIT: heres part of my home manager config that changes this: github.com/rutrum/dots/blob/master/…/nix.nix#L15

mobsenpai,
@mobsenpai@lemmy.world avatar

Yeah mine also shows global flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-unstable instead of what I have defined in flake.nix i.e 23.11

  • All
  • Subscribed
  • Moderated
  • Favorites
  • nix@programming.dev
  • ethstaker
  • DreamBathrooms
  • ngwrru68w68
  • magazineikmin
  • InstantRegret
  • everett
  • thenastyranch
  • Youngstown
  • rosin
  • slotface
  • modclub
  • khanakhh
  • kavyap
  • Durango
  • JUstTest
  • osvaldo12
  • cubers
  • Leos
  • mdbf
  • tacticalgear
  • normalnudes
  • tester
  • GTA5RPClips
  • provamag3
  • cisconetworking
  • anitta
  • megavids
  • lostlight
  • All magazines