From d149c66d0522023adf9606742b4a826b55e42709 Mon Sep 17 00:00:00 2001 From: Stephan Maka Date: Fri, 29 Jan 2021 23:45:37 +0100 Subject: [PATCH] artiq-full: move reading standalone flag from sinara-systems to before generatedNix --- artiq-full.nix | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/artiq-full.nix b/artiq-full.nix index dcf0f3d..5de005c 100644 --- a/artiq-full.nix +++ b/artiq-full.nix @@ -2,6 +2,23 @@ let sinaraSystemsSrc = ; + standaloneVariants = + let + jsonFiles = + builtins.attrNames ( + pkgs.lib.filterAttrs (name: type: + type != "directory" && + builtins.match ".+\\.json" name != null + ) (builtins.readDir sinaraSystemsSrc) + ); + isStandalone = jsonFile: + (builtins.fromJSON ( + builtins.readFile "${sinaraSystemsSrc}/${jsonFile}" + )).base == "standalone"; + in + map (builtins.replaceStrings [".json"] [""]) ( + builtins.filter isStandalone jsonFiles + ); generatedNix = pkgs.runCommand "generated-nix" { buildInputs = [ pkgs.nix pkgs.git ]; } '' @@ -111,6 +128,9 @@ let "wipm7master" "wipm7satellite" ]); + standaloneVariants = [${builtins.concatStringsSep " " ( + builtins.map (variant: "\"${variant}\"") standaloneVariants + )}]; # Splitting the build process into software+gateware does # not work when artiq embeds compiled firmware into generated # Vivado input. @@ -148,7 +168,7 @@ let boardBinaries = boardBinaries; inherit target variant; }; - } // (pkgs.lib.optionalAttrs ((builtins.fromJSON (builtins.readFile json)).base == "standalone") { + } // (pkgs.lib.optionalAttrs (builtins.elem variant standaloneVariants) { "device-db-\''${target}-\''${variant}" = pkgs.stdenv.mkDerivation { name = "device-db-\''${target}-\''${variant}"; buildInputs = ddbDeps;