nix flake: make it more idiomatic

so that one can pass attributes directly to buildIdris instead of the
convoluted.
buildIdris (...).build.overrideAttrs(oldAttrs: {})
This commit is contained in:
Matthieu Coudron 2021-09-05 01:08:22 +02:00 committed by G. Allais
parent b231ef0da5
commit 6780874d2e
2 changed files with 17 additions and 9 deletions

View File

@ -35,9 +35,7 @@
inherit idris2-version chez;
srcRev = self.shortRev or "dirty";
};
buildIdris = { projectName, src, idrisLibraries }:
pkgs.callPackage ./nix/buildIdris.nix
{ inherit src projectName idrisLibraries idris2-version; idris2 = idris2Pkg; };
buildIdris = pkgs.callPackage ./nix/buildIdris.nix { inherit idris2-version; idris2 = idris2Pkg; };
in rec {
checks = import ./nix/test.nix {
inherit (pkgs) system stdenv runCommand lib;

View File

@ -1,34 +1,44 @@
{ stdenv
, lib
, projectName
, src
, idris2
, idris2-version
, idrisLibraries
, idris2
}:
{
src
, projectName
, idrisLibraries
, ...
}@attrs:
let
ipkgName = projectName + ".ipkg";
idrName = "idris2-${idris2-version}";
libSuffix = "lib/${idrName}";
lib-dirs = lib.strings.concatMapStringsSep ":" (p: "${p}/${libSuffix}") idrisLibraries;
drvAttrs = builtins.removeAttrs attrs [ "idrisLibraries" ];
in
rec {
build = stdenv.mkDerivation {
build = stdenv.mkDerivation (drvAttrs // {
name = projectName;
src = src;
nativeBuildInputs = [ idris2 ];
configurePhase = ''
runHook preConfigure
export IDRIS2_PACKAGE_PATH=${lib-dirs}
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
idris2 --build ${ipkgName}
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin
mv build/exec/* $out/bin
runHook postInstall
'';
};
});
installLibrary = build.overrideAttrs (_: {
buildPhase = "";
installPhase = ''