flake: cleanup, indentation, comments

pull/85/head
mwojcik 2022-01-27 14:48:37 +08:00
parent 8497f9746b
commit e81d020e90
1 changed files with 110 additions and 111 deletions

221
flake.nix
View File

@ -8,7 +8,6 @@
let let
pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import mozilla-overlay) ]; }; pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import mozilla-overlay) ]; };
# ==== rustPlatform
rustManifest = pkgs.fetchurl { rustManifest = pkgs.fetchurl {
url = "https://static.rust-lang.org/dist/2021-01-29/channel-rust-nightly.toml"; url = "https://static.rust-lang.org/dist/2021-01-29/channel-rust-nightly.toml";
sha256 = "sha256-EZKgw89AH4vxaJpUHmIMzMW/80wAFQlfcxRoBD9nz0c="; sha256 = "sha256-EZKgw89AH4vxaJpUHmIMzMW/80wAFQlfcxRoBD9nz0c=";
@ -26,120 +25,120 @@
rustc = rust; rustc = rust;
cargo = rust; cargo = rust;
}); });
# ==== rustPlatform / gnutoolchain
gnu-platform = "arm-none-eabi";
binutils-pkg = { zlib, extraConfigureFlags ? [] }: pkgs.stdenv.mkDerivation rec { gnu-platform = "arm-none-eabi";
basename = "binutils";
version = "2.30"; binutils-pkg = { zlib, extraConfigureFlags ? [] }: pkgs.stdenv.mkDerivation rec {
name = "${basename}-${gnu-platform}-${version}"; basename = "binutils";
src = pkgs.fetchurl { version = "2.30";
url = "https://ftp.gnu.org/gnu/binutils/binutils-${version}.tar.bz2"; name = "${basename}-${gnu-platform}-${version}";
sha256 = "028cklfqaab24glva1ks2aqa1zxa6w6xmc8q34zs1sb7h22dxspg"; src = pkgs.fetchurl {
}; url = "https://ftp.gnu.org/gnu/binutils/binutils-${version}.tar.bz2";
configureFlags = [ sha256 = "028cklfqaab24glva1ks2aqa1zxa6w6xmc8q34zs1sb7h22dxspg";
"--enable-deterministic-archives"
"--target=${gnu-platform}"
"--with-cpu=cortex-a9"
"--with-fpu=vfpv3"
"--with-float=hard"
"--with-mode=thumb"
] ++ extraConfigureFlags;
outputs = [ "out" "info" "man" ];
depsBuildBuild = [ pkgs.buildPackages.stdenv.cc ];
buildInputs = [ zlib ];
enableParallelBuilding = true;
meta = {
description = "Tools for manipulating binaries (linker, assembler, etc.)";
longDescription = ''
The GNU Binutils are a collection of binary tools. The main
ones are `ld' (the GNU linker) and `as' (the GNU assembler).
They also include the BFD (Binary File Descriptor) library,
`gprof', `nm', `strip', etc.
'';
homepage = http://www.gnu.org/software/binutils/;
license = pkgs.lib.licenses.gpl3Plus;
/* Give binutils a lower priority than gcc-wrapper to prevent a
collision due to the ld/as wrappers/symlinks in the latter. */
priority = "10";
};
}; };
configureFlags = [
gcc-pkg = { gmp, mpfr, libmpc, platform-binutils, extraConfigureFlags ? [] }: pkgs.stdenv.mkDerivation rec { "--enable-deterministic-archives"
basename = "gcc"; "--target=${gnu-platform}"
version = "9.1.0"; "--with-cpu=cortex-a9"
name = "${basename}-${gnu-platform}-${version}"; "--with-fpu=vfpv3"
src = pkgs.fetchurl { "--with-float=hard"
url = "https://ftp.gnu.org/gnu/gcc/gcc-${version}/gcc-${version}.tar.xz"; "--with-mode=thumb"
sha256 = "1817nc2bqdc251k0lpc51cimna7v68xjrnvqzvc50q3ax4s6i9kr"; ] ++ extraConfigureFlags;
}; outputs = [ "out" "info" "man" ];
preConfigure = '' depsBuildBuild = [ pkgs.buildPackages.stdenv.cc ];
mkdir build buildInputs = [ zlib ];
cd build enableParallelBuilding = true;
meta = {
description = "Tools for manipulating binaries (linker, assembler, etc.)";
longDescription = ''
The GNU Binutils are a collection of binary tools. The main
ones are `ld' (the GNU linker) and `as' (the GNU assembler).
They also include the BFD (Binary File Descriptor) library,
`gprof', `nm', `strip', etc.
''; '';
configureScript = "../configure"; homepage = http://www.gnu.org/software/binutils/;
configureFlags = [ license = pkgs.lib.licenses.gpl3Plus;
"--target=${gnu-platform}" /* Give binutils a lower priority than gcc-wrapper to prevent a
"--with-arch=armv7-a" collision due to the ld/as wrappers/symlinks in the latter. */
"--with-tune=cortex-a9" priority = "10";
"--with-fpu=vfpv3"
"--with-float=hard"
"--disable-libssp"
"--enable-languages=c"
"--with-as=${platform-binutils}/bin/${gnu-platform}-as"
"--with-ld=${platform-binutils}/bin/${gnu-platform}-ld" ] ++ extraConfigureFlags;
outputs = [ "out" "info" "man" ];
hardeningDisable = [ "format" "pie" ];
propagatedBuildInputs = [ gmp mpfr libmpc platform-binutils ];
enableParallelBuilding = true;
dontFixup = true;
}; };
};
newlib-pkg = { platform-binutils, platform-gcc }: pkgs.stdenv.mkDerivation rec { gcc-pkg = { gmp, mpfr, libmpc, platform-binutils, extraConfigureFlags ? [] }: pkgs.stdenv.mkDerivation rec {
pname = "newlib"; basename = "gcc";
version = "3.1.0"; version = "9.1.0";
src = pkgs.fetchurl { name = "${basename}-${gnu-platform}-${version}";
url = "ftp://sourceware.org/pub/newlib/newlib-${version}.tar.gz"; src = pkgs.fetchurl {
sha256 = "0ahh3n079zjp7d9wynggwrnrs27440aac04340chf1p9476a2kzv"; url = "https://ftp.gnu.org/gnu/gcc/gcc-${version}/gcc-${version}.tar.xz";
}; sha256 = "1817nc2bqdc251k0lpc51cimna7v68xjrnvqzvc50q3ax4s6i9kr";
nativeBuildInputs = [ platform-binutils platform-gcc ];
configureFlags = [
"--target=${gnu-platform}"
"--with-cpu=cortex-a9"
"--with-fpu=vfpv3"
"--with-float=hard"
"--with-mode=thumb"
"--enable-interwork"
"--disable-multilib"
"--disable-newlib-supplied-syscalls"
"--with-gnu-ld"
"--with-gnu-as"
"--disable-newlib-io-float"
"--disable-werror"
];
dontFixup = true;
}; };
gnutoolchain = rec { preConfigure = ''
binutils-bootstrap = pkgs.callPackage binutils-pkg { }; mkdir build
gcc-bootstrap = pkgs.callPackage gcc-pkg { cd build
platform-binutils = binutils-bootstrap; '';
extraConfigureFlags = [ "--disable-libgcc" ]; configureScript = "../configure";
}; configureFlags = [
newlib = pkgs.callPackage newlib-pkg { "--target=${gnu-platform}"
platform-binutils = binutils-bootstrap; "--with-arch=armv7-a"
platform-gcc = gcc-bootstrap; "--with-tune=cortex-a9"
}; "--with-fpu=vfpv3"
binutils = pkgs.callPackage binutils-pkg { "--with-float=hard"
extraConfigureFlags = [ "--with-lib-path=${newlib}/arm-none-eabi/lib" ]; "--disable-libssp"
}; "--enable-languages=c"
gcc = pkgs.callPackage gcc-pkg { "--with-as=${platform-binutils}/bin/${gnu-platform}-as"
platform-binutils = binutils; "--with-ld=${platform-binutils}/bin/${gnu-platform}-ld" ] ++ extraConfigureFlags;
extraConfigureFlags = [ "--enable-newlib" "--with-headers=${newlib}/arm-none-eabi/include" ]; outputs = [ "out" "info" "man" ];
}; hardeningDisable = [ "format" "pie" ];
propagatedBuildInputs = [ gmp mpfr libmpc platform-binutils ];
enableParallelBuilding = true;
dontFixup = true;
};
newlib-pkg = { platform-binutils, platform-gcc }: pkgs.stdenv.mkDerivation rec {
pname = "newlib";
version = "3.1.0";
src = pkgs.fetchurl {
url = "ftp://sourceware.org/pub/newlib/newlib-${version}.tar.gz";
sha256 = "0ahh3n079zjp7d9wynggwrnrs27440aac04340chf1p9476a2kzv";
}; };
# ==== gnutoolchain/cargo-xbuild nativeBuildInputs = [ platform-binutils platform-gcc ];
configureFlags = [
"--target=${gnu-platform}"
"--with-cpu=cortex-a9"
"--with-fpu=vfpv3"
"--with-float=hard"
"--with-mode=thumb"
"--enable-interwork"
"--disable-multilib"
"--disable-newlib-supplied-syscalls"
"--with-gnu-ld"
"--with-gnu-as"
"--disable-newlib-io-float"
"--disable-werror"
];
dontFixup = true;
};
gnutoolchain = rec {
binutils-bootstrap = pkgs.callPackage binutils-pkg { };
gcc-bootstrap = pkgs.callPackage gcc-pkg {
platform-binutils = binutils-bootstrap;
extraConfigureFlags = [ "--disable-libgcc" ];
};
newlib = pkgs.callPackage newlib-pkg {
platform-binutils = binutils-bootstrap;
platform-gcc = gcc-bootstrap;
};
binutils = pkgs.callPackage binutils-pkg {
extraConfigureFlags = [ "--with-lib-path=${newlib}/arm-none-eabi/lib" ];
};
gcc = pkgs.callPackage gcc-pkg {
platform-binutils = binutils;
extraConfigureFlags = [ "--enable-newlib" "--with-headers=${newlib}/arm-none-eabi/include" ];
};
};
cargo-xbuild = rustPlatform.buildRustPackage rec { cargo-xbuild = rustPlatform.buildRustPackage rec {
pname = "cargo-xbuild"; pname = "cargo-xbuild";
version = "0.6.5"; version = "0.6.5";
@ -159,7 +158,7 @@
maintainers = with maintainers; [ johntitor xrelkd ]; maintainers = with maintainers; [ johntitor xrelkd ];
}; };
}; };
# ==== cargo-xbuild/mkbootimage
mkbootimage = pkgs.stdenv.mkDerivation { mkbootimage = pkgs.stdenv.mkDerivation {
pname = "mkbootimage"; pname = "mkbootimage";
version = "2.2"; version = "2.2";
@ -182,7 +181,7 @@
cp mkbootimage $out/bin cp mkbootimage $out/bin
''; '';
}; };
# ==== mkbootimage/fsbl
fsbl = { board ? "zc706" }: pkgs.stdenv.mkDerivation { fsbl = { board ? "zc706" }: pkgs.stdenv.mkDerivation {
name = "${board}-fsbl"; name = "${board}-fsbl";
src = pkgs.fetchFromGitHub { src = pkgs.fetchFromGitHub {
@ -213,7 +212,7 @@
doCheck = false; doCheck = false;
dontFixup = true; dontFixup = true;
}; };
# ==== fsbl/default
cargoSha256Experiments = "1bvffgr4588bbkjwnhim8rvkjvbnajaiv7hc98b19sr8kb7rcj63"; cargoSha256Experiments = "1bvffgr4588bbkjwnhim8rvkjvbnajaiv7hc98b19sr8kb7rcj63";
cargoSha256SZL = "13022ssk6s2fgxmmh5msbx01fzcmk2cj95fjpxcsmfy14k9wd77l"; cargoSha256SZL = "13022ssk6s2fgxmmh5msbx01fzcmk2cj95fjpxcsmfy14k9wd77l";