move new artiq-board.nix to artiq-full/, restore artiq-board-legacy.nix for artiq-fast/ #37

Merged
sb10q merged 1 commits from astro/nix-scripts:artiq-board into master 2024-08-17 17:37:17 +08:00
1 changed files with 35 additions and 23 deletions
Showing only changes of commit e189ee4c8f - Show all commits

View File

@ -42,6 +42,31 @@ let
cp -R * $out/registry cp -R * $out/registry
''; '';
}; };
# Funnelling the source code through a Nix string allows dropping
# all dependencies via `unsafeDiscardStringContext`.
discardContextFromPath = { name, src }:
let
packed = pkgs.stdenv.mkDerivation {
name = "${name}.nar.base64";
buildInputs = [ pkgs.nix ];
phases = [ "installPhase" ];
installPhase = "nix-store --dump ${src} | base64 -w0 > $out";
};
unpacked = archive:
pkgs.stdenvNoCC.mkDerivation {
name = builtins.unsafeDiscardStringContext name;
phases = [ "installPhase" ];
buildInputs = [ pkgs.nix ];
installPhase = "base64 -d < ${archive} | nix-store --restore $out";
};
in
unpacked (
builtins.toFile "${builtins.unsafeDiscardStringContext name}.nar.base64" (
builtins.unsafeDiscardStringContext (
builtins.readFile packed
))) ;
in in
{ target { target
, variant , variant
@ -78,7 +103,7 @@ let
software = software =
pkgs.stdenv.mkDerivation { pkgs.stdenv.mkDerivation {
name = "${name}-software"; name = "${name}-software";
src = generatedSources; src = "${generatedSources}/software";
nativeBuildInputs = [ nativeBuildInputs = [
pkgs.gnumake pkgs.which pythonEnv pkgs.gnumake pkgs.which pythonEnv
artiqpkgs.cargo artiqpkgs.cargo
@ -98,12 +123,12 @@ let
TARGET_DIR=$out/${installPath} TARGET_DIR=$out/${installPath}
mkdir -p $TARGET_DIR mkdir -p $TARGET_DIR
if [ -e software/bootloader/bootloader.bin ] if [ -e bootloader/bootloader.bin ]
then cp software/bootloader/bootloader.bin $TARGET_DIR then cp bootloader/bootloader.bin $TARGET_DIR
fi fi
if [ -e software/runtime ] if [ -e runtime ]
then cp software/runtime/runtime.{elf,fbi} $TARGET_DIR then cp runtime/runtime.{elf,fbi} $TARGET_DIR
else cp software/satman/satman.{elf,fbi} $TARGET_DIR else cp satman/satman.{elf,fbi} $TARGET_DIR
fi fi
${extraInstallCommands} ${extraInstallCommands}
''; '';
@ -118,29 +143,16 @@ let
} ''python ${./generate-identifier.py} "${identifierStr}" > $out'' } ''python ${./generate-identifier.py} "${identifierStr}" > $out''
); );
vivadoInputArchive = pkgs.stdenv.mkDerivation {
name = "${name}-vivado-input.nar.base64";
buildInputs = [ pkgs.nix ];
phases = [ "installPhase" ];
installPhase = "nix-store --dump ${generatedSources}/gateware | base64 -w0 > $out";
};
# Funnelling the source code through a Nix string allows dropping
# all dependencies via `unsafeDiscardStringContext`. The gateware
# will then be rebuilt only when these contents have changed.
pureVivadoInputArchive = builtins.toFile "${name}-vivado-input.nar.base64" (
builtins.unsafeDiscardStringContext (
builtins.readFile vivadoInputArchive
));
# Depends on just Vivado and the generated Bitstream source # Depends on just Vivado and the generated Bitstream source
vivadoCheckpoint = pkgs.stdenvNoCC.mkDerivation { vivadoCheckpoint = pkgs.stdenvNoCC.mkDerivation {
name = builtins.unsafeDiscardStringContext "${name}-vivado-checkpoint"; name = builtins.unsafeDiscardStringContext "${name}-vivado-checkpoint";
unpackPhase = "base64 -d < ${pureVivadoInputArchive} | nix-store --restore gateware"; src = discardContextFromPath {
name = "${name}-gateware";
src = "${generatedSources}/gateware";
};
buildInputs = [ vivado pkgs.nix ]; buildInputs = [ vivado pkgs.nix ];
buildPhase = '' buildPhase = ''
cd gateware
vivado -mode batch -source top_route.tcl vivado -mode batch -source top_route.tcl
''; '';