From cbdff81618efe16c175466ff9af04e1506c05b0f Mon Sep 17 00:00:00 2001
From: Patrick Baudin <patrick.baudin@cea.fr>
Date: Mon, 1 Apr 2019 14:17:47 +0200
Subject: [PATCH] [Nix] build from distrib tarball

---
 .gitlab-ci.yml  | 12 ++++++------
 nix/default.nix | 21 ++++++++++++---------
 2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f828c1b025b..04fd07dcf36 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -151,27 +151,27 @@ CFP:
   tags:
    - nix
 
-build-tarball:
-  stage: tests
+build-distrib-tarball:
+  stage: build
   variables:
     CURRENT: $CI_COMMIT_REF_NAME
     DEFAULT: "master"
     OCAML: "4_05"
     FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA"
   script:
-   - nix/frama-ci.sh build -A frama-c.distrib
+   - nix/frama-ci.sh build -A frama-c.build-distrib-tarball
   tags:
    - nix
 
-tarball-compilation:
-  stage: distrib_and_compatibility
+build-from-distrib-tarball:
+  stage: tests
   variables:
     CURRENT: $CI_COMMIT_REF_NAME
     DEFAULT: "master"
     OCAML: "4_05"
     FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA"
   script:
-   - nix/frama-ci.sh build -A frama-c.tests-distrib
+   - nix/frama-ci.sh build -A frama-c.build-from-distrib-tarball
   tags:
    - nix
 
diff --git a/nix/default.nix b/nix/default.nix
index 7b153a9754f..6e3255fb4ed 100644
--- a/nix/default.nix
+++ b/nix/default.nix
@@ -105,10 +105,11 @@ rec {
         '';
   };
 
-  distrib = stdenv.mkDerivation {
-        name = "frama-c-distrib";
+  build-distrib-tarball = stdenv.mkDerivation {
+        name = "frama-c-build-distrib-tarball";
         inherit src;
         buildInputs = buildInputs ++ [ plugins.headache.installed pkgs.file ];
+        outputs = [ "out" ];
         postPatch = ''
                patchShebangs .
         '';
@@ -119,16 +120,19 @@ rec {
         '';
         buildPhase = ''
                 make DISTRIB="frama-c-archive" src-distrib
+                tar -zcf frama-c-tests-archive.tar.gz tests src/plugins/*/tests
         '';
         installPhase = ''
-               tar -C $out --strip-components=1 -xf frama-c-archive.tar.gz
+               tar -C $out --strip-components=1 -xzf frama-c-archive.tar.gz
+               tar -C $out -xzf frama-c-tests-archive.tar.gz
         '';
   };
 
-  tests-distrib = stdenv.mkDerivation {
-        name = "frama-c-tests-distrib";
-        inherit distrib buildInputs;
-        outputs = [ "out" "build_dir" ];
+  build-from-distrib-tarball = stdenv.mkDerivation {
+        name = "frama-c-build-from-distrib-tarball";
+        inherit buildInputs;
+        src = build-distrib-tarball.out ;
+        outputs = [ "out" ];
         configurePhase = ''
                unset CC
                autoconf
@@ -136,10 +140,9 @@ rec {
         '';
         buildPhase = ''
                 make -j 4
-                make tests -j4 PTESTS_OPTS="-error-code -j 4"
         '';
         installPhase = ''
-               make install
+               true
         '';
   };
 
-- 
GitLab