diff options
| author | Alejandro Soto <alejandro@34project.org> | 2023-09-24 20:47:46 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2023-09-24 20:47:46 -0600 |
| commit | 146168ca340e435eae6e30e99c06d752719089e3 (patch) | |
| tree | e55220866c94f1a92b5ed34a4b193fbad70d405b /nix/flake.nix | |
| parent | 1e08b138f47d52a48ae7fb3534e92221c85e950d (diff) | |
nix/flake: enable formatter
Diffstat (limited to '')
| -rw-r--r-- | nix/flake.nix | 290 |
1 files changed, 148 insertions, 142 deletions
diff --git a/nix/flake.nix b/nix/flake.nix index fd5de00..582a15d 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -1,152 +1,158 @@ { - outputs = { self, nixpkgs }: let - system = "x86_64-linux"; - pkgs = import nixpkgs { inherit system; config.allowUnfree = true; }; - - crossSystem = "arm-linux"; - cross = import nixpkgs { - inherit system; - - config.allowUnsupportedSystem = true; - - crossSystem = { - config = "arm-unknown-linux-gnueabi"; - - gcc = { - # > Switch "--with-arch" may not be used with switch "--with-cpu" - # > make[1]: *** [Makefile:4315: configure-gcc] Error 1 - #arch = "armv4"; - - # Ver SA110 en arch/arm/mm/Kconfig, es parecido - cpu = "arm810"; - }; - - linux-kernel = { - name = "taller"; - target = "uImage"; - makeFlags = [ "LOADADDR=0x8000" ]; - autoModules = false; - baseConfig = "taller_defconfig"; + outputs = { self, nixpkgs }: + let + system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; config.allowUnfree = true; }; + + crossSystem = "arm-linux"; + cross = import nixpkgs { + inherit system; + + config.allowUnsupportedSystem = true; + + crossSystem = { + config = "arm-unknown-linux-gnueabi"; + + gcc = { + # > Switch "--with-arch" may not be used with switch "--with-cpu" + # > make[1]: *** [Makefile:4315: configure-gcc] Error 1 + #arch = "armv4"; + + # Ver SA110 en arch/arm/mm/Kconfig, es parecido + cpu = "arm810"; + }; + + linux-kernel = { + name = "taller"; + target = "uImage"; + makeFlags = [ "LOADADDR=0x8000" ]; + autoModules = false; + baseConfig = "taller_defconfig"; + }; }; }; - }; - in { - # Tomado de pkgs/build-support/vm/default.nix - packages."${crossSystem}".proof-of-concept = cross.makeInitrd { - contents = [ - { - symlink = "/init"; - - object = with cross; let - initrdUtils = runCommand "initrd-utils" - { nativeBuildInputs = [ buildPackages.nukeReferences ]; - allowedReferences = [ "out" ]; # prevent accidents like glibc being included in the initrd - } - '' - mkdir -p $out/bin - mkdir -p $out/lib - - # Copy what we need from Glibc. - cp -p ${cross.glibc.out}/lib/ld-linux*.so.? $out/lib - cp -p ${cross.glibc.out}/lib/libc.so.* $out/lib - cp -p ${cross.glibc.out}/lib/libm.so.* $out/lib - cp -p ${cross.glibc.out}/lib/libresolv.so.* $out/lib - - # Copy BusyBox. - cp -pd ${cross.busybox}/bin/* $out/bin - - # Run patchelf to make the programs refer to the copied libraries. - for i in $out/bin/* $out/lib/*; do if ! test -L $i; then nuke-refs $i; fi; done - - for i in $out/bin/*; do - if [ -f "$i" -a ! -L "$i" ]; then - echo "patching $i..." - patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib $i || true - fi - done - ''; - - - path = lib.makeSearchPath "bin" [ - #bashInteractive - #coreutils-full - #gnugrep - #neofetch - #util-linux - ]; - in writeScript "init" '' - #!${initrdUtils}/bin/ash - - export PATH=${initrdUtils}/bin - - mkdir -p /dev /etc /proc /sys - echo -n > /etc/fstab - - mount -t devtmpfs devtmpfs /dev - mount -t proc none /proc - mount -t sysfs none /sys - - exec ash - ''; - } - ]; - }; - - devShells."${system}" = with pkgs; { - default = mkShell { - buildInputs = [ - ncurses - openssl - SDL2 + in + { + formatter.${system} = pkgs.nixpkgs-fmt; + + # Tomado de pkgs/build-support/vm/default.nix + packages."${crossSystem}".proof-of-concept = cross.makeInitrd { + contents = [ + { + symlink = "/init"; + + object = with cross; let + initrdUtils = runCommand "initrd-utils" + { + nativeBuildInputs = [ buildPackages.nukeReferences ]; + allowedReferences = [ "out" ]; # prevent accidents like glibc being included in the initrd + } + '' + mkdir -p $out/bin + mkdir -p $out/lib + + # Copy what we need from Glibc. + cp -p ${cross.glibc.out}/lib/ld-linux*.so.? $out/lib + cp -p ${cross.glibc.out}/lib/libc.so.* $out/lib + cp -p ${cross.glibc.out}/lib/libm.so.* $out/lib + cp -p ${cross.glibc.out}/lib/libresolv.so.* $out/lib + + # Copy BusyBox. + cp -pd ${cross.busybox}/bin/* $out/bin + + # Run patchelf to make the programs refer to the copied libraries. + for i in $out/bin/* $out/lib/*; do if ! test -L $i; then nuke-refs $i; fi; done + + for i in $out/bin/*; do + if [ -f "$i" -a ! -L "$i" ]; then + echo "patching $i..." + patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib $i || true + fi + done + ''; + + + path = lib.makeSearchPath "bin" [ + #bashInteractive + #coreutils-full + #gnugrep + #neofetch + #util-linux + ]; + in + writeScript "init" '' + #!${initrdUtils}/bin/ash + + export PATH=${initrdUtils}/bin + + mkdir -p /dev /etc /proc /sys + echo -n > /etc/fstab + + mount -t devtmpfs devtmpfs /dev + mount -t proc none /proc + mount -t sysfs none /sys + + exec ash + ''; + } ]; - - nativeBuildInputs = [ - binutils - gcc - cross.stdenv.cc.cc - cross.stdenv.cc.bintools - gdb - gnumake - gtkwave - pkg-config - (python3.withPackages (py: [ py.numpy py.pillow py.matplotlib ])) - (quartus-prime-lite.override { supportedDevices = [ "Cyclone V" ]; }) - verilator - ]; - - shellHook = '' - export MAKEFLAGS="AR=gcc-ar" - export CXXFLAGS="-O3 -flto $(pkg-config --cflags sdl2 ncursesw)" - export LDFLAGS="-O3 -flto $(pkg-config --libs sdl2 ncursesw)" - - # <https://discourse.nixos.org/t/fonts-in-nix-installed-packages-on-a-non-nixos-system/5871/7> - export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive" - export FONTCONFIG_FILE="${fontconfig.out}/etc/fonts/fonts.conf" - ''; }; - kbuild = mkShell { - buildInputs = [ - ncurses - ]; - - nativeBuildInputs = [ - bc - bison - flex - gcc - cross.stdenv.cc.cc - cross.stdenv.cc.bintools - gnumake - openssl # Splash de u-boot - ubootTools - ]; + devShells."${system}" = with pkgs; { + default = mkShell { + buildInputs = [ + ncurses + openssl + SDL2 + ]; + + nativeBuildInputs = [ + binutils + gcc + cross.stdenv.cc.cc + cross.stdenv.cc.bintools + gdb + gnumake + gtkwave + pkg-config + (python3.withPackages (py: [ py.numpy py.pillow py.matplotlib ])) + (quartus-prime-lite.override { supportedDevices = [ "Cyclone V" ]; }) + verilator + ]; + + shellHook = '' + export MAKEFLAGS="AR=gcc-ar" + export CXXFLAGS="-O3 -flto $(pkg-config --cflags sdl2 ncursesw)" + export LDFLAGS="-O3 -flto $(pkg-config --libs sdl2 ncursesw)" + + # <https://discourse.nixos.org/t/fonts-in-nix-installed-packages-on-a-non-nixos-system/5871/7> + export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive" + export FONTCONFIG_FILE="${fontconfig.out}/etc/fonts/fonts.conf" + ''; + }; - shellHook = '' - export CROSS_COMPILE=arm-none-eabi- - export MAKEFLAGS="ARCH=arm O=build/taller LOADADDR=0x8000" - ''; + kbuild = mkShell { + buildInputs = [ + ncurses + ]; + + nativeBuildInputs = [ + bc + bison + flex + gcc + cross.stdenv.cc.cc + cross.stdenv.cc.bintools + gnumake + openssl # Splash de u-boot + ubootTools + ]; + + shellHook = '' + export CROSS_COMPILE=arm-none-eabi- + export MAKEFLAGS="ARCH=arm O=build/taller LOADADDR=0x8000" + ''; + }; }; }; - }; } |
