[WIP] Flakes #45

Closed
astro wants to merge 12 commits from astro/nix-scripts:flakes into master
11 changed files with 279 additions and 40 deletions

View File

@ -1,9 +1,11 @@
{ pkgs ? import <nixpkgs> {}
, artiq-fast ? <artiq-fast>
, sinaraSystemsSrc ? <sinaraSystemsSrc>
, sinaraSystemsRev ? null
, sinaraSystemsHash ? null
}:
let
sinaraSystemsSrc = <sinaraSystemsSrc>;
generatedNix = pkgs.runCommand "generated-nix" { buildInputs = [ pkgs.nix pkgs.git ]; }
''
mkdir $out
@ -11,14 +13,21 @@ let
cp ${../artiq-full/artiq-targets.nix} $out/artiq-targets.nix
cp -a ${artiq-fast} $out/fast
${if sinaraSystemsRev != null && sinaraSystemsHash != null
then ''
REV=${sinaraSystemsRev}
HASH=${sinaraSystemsHash}
'' else ''
REV=`git --git-dir ${sinaraSystemsSrc}/.git rev-parse HEAD`
echo -n $REV > $out/sinara-rev.txt
SINARA_SRC_CLEAN=`mktemp -d`
cp -a ${sinaraSystemsSrc}/. $SINARA_SRC_CLEAN
chmod -R 755 $SINARA_SRC_CLEAN/.git
chmod 755 $SINARA_SRC_CLEAN
rm -rf $SINARA_SRC_CLEAN/.git
HASH=`nix-hash --type sha256 --base32 $SINARA_SRC_CLEAN`
''}
echo -n $REV > $out/sinara-rev.txt
echo -n $HASH > $out/sinara-hash.txt
cat > $out/default.nix << EOF

View File

@ -1,7 +1,10 @@
{ pkgs, version, src, target }:
let
wfvm = import ../wfvm.nix { inherit pkgs; };
wfvm = import ../wfvm.nix {
inherit pkgs;
wfvm-pkgs = pkgs;
};
libiconv-filename = "libiconv-1.15-h1df5818_7.tar.bz2";
libiconv = pkgs.fetchurl {
url = "https://anaconda.org/anaconda/libiconv/1.15/download/win-64/${libiconv-filename}";

View File

@ -1,7 +1,10 @@
{ pkgs, version, src }:
let
wfvm = import ../wfvm.nix { inherit pkgs; };
wfvm = import ../wfvm.nix {
inherit pkgs;
wfvm-pkgs = pkgs;
};
conda-vs2015_runtime-filename = "vs2015_runtime-14.16.27012-hf0eaf9b_2.tar.bz2";
conda-vs2015_runtime = pkgs.fetchurl {
url = "https://anaconda.org/anaconda/vs2015_runtime/14.16.27012/download/win-64/${conda-vs2015_runtime-filename}";

View File

@ -1,7 +1,10 @@
{ pkgs, conda-windows-llvm-or1k, version, src }:
let
wfvm = import ../wfvm.nix { inherit pkgs; };
wfvm = import ../wfvm.nix {
inherit pkgs;
wfvm-pkgs = pkgs;
};
conda-vs2015_runtime-filename = "vs2015_runtime-14.16.27012-hf0eaf9b_2.tar.bz2";
conda-vs2015_runtime = pkgs.fetchurl {
url = "https://anaconda.org/anaconda/vs2015_runtime/14.16.27012/download/win-64/${conda-vs2015_runtime-filename}";

View File

@ -33,8 +33,6 @@ in
buildInputs = [ perl groff cmake libxml2 python libffi ] ++ stdenv.lib.optional stdenv.isLinux valgrind;
preBuild = ''
NIX_BUILD_CORES=4
makeFlagsArray=(-j''$NIX_BUILD_CORES)
mkdir -p $out/
'';

View File

@ -1,16 +1,16 @@
{ pkgs }:
let
# Pin nixpkgs to avoid frequent resource-intensive Windows reinstallations on Hydra.
wfvm-pkgs = pkgs.fetchFromGitHub {
{ pkgs
, wfvm-pkgs ? import (pkgs.fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
rev = "f8248ab6d9e69ea9c07950d73d48807ec595e923";
sha256 = "009i9j6mbq6i481088jllblgdnci105b2q4mscprdawg3knlyahk";
};
}) {}
}:
let
wfvm = pkgs.fetchgit {
url = "https://git.m-labs.hk/M-Labs/wfvm.git";
rev = "4b497938ffd9fcddf84a3dbe2f01524395292adb";
sha256 = "0m3kdbbcskqc1lf8b5f7ccbll9b7vkl4r00kbyx3yjb2rs6cqvil";
};
in import "${wfvm}/wfvm" { pkgs = (import wfvm-pkgs {}); }
in import "${wfvm}/wfvm" { pkgs = wfvm-pkgs; }

View File

@ -13,7 +13,10 @@ set -e
nix-build -E "
let
pkgs = import <nixpkgs> {};
wfvm = import ../wfvm.nix { inherit pkgs; };
wfvm = import ../wfvm.nix {
inherit pkgs;
wfvm-pkgs = pkgs;
};
in
wfvm.utils.wfvm-run {
name = \"get-conda-packages\";

View File

@ -10,7 +10,10 @@ let
inherit port;
}) tcpPorts;
wfvm = import ../wfvm.nix { inherit pkgs; };
wfvm = import ../wfvm.nix {
inherit pkgs;
wfvm-pkgs = pkgs;
};
conda-deps = {
name = "conda-deps";
script = let

View File

@ -1,22 +1,25 @@
{ pkgs ? import <nixpkgs> {}
, a6p ? <a6p>
}:
let
sinaraSystemsRev = builtins.readFile <artiq-board-generated/sinara-rev.txt>;
sinaraSystemsHash = builtins.readFile <artiq-board-generated/sinara-hash.txt>;
sinaraSystemsSrc =
, artiq-board-generated ? <artiq-board-generated>
, sinaraSystemsRev ? builtins.readFile (artiq-board-generated + "/sinara-rev.txt")
, sinaraSystemsHash ? builtins.readFile (artiq-board-generated + "/sinara-hash.txt")
, sinaraSystemsSrc ? (
if a6p
then pkgs.fetchgit {
url = "https://git.m-labs.hk/M-Labs/sinara-systems.git";
rev = sinaraSystemsRev;
sha256 = sinaraSystemsHash;
}
else <sinaraSystemsSrc>;
artiq-fast =
else <sinaraSystemsSrc>
)
, artiq-fast ? (
if a6p
then <artiq-board-generated/fast>
else <artiq-fast>;
else <artiq-fast>
)
}:
let
artiqVersion = import (artiq-fast + "/pkgs/artiq-version.nix") {
inherit (pkgs) stdenv git fetchgit;
};
@ -49,17 +52,17 @@ let
${if a6p
then ''
cp -a ${<artiq-board-generated>} $out/board-generated
cp -a ${artiq-board-generated} $out/board-generated
ln -s board-generated/fast $out/fast
''
else "cp -a ${<artiq-fast>} $out/fast"}
else "cp -a ${artiq-fast} $out/fast"}
cp ${./artiq-full}/artiq-board-vivado.nix $out
cp ${./artiq-full}/generate-identifier.py $out
cp ${./artiq-full}/conda-artiq-board.nix $out
cp ${./artiq-full}/extras.nix $out
cp ${./artiq-full}/*.patch $out
${if a6p
${if sinaraSystemsRev != null && sinaraSystemsHash != null
then ''
REV=${sinaraSystemsRev}
HASH=${sinaraSystemsHash}
@ -109,7 +112,9 @@ let
inherit pkgs vivado;
}
''};
conda-artiq-board = import ./conda-artiq-board.nix { inherit pkgs; };
conda-artiq-board = import ./conda-artiq-board.nix {
inherit pkgs;
};
src = pkgs.fetchgit {
url = "https://git.m-labs.hk/M-Labs/sinara-systems.git";
rev = "$REV";

97
flake.lock Normal file
View File

@ -0,0 +1,97 @@
{
"nodes": {
"artiq-beta-src": {
"flake": false,
"locked": {
"lastModified": 1614493604,
"narHash": "sha256-9P/O4SWHqHWO+OD3d8FihJXQ+Y5JRlW0ajBNYZlIZUg=",
"ref": "master",
"rev": "b8f4c6b9bb8ce4f2d7dc50e87690ad336841357c",
"revCount": 7585,
"type": "git",
"url": "https://github.com/M-Labs/artiq.git"
},
"original": {
"type": "git",
"url": "https://github.com/M-Labs/artiq.git"
}
},
"artiq-legacy-src": {
"flake": false,
"locked": {
"lastModified": 1613549523,
"narHash": "sha256-FgX/W+y8N4/6DLLTJuJVg5gUr3zk/5DxmSIxA4I6ZvE=",
"ref": "release-5",
"rev": "10c9842fc8844b524811336c6a529c648a2d2fde",
"revCount": 7153,
"type": "git",
"url": "https://github.com/M-Labs/artiq.git"
},
"original": {
"ref": "release-5",
"type": "git",
"url": "https://github.com/M-Labs/artiq.git"
}
},
"artiq-src": {
"flake": false,
"locked": {
"lastModified": 1613555154,
"narHash": "sha256-D/43YVvMNkcXV6sBBxAqxcmtEO3TagIQEQl0zsGE+ag=",
"ref": "release-6",
"rev": "c22482787ef806eb8e48d59b6ded7d93c7677c81",
"revCount": 7582,
"type": "git",
"url": "https://github.com/M-Labs/artiq.git"
},
"original": {
"ref": "release-6",
"type": "git",
"url": "https://github.com/M-Labs/artiq.git"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1614338965,
"narHash": "sha256-2HPgL9171Dhlg9lS4Ep5aeh4ejRCED+gNmU9tYzgyic=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "113092f5531ef38a45046990199873755a372646",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "release-20.09",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"artiq-beta-src": "artiq-beta-src",
"artiq-legacy-src": "artiq-legacy-src",
"artiq-src": "artiq-src",
"nixpkgs": "nixpkgs",
"sinara-systems": "sinara-systems"
}
},
"sinara-systems": {
"flake": false,
"locked": {
"lastModified": 1615195806,
"narHash": "sha256-UfsPJxvERsGiECOFC+sjmk4r61aWepF0nXqRgnmLR80=",
"ref": "master",
"rev": "1f0605f46cc7cbfcdf427f15a93e0e4a75d0d491",
"revCount": 202,
"type": "git",
"url": "https://git.m-labs.hk/M-Labs/sinara-systems.git"
},
"original": {
"type": "git",
"url": "https://git.m-labs.hk/M-Labs/sinara-systems.git"
}
}
},
"root": "root",
"version": 7
}

115
flake.nix Normal file
View File

@ -0,0 +1,115 @@
# let
# system = "x86_64-linux";
# in
{
description = "ARTIQ";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-20.09";
artiq-beta-src = {
url = "git+https://github.com/M-Labs/artiq.git";
flake = false;
};
artiq-src = {
url = "git+https://github.com/M-Labs/artiq.git?ref=release-6";
flake = false;
};
artiq-legacy-src = {
url = "git+https://github.com/M-Labs/artiq.git?ref=release-5";
flake = false;
};
sinara-systems = {
url = "git+https://git.m-labs.hk/M-Labs/sinara-systems.git";
flake = false;
};
};
outputs = sources@{ self, nixpkgs, sinara-systems, ... }:
let
systems = [
"x86_64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
sinaraSystemsSrc = sinara-systems.outPath;
sinaraSystemsRev = sinara-systems.rev;
sinaraSystemsHash = builtins.replaceStrings ["sha256-"] [""] sinara-systems.narHash;
artiq-jobsets = system: artiqInputName: a6p:
let
pkgs = nixpkgs.legacyPackages.${system};
artiq-fast-src =
let
inherit (sources.${artiqInputName}) lastModified rev revCount narHash;
hash = builtins.replaceStrings ["sha256-"] [""] narHash;
artiqSrc = sources.${artiqInputName}.outPath;
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.${toString revCount}.`cut -c1-8 <<< ${rev}`$SUFFIX\"" > $out/pkgs/artiq-version.nix
echo "{ stdenv, git, fetchgit }: \"${toString lastModified}\"" > $out/pkgs/artiq-timestamp.nix
'';
artiq-fast =
import artiq-fast-src {
inherit pkgs;
};
artiq-board-generated =
(import ./artiq-board-generated {
inherit pkgs;
inherit sinaraSystemsSrc sinaraSystemsRev sinaraSystemsHash;
artiq-fast = artiq-fast-src;
}).generated-nix;
artiq-full =
import ./artiq-full.nix {
inherit pkgs a6p artiq-board-generated;
artiq-fast = artiq-fast-src;
inherit sinaraSystemsSrc sinaraSystemsRev sinaraSystemsHash;
};
in {
inherit artiq-fast artiq-full;
};
in {
packages = forAllSystems (system:
builtins.foldl' (a: b: a // b) {} (
builtins.attrValues (
artiq-jobsets system "artiq-beta-src" true
)
)
);
defaultPackage = forAllSystems (system: self.packages.${system}.artiq);
hydraJobs =
let
jobset = artiqInputName: a6p: name:
forAllSystems (system: (artiq-jobsets system artiqInputName a6p).${name});
in {
fast = jobset "artiq-src" true "artiq-fast";
fast-beta = jobset "artiq-beta-src" true "artiq-fast";
fast-legacy = jobset "artiq-legacy-src" false "artiq-fast";
full = jobset "artiq-src" true "artiq-full";
full-beta = jobset "artiq-beta-src" true "artiq-full";
full-legacy = jobset "artiq-legacy-src" false "artiq-full";
};
};
}