flake: syntax fixup, hash update (nix develop works)

pull/85/head
mwojcik 2022-01-26 15:37:59 +08:00
parent d6e3167e44
commit 8a84d0bbf0
2 changed files with 157 additions and 120 deletions

44
flake.lock Normal file
View File

@ -0,0 +1,44 @@
{
"nodes": {
"mozilla-overlay": {
"flake": false,
"locked": {
"lastModified": 1638887313,
"narHash": "sha256-FMYV6rVtvSIfthgC1sK1xugh3y7muoQcvduMdriz4ag=",
"owner": "mozilla",
"repo": "nixpkgs-mozilla",
"rev": "7c1e8b1dd6ed0043fb4ee0b12b815256b0b9de6f",
"type": "github"
},
"original": {
"owner": "mozilla",
"repo": "nixpkgs-mozilla",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1642961095,
"narHash": "sha256-RLatktZmvwFBOyqdoIk4qdS4OGKB7aKIvvs4ZP2L8D8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "604c44137d97b5111be1ca5c0d97f6e24fbc5c2c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-21.11",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"mozilla-overlay": "mozilla-overlay",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

233
flake.nix
View File

@ -9,124 +9,119 @@
pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import mozilla-overlay) ]; }; pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import mozilla-overlay) ]; };
# ==== rustPlatform # ==== rustPlatform
let 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-T0D0ypXA+nuH7o3AHCokzSBZAvQxvef4x9+XxO3aBao="; };
targets = [];
rustChannelOfTargets = _channel: _date: targets:
(pkgs.lib.rustLib.fromManifestFile rustManifest {
inherit (pkgs) stdenv lib fetchurl patchelf;
}).rust.override {
inherit targets;
extensions = ["rust-src"];
}; };
targets = []; rust = rustChannelOfTargets "nightly" null targets;
rustChannelOfTargets = _channel: _date: targets: rustPlatform = pkgs.recurseIntoAttrs (pkgs.makeRustPlatform {
(pkgs.lib.rustLib.fromManifestFile rustManifest { rustc = rust;
inherit (pkgs) stdenv lib fetchurl patchelf; cargo = rust;
}).rust.override { });
inherit targets;
extensions = ["rust-src"];
};
rust = rustChannelOfTargets "nightly" null targets;
in
rustPlatform = pkgs.recurseIntoAttrs (pkgs.makeRustPlatform {
rustc = rust;
cargo = rust;
});
# ==== rustPlatform / gnutoolchain # ==== rustPlatform / gnutoolchain
gnutoolchain = { gnu-platform = "arm-none-eabi";
let
gnu-platform = "arm-none-eabi";
binutils-pkg = { extraConfigureFlags ? [] }: pkgs.stdenv.mkDerivation rec { binutils-pkg = { extraConfigureFlags ? [] }: pkgs.stdenv.mkDerivation rec {
basename = "binutils"; basename = "binutils";
version = "2.30"; version = "2.30";
name = "${basename}-${gnu-platform}-${version}"; name = "${basename}-${gnu-platform}-${version}";
src = pkgs.fetchurl { src = pkgs.fetchurl {
url = "https://ftp.gnu.org/gnu/binutils/binutils-${version}.tar.bz2"; url = "https://ftp.gnu.org/gnu/binutils/binutils-${version}.tar.bz2";
sha256 = "028cklfqaab24glva1ks2aqa1zxa6w6xmc8q34zs1sb7h22dxspg"; sha256 = "028cklfqaab24glva1ks2aqa1zxa6w6xmc8q34zs1sb7h22dxspg";
};
configureFlags = [
"--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 = [ pkgs.lib.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 = { 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 ];
'' buildInputs = [ pkgs.lib.zlib ];
mkdir build enableParallelBuilding = true;
cd build 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 = with pkgs.libs [ gmp mpfr libmpc platform-binutils ];
enableParallelBuilding = true;
dontFixup = true;
}; };
};
newlib-pkg = { platform-binutils, platform-gcc }: pkgs.stdenv.mkDerivation rec { gcc-pkg = { 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 pkgs.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;
}; };
in rec { preConfigure = ''
mkdir build
cd build
'';
configureScript = "../configure";
configureFlags = [
"--target=${gnu-platform}"
"--with-arch=armv7-a"
"--with-tune=cortex-a9"
"--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 = with pkgs.libs; [ 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";
};
nativeBuildInputs = [ platform-binutils pkgs.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 { }; binutils-bootstrap = pkgs.callPackage binutils-pkg { };
gcc-bootstrap = pkgs.callPackage gcc-pkg { gcc-bootstrap = pkgs.callPackage gcc-pkg {
platform-binutils = binutils-bootstrap; platform-binutils = binutils-bootstrap;
@ -143,8 +138,7 @@
platform-binutils = binutils; platform-binutils = binutils;
extraConfigureFlags = [ "--enable-newlib" "--with-headers=${newlib}/arm-none-eabi/include" ]; extraConfigureFlags = [ "--enable-newlib" "--with-headers=${newlib}/arm-none-eabi/include" ];
}; };
} };
}
# ==== gnutoolchain/cargo-xbuild # ==== gnutoolchain/cargo-xbuild
cargo-xbuild = rustPlatform.buildRustPackage rec { cargo-xbuild = rustPlatform.buildRustPackage rec {
pname = "cargo-xbuild"; pname = "cargo-xbuild";
@ -156,16 +150,15 @@
rev = "v${version}"; rev = "v${version}";
sha256 = "18djvygq9v8rmfchvi2hfj0i6fhn36m716vqndqnj56fiqviwxvf"; sha256 = "18djvygq9v8rmfchvi2hfj0i6fhn36m716vqndqnj56fiqviwxvf";
}; };
cargoLock = { cargoSha256 = "13sj9j9kl6js75h9xq0yidxy63vixxm9q3f8jil6ymarml5wkhx8";
lockFile = [ ./Cargo.lock ]
}
meta = with pkgs.lib; { meta = with pkgs.lib; {
description = "Automatically cross-compiles the sysroot crates core, compiler_builtins, and alloc"; description = "Automatically cross-compiles the sysroot crates core, compiler_builtins, and alloc";
homepage = "https://github.com/rust-osdev/cargo-xbuild"; homepage = "https://github.com/rust-osdev/cargo-xbuild";
license = with licenses; [ mit asl20 ]; license = with licenses; [ mit asl20 ];
maintainers = with maintainers; [ johntitor xrelkd ]; maintainers = with maintainers; [ johntitor xrelkd ];
}; };
} };
# ==== cargo-xbuild/mkbootimage # ==== cargo-xbuild/mkbootimage
mkbootimage = pkgs.stdenv.mkDerivation { mkbootimage = pkgs.stdenv.mkDerivation {
pname = "mkbootimage"; pname = "mkbootimage";
@ -188,7 +181,7 @@
mkdir -p $out/bin mkdir -p $out/bin
cp mkbootimage $out/bin cp mkbootimage $out/bin
''; '';
} };
# ==== mkbootimage/fsbl # ==== mkbootimage/fsbl
fsbl = { board ? "zc706" }: pkgs.stdenv.mkDerivation { fsbl = { board ? "zc706" }: pkgs.stdenv.mkDerivation {
name = "${board}-fsbl"; name = "${board}-fsbl";
@ -219,7 +212,7 @@
''; '';
doCheck = false; doCheck = false;
dontFixup = true; dontFixup = true;
} };
# ==== fsbl/ # ==== fsbl/
in { in {
packages.x86_64-linux = { packages.x86_64-linux = {
@ -241,8 +234,8 @@
openocd gdb openocd gdb
openssh rsync openssh rsync
llvmPackages_9.clang-unwrapped llvmPackages_9.clang-unwrapped
mkbootimage mkbootimage ];
}; };
defaultPackage.x86_64-linux = zynq-rs; defaultPackage.x86_64-linux = fsbl { board = "zc706"; };
}; };
} }