nixpkgs/pkgs/stdenv/linux/bootstrap/loongson2f/default.nix
Shea Levy 986f361946 linux/bootstrap: Use <nix/fetchurl> to get the static binaries
Since nix-1.4, nix's corepkgs contain a fetchurl suitable for
downloading the bootstrap binaries. Doing this will allow us to have a
nixpkgs with no in-tree binaries without breaking the purity of the
bootstrap (though for now, they are fetched in-tree until the binaries
are added to nixos.org somewhere). As an additional small benefit, the
in-tree binaries do not have to be hashed on every instantiation as they
do now.

The fetchurl in nix-1.2 and 1.3 isn't able to make binaries executable,
so it can't be used for this case. In that case, attempting to build the
bootstrap will show a message asking the user to manually download each
file and add it to the store with nix-store --add (but the hash is
ultimately the same, of course).

Signed-off-by: Shea Levy <shea@shealevy.com>
2013-05-05 11:30:34 -04:00

70 lines
1.7 KiB
Nix

let
fetch = { file, sha256 }:
let
nixFetchurl = import <nix/fetchurl.nix>;
args = {
url = "file://${builtins.toString ./.}/${file}";
inherit sha256;
executable = true;
};
in if (builtins.functionArgs nixFetchurl) ? executable
then nixFetchurl args
else derivation {
name = file;
builder = "/bin/sh";
system = builtins.currentSystem;
args = [ "-c" "echo $message; exit 1" ];
message = ''
Sorry, this version of nix cannot download all of the bootstrap tools.
Please download ${args.url}, make it executable, add it to the store
with `nix-store --add', and try again.
'';
outputHashAlgo = "sha256";
outputHash = args.sha256;
outputHashMode = "recursive";
preferLocalBuild = true;
};
in {
sh = fetch {
file = "sh";
sha256 = "02jjl49wdq85pgh61aqf78yaknn9mi3rcspbpk7hs9c4mida2rhf";
};
bzip2 = fetch {
file = "bzip2";
sha256 = "1qn27y3amj9c6mnjk2kyb59y0d2w4yv16z9apaxx91hyq19gf29z";
};
mkdir = fetch {
file = "mkdir";
sha256 = "1vbp2bv9hkyb2fwl8hjrffpywn1wrl1kc4yrwi2lirawlnc6kymh";
};
cpio = fetch {
file = "cpio";
sha256 = "0mqxwdx0sl7skxx6049mk35l7d0fnibqsv174284kdp4p7iixwa0";
};
ln = fetch {
file = "ln";
sha256 = "05lwx8qvga3yv8xhs8bjgsfygsfrcxsfck0lxw6gsdckx25fgi7s";
};
curl = fetch {
file = "curl.bz2";
sha256 = "0iblnz4my54gryac04i64fn3ksi9g3dx96yjq93fj39z6kx6151c";
};
bootstrapTools = {
url = "http://nixos.org/tarballs/stdenv-linux/loongson2f/r22849/cross-bootstrap-tools.cpio.bz2";
sha256 = "00aavbk76qjj2gdlmpaaj66r8nzl4d7pyl8cv1gigyzgpbr5vv3j";
};
}