nix-scripts/flake.nix

110 lines
3.4 KiB
Nix
Raw Normal View History

2021-03-04 03:35:30 +08:00
# let
# system = "x86_64-linux";
# in
{
description = "ARTIQ";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-20.09";
artiq-beta-src = {
url = "github:M-Labs/artiq";
flake = false;
};
artiq-src = {
url = "github:M-Labs/artiq/release-6";
flake = false;
};
artiq-legacy-src = {
url = "github:M-Labs/artiq/release-5";
flake = false;
};
sinara-systems = {
url = "git+https://git.m-labs.hk/M-Labs/sinara-systems.git";
flake = false;
};
};
2021-03-04 23:51:53 +08:00
2021-03-04 03:35:30 +08:00
outputs = sources@{ self, nixpkgs, ... }:
let
systems = [
"x86_64-linux"
];
forAllSystems = f:
builtins.foldl' (systems: system:
systems // { ${system} = f system; }
) {} systems;
in rec {
packages = forAllSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
artiq-fast-src = artiqInputName:
let
inherit (sources.${artiqInputName}) lastModified rev narHash;
hash = builtins.replaceStrings ["sha256-"] [""] narHash;
artiqSrc = sources.${artiqInputName}.outPath;
2021-03-04 23:51:53 +08:00
2021-03-04 03:35:30 +08:00
in pkgs.runCommand "generated-nix" { buildInputs = [ pkgs.nix pkgs.git ]; } ''
cp --no-preserve=mode,ownership -R ${./artiq-fast} $out
MAJOR_VERSION=`cat ${artiqSrc}/MAJOR_VERSION`
if [ -e ${artiqSrc}/BETA ]; then
SUFFIX=".beta"
else
SUFFIX=""
fi
cat > $out/pkgs/artiq-src.nix << EOF
{ fetchgit }:
fetchgit {
url = "git://github.com/m-labs/artiq.git";
rev = "${rev}";
sha256 = "${hash}";
}
EOF
echo "{ stdenv, git, fetchgit }: \"$MAJOR_VERSION.`cut -c1-8 <<< ${rev}`$SUFFIX\"" > $out/pkgs/artiq-version.nix
echo "{ stdenv, git, fetchgit }: \"${toString lastModified}\"" > $out/pkgs/artiq-timestamp.nix
'';
artiq-fast = artiqInputName:
import (artiq-fast-src artiqInputName) {
inherit pkgs;
};
artiq-board-generated = artiqInputName:
(import ./artiq-board-generated {
inherit pkgs;
sinaraSystemsSrc = null; #sources.sinara-systems.outPath;
sinaraSystemsRev = sources.sinara-systems.rev;
sinaraSystemsHash = builtins.replaceStrings ["sha256-"] [""]
sources.sinara-systems.narHash;
artiq-fast = artiq-fast-src artiqInputName;
}).generated-nix;
artiq-full = artiqInputName: a6p:
import ./artiq-full.nix {
inherit pkgs;
inherit a6p;
artiq-board-generated = artiq-board-generated artiqInputName;
sinaraSystemsSrc = sources.sinara-systems.outPath;
artiq-fast = artiq-fast-src artiqInputName;
};
2021-03-04 23:51:53 +08:00
excluded = [
# "windows-no-hardware-tests"
# "extended-tests"
];
2021-03-04 03:35:30 +08:00
allPackages = artiqInputName: a6p:
2021-03-04 23:51:53 +08:00
nixpkgs.lib.filterAttrs (name: _: !builtins.elem name excluded) (
(artiq-fast artiqInputName) //
(artiq-full artiqInputName a6p)
);
2021-03-04 03:35:30 +08:00
in allPackages "artiq-beta-src" true
);
defaultPackage = forAllSystems (system: self.packages.${system}.artiq);
};
}