Rewire nix

This commit is contained in:
Robert Hensing 2019-09-28 16:27:07 +02:00
parent adc2e34deb
commit 286d0ae084
6 changed files with 69 additions and 47 deletions

View File

@ -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; };
}

42
nix/arion.nix Normal file
View File

@ -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 ]} \
;
'';
}))

6
nix/ci.nix Normal file
View File

@ -0,0 +1,6 @@
args@{ pkgs ? import ./default.nix args, system ? null, ... }:
{
inherit (pkgs) arion tests;
doc = pkgs.recurseIntoAttrs (import ../doc { inherit pkgs; });
}

View File

@ -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}
'';
})

View File

@ -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; };
}

View File

@ -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
];
};
};