mirror of
https://github.com/NixOS/nix.git
synced 2024-11-24 15:52:30 +00:00
21655a70f5
Nix expressions. To subscribe to a channel (needs to be done only once): nix-channel --add \ http://catamaran.labs.cs.uu.nl/dist/nix/channels/nixpkgs-unstable This just adds the given URL to ~/.nix-channels (which can also be edited manually). To update from all channels: nix-channel --update This fetches the latest expressions and pulls cache manifests. The default Nix expression (~/.nix-defexpr) is made to point to the conjunction of the expressions downloaded from all channels. So to update all installed derivations in the current user environment: nix-channel --update nix-env --upgrade '*' If you are really courageous, you can put this in a cronjob or something. You can subscribe to multiple channels. It is not entirely clear what happens when there are name clashes between derivations from different channels. From nix-env/main.cc it appears that the one with the lowest (highest?) hash will be used, which is pretty meaningless.
38 lines
893 B
Plaintext
38 lines
893 B
Plaintext
#! @shell@ -e
|
|
|
|
url=$1
|
|
|
|
if test -z "$url"; then
|
|
echo "syntax: nix-prefetch-url URL" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# !!! race? should be relatively safe, `svn export' barfs if $tmpPath exists.
|
|
tmpPath1=@storedir@/nix-prefetch-url-$$
|
|
|
|
# Perform the checkout.
|
|
@curl@ --fail --location --max-redirs 20 "$url" > $tmpPath1
|
|
|
|
# Compute the hash.
|
|
hash=$(@bindir@/nix-hash --flat $tmpPath1)
|
|
echo "hash is $hash" >&2
|
|
|
|
# Rename it so that the fetchsvn builder can find it.
|
|
tmpPath2=@storedir@/nix-prefetch-url-$hash
|
|
test -e $tmpPath2 || mv $tmpPath1 $tmpPath2 # !!! race
|
|
|
|
# Create a Nix expression that does a fetchsvn.
|
|
storeExpr=$( \
|
|
echo "(import @datadir@/nix/corepkgs/fetchurl) \
|
|
{url = $url; md5 = \"$hash\"; system = \"@system@\";}" \
|
|
| nix-instantiate -)
|
|
|
|
# Realise it.
|
|
finalPath=$(nix-store -qnB --force-realise $storeExpr)
|
|
|
|
echo "path is $finalPath" >&2
|
|
|
|
rm -rf $tmpPath2 || true
|
|
|
|
echo $hash
|