summary refs log tree commit diff
diff options
context:
space:
mode:
authorRobert Hensing <roberth@users.noreply.github.com>2019-10-24 16:12:06 +0200
committerGitHub <noreply@github.com>2019-10-24 16:12:06 +0200
commitbecfba9512c68b013ac62f5adb0ffc2d96c5132e (patch)
treea7db23723ac4c72ec525871cb31cf0e6604a2d01
parentdc84a7d4e3aa42afa0d41d38ffffe98022b0f946 (diff)
parentd3913c84da984980d562a1f2441939a2d1faa6e6 (diff)
downloadnixpkgs-becfba9512c68b013ac62f5adb0ffc2d96c5132e.tar
nixpkgs-becfba9512c68b013ac62f5adb0ffc2d96c5132e.tar.gz
nixpkgs-becfba9512c68b013ac62f5adb0ffc2d96c5132e.tar.bz2
nixpkgs-becfba9512c68b013ac62f5adb0ffc2d96c5132e.tar.lz
nixpkgs-becfba9512c68b013ac62f5adb0ffc2d96c5132e.tar.xz
nixpkgs-becfba9512c68b013ac62f5adb0ffc2d96c5132e.tar.zst
nixpkgs-becfba9512c68b013ac62f5adb0ffc2d96c5132e.zip
Merge pull request #71092 from roberth/arion-init
arion: init at 0.1.0.0
-rw-r--r--pkgs/applications/virtualization/arion/default.nix83
-rw-r--r--pkgs/top-level/all-packages.nix2
2 files changed, 85 insertions, 0 deletions
diff --git a/pkgs/applications/virtualization/arion/default.nix b/pkgs/applications/virtualization/arion/default.nix
new file mode 100644
index 00000000000..f144ec97677
--- /dev/null
+++ b/pkgs/applications/virtualization/arion/default.nix
@@ -0,0 +1,83 @@
+{ pkgs
+, lib
+, haskellPackages
+, haskell
+, runCommand
+}:
+
+let
+
+  /* This derivation builds the arion tool.
+
+     It is based on the arion-compose Haskell package, but adapted and extended to
+       - have the correct name
+       - have a smaller closure size
+       - have functions to use Arion from inside Nix: arion.eval and arion.build
+       - make it self-contained by including docker-compose
+   */
+  arion =
+    justStaticExecutables (
+      overrideCabal
+        arion-compose
+        cabalOverrides
+      );
+
+  inherit (haskell.lib) justStaticExecutables overrideCabal;
+
+  inherit (haskellPackages) arion-compose;
+
+  cabalOverrides = o: {
+    buildTools = (o.buildTools or []) ++ [pkgs.makeWrapper];
+    passthru = (o.passthru or {}) // {
+      inherit eval build;
+    };
+    # Patch away the arion-compose name. Unlike the Haskell library, the program
+    # is called arion (arion was already taken on hackage).
+    pname = "arion";
+    src = arion-compose.src;
+
+    # PYTHONPATH
+    #
+    # We close off the python module search path!
+    #
+    # Accepting directories from the environment into the search path
+    # tends to break things. Docker Compose does not have a plugin
+    # system as far as I can tell, so I don't expect this to break a
+    # feature, but rather to make the program more robustly self-
+    # contained.
+
+    postInstall = ''${o.postInstall or ""}
+      mkdir -p $out/libexec
+      mv $out/bin/arion $out/libexec
+      makeWrapper $out/libexec/arion $out/bin/arion \
+        --unset PYTHONPATH \
+        --prefix PATH : ${lib.makeBinPath [ pkgs.docker-compose ]} \
+        ;
+    '';
+  };
+
+  # Unpacked sources for evaluation by `eval`
+  srcUnpacked = runCommand "arion-src" {}
+    "mkdir $out; tar -C $out --strip-components=1 -xf ${arion-compose.src}";
+
+  /* Function for evaluating a composition
+
+     Re-uses this Nixpkgs evaluation instead of `arion-pkgs.nix`.
+
+     Returns the module system's `config` and `options` variables.
+   */
+  eval = args@{...}:
+    import (srcUnpacked + "/src/nix/eval-composition.nix")
+      ({ inherit pkgs; } // args);
+
+  /* Function to derivation of the docker compose yaml file
+     NOTE: The output will change: https://github.com/hercules-ci/arion/issues/82
+
+    This function is particularly useful on CI, although the references
+    to image tarballs may not always be desirable.
+   */
+  build = args@{...}:
+    let composition = eval args;
+    in composition.config.out.dockerComposeYaml;
+
+in arion
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 2a7f23d2fd2..bb9af968fa0 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -17575,6 +17575,8 @@ in
 
   ario = callPackage ../applications/audio/ario { };
 
+  arion = callPackage ../applications/virtualization/arion { };
+
   arora = callPackage ../applications/networking/browsers/arora { };
 
   artha = callPackage ../applications/misc/artha { };