diff --git a/default.nix b/default.nix index 7f48895..7b66620 100644 --- a/default.nix +++ b/default.nix @@ -1,6 +1,6 @@ -args@{ pkgs ? import ./nix args, system ? null, ... }: - +{ pkgs ? import ./nix {} +, haskellPackages ? pkgs.haskellPackages +}: { - inherit (pkgs) arion tests; - doc = pkgs.recurseIntoAttrs (import ./doc { inherit pkgs; }); + arion = import ./nix/arion.nix { inherit pkgs haskellPackages; }; } diff --git a/nix/arion.nix b/nix/arion.nix new file mode 100644 index 0000000..4b76fc1 --- /dev/null +++ b/nix/arion.nix @@ -0,0 +1,42 @@ +{ pkgs ? import ./. {} +, lib ? pkgs.lib +, haskellPackages ? pkgs.haskellPackages +, arion-compose ? import ./haskell-arion-compose.nix { inherit pkgs haskellPackages; } +}: + +let + inherit (pkgs.haskell.lib) justStaticExecutables overrideCabal; + + srcDir = ../src; + eval = import (srcDir + "/nix/eval-composition.nix"); + build = args@{...}: + let composition = eval args; + in composition.config.build.dockerComposeYaml; + +in + justStaticExecutables (overrideCabal arion-compose (o: { + buildTools = o.buildTools ++ [pkgs.makeWrapper]; + passthru = o.passthru // { + inherit eval build; + }; + pname = "arion"; # Cover up the needlessly long Haskell package name + + # 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 ]} \ + ; + ''; + })) diff --git a/nix/ci.nix b/nix/ci.nix new file mode 100644 index 0000000..91f1a0f --- /dev/null +++ b/nix/ci.nix @@ -0,0 +1,6 @@ +args@{ pkgs ? import ./default.nix args, system ? null, ... }: + +{ + inherit (pkgs) arion tests; + doc = pkgs.recurseIntoAttrs (import ../doc { inherit pkgs; }); +} diff --git a/nix/haskell-arion-compose.nix b/nix/haskell-arion-compose.nix new file mode 100644 index 0000000..239d476 --- /dev/null +++ b/nix/haskell-arion-compose.nix @@ -0,0 +1,14 @@ + +# NOTE: This file produces a haskell library, not the arion package! + +{ pkgs ? import ./default.nix {}, haskellPackages ? pkgs.haskellPackages }: +let + inherit (pkgs.haskell.lib) overrideCabal addBuildTools; +in + overrideCabal (addBuildTools (haskellPackages.callCabal2nix "arion-compose" ./.. {}) [pkgs.nix]) (o: o // { + preCheck = '' + export NIX_LOG_DIR=$TMPDIR + export NIX_STATE_DIR=$TMPDIR + export NIX_PATH=nixpkgs=${pkgs.path} + ''; + }) \ No newline at end of file diff --git a/nix/haskell-overlay.nix b/nix/haskell-overlay.nix index 74e43c4..c2d82cb 100644 --- a/nix/haskell-overlay.nix +++ b/nix/haskell-overlay.nix @@ -1,13 +1,4 @@ self: super: hself: hsuper: -let - inherit (self.haskell.lib) addBuildTools overrideCabal; -in { - arion-compose = overrideCabal (addBuildTools (hself.callCabal2nix "arion-compose" ./.. {}) [self.nix]) (o: o // { - preCheck = '' - export NIX_LOG_DIR=$TMPDIR - export NIX_STATE_DIR=$TMPDIR - export NIX_PATH=nixpkgs=${self.path} - ''; - }); + arion-compose = import ./haskell-arion-compose.nix { pkgs = self; haskellPackages = hself; }; } \ No newline at end of file diff --git a/nix/overlay.nix b/nix/overlay.nix index 6a41e14..8b5490c 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -3,42 +3,10 @@ let inherit (self.arion-project) haskellPkgs; inherit (super) lib; - srcDir = ../src; # TODO gitignoreSource + whitelist nix and arion-image - eval = import (srcDir + "/nix/eval-composition.nix"); - build = args@{...}: - let composition = eval args; - in composition.config.build.dockerComposeYaml; - hlib = super.haskell.lib; in { - arion-v0 = super.callPackage ../arion.nix {}; - arion = hlib.justStaticExecutables (hlib.overrideCabal haskellPkgs.arion-compose (o: { - buildTools = o.buildTools ++ [super.makeWrapper]; - passthru = o.passthru // { - inherit eval build; - }; - pname = "arion"; # Cover up the needlessly long Haskell package name - - # 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 [ self.docker-compose ]} \ - ; - ''; - })); + arion = import ./arion.nix { pkgs = self; }; tests = super.callPackage ../tests {}; doc = super.callPackage ../doc {}; @@ -50,6 +18,7 @@ in haskellPkgs.cabal-install haskellPkgs.ghcid super.docker-compose + (import ~/h/ghcide-nix {}).ghcide-ghc864 ]; }; };