2
0
mirror of https://github.com/m-labs/artiq.git synced 2025-01-12 12:03:35 +08:00

flake: format using alejandra

This commit is contained in:
Charlie Root 2024-12-13 22:19:49 +01:00 committed by Sébastien Bourdeauducq
parent db293d5ecd
commit 9a8338d71b

199
flake.nix
View File

@ -38,10 +38,21 @@
};
};
outputs = { self, nixpkgs, rust-overlay, sipyco, src-pythonparser, artiq-comtools, src-migen, src-misoc }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import rust-overlay) ]; };
pkgs-aarch64 = import nixpkgs { system = "aarch64-linux"; };
outputs = {
self,
nixpkgs,
rust-overlay,
sipyco,
src-pythonparser,
artiq-comtools,
src-migen,
src-misoc,
}: let
pkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [(import rust-overlay)];
};
pkgs-aarch64 = import nixpkgs {system = "aarch64-linux";};
artiqVersionMajor = 9;
artiqVersionMinor = self.sourceInfo.revCount or 0;
@ -58,24 +69,25 @@
};
rust = pkgs.rust-bin.nightly."2021-09-01".default.override {
extensions = [ "rust-src" ];
targets = [ ];
extensions = ["rust-src"];
targets = [];
};
rustPlatform = pkgs.makeRustPlatform {
rustc = rust;
cargo = rust;
};
vivadoDeps = pkgs: with pkgs; let
vivadoDeps = pkgs:
with pkgs; let
# Apply patch from https://github.com/nix-community/nix-environments/pull/54
# to fix ncurses libtinfo.so's soname issue
ncurses' = ncurses5.overrideAttrs (old: {
configureFlags = old.configureFlags ++ [ "--with-termlib" ];
configureFlags = old.configureFlags ++ ["--with-termlib"];
postFixup = "";
});
in [
libxcrypt-legacy
(ncurses'.override { unicodeSupport = false; })
(ncurses'.override {unicodeSupport = false;})
zlib
libuuid
xorg.libSM
@ -94,7 +106,7 @@
version = "1.4";
src = src-pythonparser;
doCheck = false;
propagatedBuildInputs = with pkgs.python3Packages; [ regex ];
propagatedBuildInputs = with pkgs.python3Packages; [regex];
};
qasync = pkgs.python3Packages.buildPythonPackage rec {
@ -110,17 +122,17 @@
postPatch = ''
rm qasync/_windows.py # Ignoring it is not taking effect and it will not be used on Linux
'';
buildInputs = [ pkgs.python3Packages.poetry-core ];
propagatedBuildInputs = [ pkgs.python3Packages.pyqt6 ];
checkInputs = [ pkgs.python3Packages.pytestCheckHook ];
pythonImportsCheck = [ "qasync" ];
disabledTestPaths = [ "tests/test_qeventloop.py" ];
buildInputs = [pkgs.python3Packages.poetry-core];
propagatedBuildInputs = [pkgs.python3Packages.pyqt6];
checkInputs = [pkgs.python3Packages.pytestCheckHook];
pythonImportsCheck = ["qasync"];
disabledTestPaths = ["tests/test_qeventloop.py"];
};
libartiq-support = pkgs.stdenv.mkDerivation {
name = "libartiq-support";
src = self;
buildInputs = [ rust ];
buildInputs = [rust];
buildPhase = ''
rustc $src/artiq/test/libartiq_support/lib.rs -Cpanic=unwind -g
'';
@ -144,7 +156,7 @@
rev = "v${version}";
sha256 = "sha256-5QBSRDb28Bui9IOhGofj+c7Rk7J5fNv5nPksEPY/O5o=";
};
nativeBuildInputs = [ pkgs.llvm_15 ];
nativeBuildInputs = [pkgs.llvm_15];
# Disable static linking
# https://github.com/numba/llvmlite/issues/93
postPatch = ''
@ -162,16 +174,16 @@
version = artiqVersion;
src = self;
preBuild =
''
preBuild = ''
export VERSIONEER_OVERRIDE=${version}
export VERSIONEER_REV=${artiqRev}
'';
nativeBuildInputs = [ pkgs.qt6.wrapQtAppsHook ];
nativeBuildInputs = [pkgs.qt6.wrapQtAppsHook];
# keep llvm_x and lld_x in sync with llvmlite
propagatedBuildInputs = [ pkgs.llvm_15 pkgs.lld_15 sipyco.packages.x86_64-linux.sipyco pythonparser llvmlite-new pkgs.qt6.qtsvg artiq-comtools.packages.x86_64-linux.artiq-comtools ]
++ (with pkgs.python3Packages; [ pyqtgraph pygit2 numpy dateutil scipy prettytable pyserial levenshtein h5py pyqt6 qasync tqdm lmdb jsonschema platformdirs ]);
propagatedBuildInputs =
[pkgs.llvm_15 pkgs.lld_15 sipyco.packages.x86_64-linux.sipyco pythonparser llvmlite-new pkgs.qt6.qtsvg artiq-comtools.packages.x86_64-linux.artiq-comtools]
++ (with pkgs.python3Packages; [pyqtgraph pygit2 numpy dateutil scipy prettytable pyserial levenshtein h5py pyqt6 qasync tqdm lmdb jsonschema platformdirs]);
dontWrapQtApps = true;
postFixup = ''
@ -180,8 +192,7 @@
wrapQtApp "$out/bin/artiq_session"
'';
preFixup =
''
preFixup = ''
# Ensure that wrapProgram uses makeShellWrapper rather than makeBinaryWrapper
# brought in by wrapQtAppsHook. Only makeShellWrapper supports --run.
wrapProgram() { wrapProgramShell "$@"; }
@ -196,7 +207,7 @@
# FIXME: automatically propagate lld_15 llvm_15 dependencies
# cacert is required in the check stage only, as certificates are to be
# obtained from system elsewhere
nativeCheckInputs = with pkgs; [ lld_15 llvm_15 lit outputcheck cacert ] ++ [ libartiq-support ];
nativeCheckInputs = with pkgs; [lld_15 llvm_15 lit outputcheck cacert] ++ [libartiq-support];
checkPhase = ''
python -m unittest discover -v artiq.test
@ -206,17 +217,18 @@
'';
};
artiq = artiq-upstream // {
withExperimentalFeatures = features: artiq-upstream.overrideAttrs(oa:
{ patches = map (f: ./experimental-features/${f}.diff) features; });
artiq =
artiq-upstream
// {
withExperimentalFeatures = features: artiq-upstream.overrideAttrs (oa: {patches = map (f: ./experimental-features/${f}.diff) features;});
};
migen = pkgs.python3Packages.buildPythonPackage rec {
name = "migen";
src = src-migen;
format = "pyproject";
nativeBuildInputs = [ pkgs.python3Packages.setuptools ];
propagatedBuildInputs = [ pkgs.python3Packages.colorama ];
nativeBuildInputs = [pkgs.python3Packages.setuptools];
propagatedBuildInputs = [pkgs.python3Packages.colorama];
};
asyncserial = pkgs.python3Packages.buildPythonPackage rec {
@ -228,13 +240,13 @@
rev = version;
sha256 = "sha256-ZHzgJnbsDVxVcp09LXq9JZp46+dorgdP8bAiTB59K28=";
};
propagatedBuildInputs = [ pkgs.python3Packages.pyserial ];
propagatedBuildInputs = [pkgs.python3Packages.pyserial];
};
misoc = pkgs.python3Packages.buildPythonPackage {
name = "misoc";
src = src-misoc;
propagatedBuildInputs = with pkgs.python3Packages; [ jinja2 numpy migen pyserial asyncserial ];
propagatedBuildInputs = with pkgs.python3Packages; [jinja2 numpy migen pyserial asyncserial];
};
microscope = pkgs.python3Packages.buildPythonPackage rec {
@ -246,7 +258,7 @@
rev = "c21afe7a53258f05bde57e5ebf2e2761f3d495e4";
sha256 = "sha256-jzyiLRuEf7p8LdhmZvOQj/dyQx8eUE8p6uRlwoiT8vg=";
};
propagatedBuildInputs = with pkgs.python3Packages; [ pyserial prettytable msgpack migen ];
propagatedBuildInputs = with pkgs.python3Packages; [pyserial prettytable msgpack migen];
};
vivadoEnv = pkgs.buildFHSEnv {
@ -261,10 +273,15 @@
runScript = "vivado";
};
makeArtiqBoardPackage = { target, variant, buildCommand ? "python -m artiq.gateware.targets.${target} -V ${variant}", experimentalFeatures ? [] }:
makeArtiqBoardPackage = {
target,
variant,
buildCommand ? "python -m artiq.gateware.targets.${target} -V ${variant}",
experimentalFeatures ? [],
}:
pkgs.stdenv.mkDerivation {
name = "artiq-board-${target}-${variant}";
phases = [ "buildPhase" "checkPhase" "installPhase" ];
phases = ["buildPhase" "checkPhase" "installPhase"];
cargoDeps = rustPlatform.importCargoLock {
lockFile = ./artiq/firmware/Cargo.lock;
outputHashes = {
@ -273,7 +290,7 @@
};
};
nativeBuildInputs = [
(pkgs.python3.withPackages(ps: [ migen misoc (artiq.withExperimentalFeatures experimentalFeatures) ps.packaging ]))
(pkgs.python3.withPackages (ps: [migen misoc (artiq.withExperimentalFeatures experimentalFeatures) ps.packaging]))
rust
pkgs.llvmPackages_15.clang-unwrapped
pkgs.llvm_15
@ -281,8 +298,7 @@
vivado
rustPlatform.cargoSetupHook
];
buildPhase =
''
buildPhase = ''
ARTIQ_PATH=`python -c "import artiq; print(artiq.__path__[0])"`
ln -s $ARTIQ_PATH/firmware/Cargo.lock .
cargoSetupPostUnpackHook
@ -290,8 +306,7 @@
${buildCommand}
'';
doCheck = true;
checkPhase =
''
checkPhase = ''
# Search for PCREs in the Vivado output to check for errors
check_log() {
grep -Pe "$1" artiq_${target}/${variant}/gateware/vivado.log && exit 1 || true
@ -299,8 +314,7 @@
check_log "\d+ constraint not met\."
check_log "Timing constraints are not met\."
'';
installPhase =
''
installPhase = ''
mkdir $out
cp artiq_${target}/${variant}/gateware/top.bit $out
if [ -e artiq_${target}/${variant}/software/bootloader/bootloader.bin ]
@ -330,25 +344,45 @@
sha256 = "1zqv47kzgvbn4c8cr019a6wcja7gn5h1z4kvw5bhpc72fyhagal9";
};
phases = ["installPhase"];
installPhase =
''
installPhase = ''
mkdir -p $out/share/bscan-spi-bitstreams
cp $src/*.bit $out/share/bscan-spi-bitstreams
'';
};
in pkgs.buildEnv {
in
pkgs.buildEnv {
name = "openocd-bscanspi";
paths = [ pkgs.openocd bscan_spi_bitstreams-pkg ];
paths = [pkgs.openocd bscan_spi_bitstreams-pkg];
};
latex-artiq-manual = pkgs.texlive.combine {
inherit (pkgs.texlive)
scheme-basic latexmk cmap collection-fontsrecommended fncychap
titlesec tabulary varwidth framed fancyvrb float wrapfig parskip
upquote capt-of needspace etoolbox booktabs pgf pgfplots;
inherit
(pkgs.texlive)
scheme-basic
latexmk
cmap
collection-fontsrecommended
fncychap
titlesec
tabulary
varwidth
framed
fancyvrb
float
wrapfig
parskip
upquote
capt-of
needspace
etoolbox
booktabs
pgf
pgfplots
;
};
artiq-frontend-dev-wrappers = pkgs.runCommandNoCC "artiq-frontend-dev-wrappers" {}
artiq-frontend-dev-wrappers =
pkgs.runCommandNoCC "artiq-frontend-dev-wrappers" {}
''
mkdir -p $out/bin
for program in ${self}/artiq/frontend/*.py; do
@ -379,10 +413,17 @@
name = "artiq-manual-html-${version}";
version = artiqVersion;
src = self;
buildInputs = with pkgs.python3Packages; [
sphinx sphinx_rtd_theme sphinxcontrib-tikz
sphinx-argparse sphinxcontrib-wavedrom
] ++ [ latex-artiq-manual artiq-comtools.packages.x86_64-linux.artiq-comtools
buildInputs = with pkgs.python3Packages;
[
sphinx
sphinx_rtd_theme
sphinxcontrib-tikz
sphinx-argparse
sphinxcontrib-wavedrom
]
++ [
latex-artiq-manual
artiq-comtools.packages.x86_64-linux.artiq-comtools
pkgs.pdf2svg
];
buildPhase = ''
@ -401,10 +442,17 @@
name = "artiq-manual-pdf-${version}";
version = artiqVersion;
src = self;
buildInputs = with pkgs.python3Packages; [
sphinx sphinx_rtd_theme sphinxcontrib-tikz
sphinx-argparse sphinxcontrib-wavedrom
] ++ [ latex-artiq-manual artiq-comtools.packages.x86_64-linux.artiq-comtools
buildInputs = with pkgs.python3Packages;
[
sphinx
sphinx_rtd_theme
sphinxcontrib-tikz
sphinx-argparse
sphinxcontrib-wavedrom
]
++ [
latex-artiq-manual
artiq-comtools.packages.x86_64-linux.artiq-comtools
pkgs.pdf2svg
];
buildPhase = ''
@ -424,7 +472,7 @@
inherit qtPaths makeArtiqBoardPackage openocd-bscanspi-f;
packages.x86_64-linux.default = pkgs.python3.withPackages(_: [ packages.x86_64-linux.artiq ]);
packages.x86_64-linux.default = pkgs.python3.withPackages (_: [packages.x86_64-linux.artiq]);
formatter.x86_64-linux = pkgs.alejandra;
@ -435,7 +483,8 @@
# are added to PATH.
default = pkgs.mkShell {
name = "artiq-dev-shell";
packages = with pkgs; [
packages = with pkgs;
[
git
lit
lld_15
@ -450,9 +499,9 @@
python3Packages.sphinxcontrib-wavedrom
python3Packages.sphinx_rtd_theme
(python3.withPackages(ps: [ migen misoc microscope ps.packaging ps.paramiko ] ++ artiq.propagatedBuildInputs ))
] ++
[
(python3.withPackages (ps: [migen misoc microscope ps.packaging ps.paramiko] ++ artiq.propagatedBuildInputs))
]
++ [
latex-artiq-manual
rust
artiq-frontend-dev-wrappers
@ -485,7 +534,7 @@
packages.x86_64-linux.vivado
packages.x86_64-linux.openocd-bscanspi
(pkgs.python3.withPackages(ps: [ migen misoc artiq ps.packaging ps.paramiko ]))
(pkgs.python3.withPackages (ps: [migen misoc artiq ps.packaging ps.paramiko]))
];
};
};
@ -499,11 +548,10 @@
gateware-sim = pkgs.stdenvNoCC.mkDerivation {
name = "gateware-sim";
buildInputs = [
(pkgs.python3.withPackages(ps: with packages.x86_64-linux; [ migen misoc artiq ]))
(pkgs.python3.withPackages (ps: with packages.x86_64-linux; [migen misoc artiq]))
];
phases = [ "buildPhase" ];
buildPhase =
''
phases = ["buildPhase"];
buildPhase = ''
python -m unittest discover -v artiq.gateware.test
touch $out
'';
@ -516,19 +564,22 @@
#__impure = true; # Nix 2.8+
buildInputs = [
(pkgs.python3.withPackages(ps: with packages.x86_64-linux; [
(pkgs.python3.withPackages (
ps:
with packages.x86_64-linux;
[
artiq
ps.paramiko
] ++ ps.paramiko.optional-dependencies.ed25519
]
++ ps.paramiko.optional-dependencies.ed25519
))
pkgs.llvm_15
pkgs.lld_15
pkgs.openssh
packages.x86_64-linux.openocd-bscanspi # for the bscanspi bitstreams
];
phases = [ "buildPhase" ];
buildPhase =
''
phases = ["buildPhase"];
buildPhase = ''
export HOME=`mktemp -d`
mkdir $HOME/.ssh
cp /opt/hydra_id_ed25519 $HOME/.ssh/id_ed25519