-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
So I've been fighting through an install since I feel that nixos is the only sane distro out there nowadays. However, whilst going through the install, it dies at the download of the most important mail client evar... (as well as other tarballs)
"""
nixos-install
...
building path(s) `/nix/store/821xq4fwx0pdkix0z4x3lizanikxms10-mutt-1.5.22.tar.gz'
trying ftp://ftp.mutt.org/mutt/devel/mutt-1.5.22.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:02:06 --:--:-- 0curl: (7) Failed to connect to ftp.mutt.org port 21: Connection timed out
error: cannot download mutt-1.5.22.tar.gz from any mirror
builder for /nix/store/jaydqqsxhqgg5vwgi8g0fqf1ia1przp0-mutt-1.5.22.tar.gz.drv' failed with exit code 1 building path(s)
/nix/store/2d2lmdrj0695xcqij9qglsfdfb16cnw7-at_3.1.14.orig.tar.gz'
cannot build derivation /nix/store/i1vbr6r87hij1x2frad6xir6rf9qml14-mutt-1.5.22.drv': 1 dependencies couldn't be built cannot build derivation
/nix/store/a0k0nzbiqvh72ziq2w5jmiyk2pjrkdc1-system-path.drv': 1 dependencies couldn't be built
cannot build derivation /nix/store/nd76bd34ali8pz519vv45sx8b4s4gb9w-nixos-14.04.610.71c13be.drv': 1 dependencies couldn't be built error: build of
/nix/store/nd76bd34ali8pz519vv45sx8b4s4gb9w-nixos-14.04.610.71c13be.drv' failed
"""
Which is fine. I was informed that you can use nix-prefetch-url with file:// to download it to the store so the installer picks it up.
"""
curl --location -k (whee) -O https://mirror/mutt-1.5.22.tar.gz
nix-prefetch-url file:///root/mutt-1.5.22.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3693k 100 3693k 0 0 529M 0 --:--:-- --:--:-- --:--:-- 529M
path is ‘/nix/store/821xq4fwx0pdkix0z4x3lizanikxms10-mutt-1.5.22.tar.gz’
19zk81spnb0gc8y5mwmcfn33g77wv1xz5bmgic8aan07xn8fislg
"""
oh, but my base is at /mnt/nix/store. The nix-store manpage says the NIX_STORE_DIR variable can be used to add the file to a different store.
"""
NIX_STORE_DIR=/mnt/nix/store nix-prefetch-url file:///root/mutt-1.5.22.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3693k 100 3693k 0 0 376M 0 --:--:-- --:--:-- --:--:-- 376M
path is ‘/mnt/nix/store/vgsqzv81yyaimgbaa8yh4kw590mlsjvk-mutt-1.5.22.tar.gz’
19zk81spnb0gc8y5mwmcfn33g77wv1xz5bmgic8aan07xn8fislg
"""
However, the second path is incorrect as nixos-install is looking for {/mnt}/nix/store/821xq4fwx0pdkix0z4x3lizanikxms10-mutt-1.5.22.tar.gz
This led me to believe that the hash is being determined not only by the filename or it's contents, but also the store path which would imply that NIX_STORE_DIR cannot be used with nix-prefetch-url. As a test, I ran nix-store to store an empty file since by looking at the code nix-prefetch-url just calls nix-store to stash it .
"""
mkdir dir1 dir2
touch empty
NIX_STORE_DIR=~/dir1 nix-store --add empty
/root/dir1/91zzq5zgxs5pkb6k9x3wlb5hnb2984ns-empty
NIX_STORE_DIR=~/dir2 nix-store --add empty
/root/dir2/fp47ylqji68kmad0mqrc5ny9dwz6hpgy-empty
dd if=/dev/zero of=empty count=1 bs=1
1+0 records in
1+0 records out
1 byte (1 B) copied, 0.000739335 s, 1.4 kB/s
NIX_STORE_DIR=~/dir1 nix-store --add empty
/root/dir1/94m6wbyzp9q0xxyc834ywh42kzpnb5cn-empty
NIX_STORE_DIR=~/dir2 nix-store --add empty
/root/dir2/c86lj0ks91l92lgjdkyc9b77ysbwgdid-empty
"""
So, at this point I looked at how the store was implemented in src/libstore/store-api.cc and confirmed it depended on settings.nixStore when executing makeStorePath. This appears wrong to me as the store's location shouldn't need be known by the package, but I'm not the developer so there was probably some other intention..
So, I tried chrooting to /mnt. Ensured that nix-store was there and nix-prefetch-url was there.
"""
cp -r /nix/store/*nix-1.7 /mnt/root/nix-1.7
cp $(which nix-prefetch-url) /mnt/root/
cp $(which mv) /mnt/root
chroot /mnt bin/sh
sh-4.2# cd /root
sh-4.2# cd 1.7
sh-4.2# bin/nix-store --add /root/mutt.gz
/nix/store/1ppr5na1qywcbb1ykk9q1d6zmx3ffgff-mutt-1.5.22.tar.gz
sh-4.2# echo gahhhh
sh-4.2# /root/nix-prefetch-url file:///root/mutt-1.5.22.tar.gz
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "",
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3693k 100 3693k 0 0 1403M 0 --:--:-- --:--:-- --:--:-- 1403M
path is ‘/nix/store/821xq4fwx0pdkix0z4x3lizanikxms10-mutt-1.5.22.tar.gz’
19zk81spnb0gc8y5mwmcfn33g77wv1xz5bmgic8aan07xn8fislg
"""
Whilst being a newborn distribution, one has to expect and plan for nixpkgs to be outdated until more and more maintainers begin to appear. So I expect this problem to happen to happen to others other than myself.
What is the correct way to call nix-prefetch-url in order to get nixos-install to pick up a file that you want to provide when a mirror for a nixpkgs is outdated or expired? Manually chrooting and copying tools to the filesystem as I have? Why does nix-store --add and nix-prefetch-url generated entirely different hashes for the same file contents?