DavHau / nix-portable

Nix - Static, Permissionless, Installation-free, Pre-configured
MIT License
788 stars 29 forks source link

A way to update nixpkgs #26

Open yajo opened 2 years ago

yajo commented 2 years ago

I have been struggling to update the bundled nixpkgs, as it is quite old these days. I can see that using nix-channel is not supported: https://github.com/DavHau/nix-portable/blob/55feedfc61a959bafc6c944e46e3e452cffb1999/README.md?plain=1#L40-L42

Well... I just found a way to do it, and wanted to share it in case it helps adding that support.

# nix-portable comes like this:
~> nix-portable nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
"20.09pre-git"

# Let's try to update it:
~> nix-portable nix-channel --add https://nixos.org/channels/nixos-21.11 nixpkgs
~> nix-portable nix-channel --update
unpacking channels...

# It didn't work:
~> nix-portable nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
"20.09pre-git"

# Now, the magic:
~> ln -sf ../../.nix-defexpr/channels/nixpkgs ~/.nix-portable/channels/nixpkgs 
~> nix-portable nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
"21.11.335037.e67c94a1adb"

IIUC, by shipping that symlink out of the box, we'd get usable nix-channel!

ZiWenWangCS commented 1 year ago

Hi yajo, this didn't work for me, my is still "20.09pre-git". Also I think you meant ('~' instead of '../../'): ~> ln -sf ~/.nix-defexpr/channels/nixpkgs ~/.nix-portable/channels/nixpkgs

DavHau commented 1 year ago

It is updated on master. There is just no release yet as we still have a breakage inside docker environments. If you don't care about that feel free to just build a binary yourself from the flake on master

a-zen commented 1 year ago

@DavHau so newer versions won't work in docker anymore? :(