summary refs log tree commit diff
diff options
context:
space:
mode:
authorBruno Bzeznik <Bruno.Bzeznik@imag.fr>2020-08-25 09:44:27 +0200
committerDaniƫl de Kok <me@danieldk.eu>2020-08-28 14:39:21 +0200
commit1601ff7dd4941e8cd5b4b5429820daa4d32f36f2 (patch)
tree27722753f19b0ebfa5370dd26d825d414e8fdde7
parent46f277b3f2b2410368f9f9000932d9af8ddf37ce (diff)
downloadnixpkgs-1601ff7dd4941e8cd5b4b5429820daa4d32f36f2.tar
nixpkgs-1601ff7dd4941e8cd5b4b5429820daa4d32f36f2.tar.gz
nixpkgs-1601ff7dd4941e8cd5b4b5429820daa4d32f36f2.tar.bz2
nixpkgs-1601ff7dd4941e8cd5b4b5429820daa4d32f36f2.tar.lz
nixpkgs-1601ff7dd4941e8cd5b4b5429820daa4d32f36f2.tar.xz
nixpkgs-1601ff7dd4941e8cd5b4b5429820daa4d32f36f2.tar.zst
nixpkgs-1601ff7dd4941e8cd5b4b5429820daa4d32f36f2.zip
charliecloud: 0.12 -> 0.18 (docker + ch-grow support)
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/charliecloud.nix43
-rw-r--r--pkgs/applications/virtualization/charliecloud/default.nix28
3 files changed, 67 insertions, 5 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index a4a62d85a59..ca8b3446fec 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -48,6 +48,7 @@ in
   ceph-multi-node = handleTestOn ["x86_64-linux"] ./ceph-multi-node.nix {};
   certmgr = handleTest ./certmgr.nix {};
   cfssl = handleTestOn ["x86_64-linux"] ./cfssl.nix {};
+  charliecloud = handleTest ./charliecloud.nix {};
   chromium = (handleTestOn ["x86_64-linux"] ./chromium.nix {}).stable or {};
   cjdns = handleTest ./cjdns.nix {};
   clickhouse = handleTest ./clickhouse.nix {};
diff --git a/nixos/tests/charliecloud.nix b/nixos/tests/charliecloud.nix
new file mode 100644
index 00000000000..acba41e228a
--- /dev/null
+++ b/nixos/tests/charliecloud.nix
@@ -0,0 +1,43 @@
+# This test checks charliecloud image construction and run
+
+import ./make-test-python.nix ({ pkgs, ...} : let
+
+  dockerfile = pkgs.writeText "Dockerfile" ''
+    FROM nix
+    RUN mkdir /home /tmp
+    RUN touch /etc/passwd /etc/group
+    CMD ["true"]
+  '';
+
+in {
+  name = "charliecloud";
+  meta = with pkgs.stdenv.lib.maintainers; {
+    maintainers = [ bzizou ];
+  };
+
+  nodes = {
+    host = { ... }: {
+      environment.systemPackages = [ pkgs.charliecloud ];
+      virtualisation.docker.enable = true;
+      users.users.alice = {
+        isNormalUser = true;
+        extraGroups = [ "docker" ];
+      };
+    };
+  };
+
+  testScript = ''
+    host.start()
+    host.wait_for_unit("docker.service")
+    host.succeed(
+        'su - alice -c "docker load --input=${pkgs.dockerTools.examples.nix}"'
+    )
+    host.succeed(
+        "cp ${dockerfile} /home/alice/Dockerfile"
+    )
+    host.succeed('su - alice -c "ch-build -t hello ."')
+    host.succeed('su - alice -c "ch-builder2tar hello /var/tmp"')
+    host.succeed('su - alice -c "ch-tar2dir /var/tmp/hello.tar.gz /var/tmp"')
+    host.succeed('su - alice -c "ch-run /var/tmp/hello -- echo Running_From_Container_OK"')
+  '';
+})
diff --git a/pkgs/applications/virtualization/charliecloud/default.nix b/pkgs/applications/virtualization/charliecloud/default.nix
index d66117138cf..54663f9c5e6 100644
--- a/pkgs/applications/virtualization/charliecloud/default.nix
+++ b/pkgs/applications/virtualization/charliecloud/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, python, autoconf, automake, docker, buildah }:
+{ stdenv, fetchFromGitHub, python3, python3Packages, docker, autoreconfHook, coreutils, makeWrapper, gnused, gnutar, gzip, findutils, sudo, nixosTests }:
 
 stdenv.mkDerivation rec {
 
@@ -12,13 +12,21 @@ stdenv.mkDerivation rec {
     sha256 = "0x2kvp95ld0yii93z9i0k9sknfx7jkgy4rkw9l369fl7f73ghsiq";
   };
 
-  nativeBuildInputs = [ autoreconfHook ];
-  buildInputs = [ python docker buildah ];
+  nativeBuildInputs = [ autoreconfHook makeWrapper ];
+  buildInputs = [
+    docker
+    (python3.withPackages (ps: [ ps.lark-parser ps.requests ]))
+  ];
+
+  configureFlags = let
+    pythonEnv = python3.withPackages (ps: [ ps.lark-parser ps.requests ]);
+  in [
+    "--with-python=${pythonEnv}/bin/python3"
+  ];
 
   preConfigure = ''
     patchShebangs test/
-    patchShebangs autogen.sh
-    ./autogen.sh
+    substituteInPlace configure.ac --replace "/usr/bin/env" "${coreutils}/bin/env"
   '';
 
   makeFlags = [
@@ -26,6 +34,16 @@ stdenv.mkDerivation rec {
     "LIBEXEC_DIR=lib/charliecloud"
   ];
 
+  # Charliecloud calls some external system tools.
+  # Here we wrap those deps so they are resolved inside nixpkgs.
+  postInstall = ''
+    for file in $out/bin/* ; do \
+      wrapProgram $file --prefix PATH : ${stdenv.lib.makeBinPath [ coreutils docker gnused gnutar gzip findutils sudo ]}
+    done
+  '';
+
+  passthru.tests.charliecloud = nixosTests.charliecloud;
+
   meta = {
     description = "User-defined software stacks (UDSS) for high-performance computing (HPC) centers";
     longDescription = ''