Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions pkgs/by-name/mi/microhs/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
callPackage,
stdenv,
fetchFromGitHub,
lib,
writableTmpDirAsHomeHook,
writeTextDir,
}:

stdenv.mkDerivation (finalAttrs: {
pname = "microhs";
version = "0.14.21.0";

src = fetchFromGitHub {
owner = "augustss";
repo = "MicroHs";
tag = "v${finalAttrs.version}";
hash = "sha256-Tq8fjI3LCP4NWrmbMP0xyhY2fjRmsMCEvgfDQ/SB5Bo=";
};

# mcabal doesn't seem to respect the make flag and fails with /homeless-shelter
# This works around the issue
nativeBuildInputs = [ writableTmpDirAsHomeHook ];

makeFlags = [ "MCABAL=$(out)" ];
buildFlags = [ "bootstrap" ];

# MicroCabal is a separate repository, which should be packaged separately
# The MicroCabal that is installed by `make install` is pregenerated, does not respect MCABAL above, and so is not useable
postInstall = "rm $out/bin/mcabal";

passthru.tests = {
hello-world = callPackage ./test-hello-world.nix { microhs = finalAttrs.finalPackage; };
};

meta = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this is "built" from generated code that has equivalent properties to bytecode, could you set the appropriate sourceProvenance?

It'd also be great if the description mentioned the purpose/difference of this package.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formula has been superseded now in #460845 which bootstraps without the generated blob using hugs (recently fixed in nixpkgs)

Once that is merged this will be deleted, so I wasn't planning on making any changes to this formula

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer this to be done regardless as it's not certain when/if that PR is merged.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no reason it shouldn't be merged, and that PR is a superior approach to this one, so I'd rather contribute to it to help get it over the line!

description = "Haskell implemented with combinators";
homepage = "https://github.com/augustss/MicroHs";
license = lib.licenses.asl20;
maintainers = [ lib.maintainers.steeleduncan ];
platforms = lib.platforms.all;
};
})
34 changes: 34 additions & 0 deletions pkgs/by-name/mi/microhs/test-hello-world.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
stdenv,
microhs,
writeTextDir,
}:

stdenv.mkDerivation {
name = "microhs-hello-world";
buildInputs = [ microhs ];

src = writeTextDir "helloworld.hs" ''
main :: IO ()
main = putStrLn "Hello World"
'';

buildPhase = ''
runHook preBuild
mhs helloworld.hs -oExe
runHook postBuild
'';

checkPhase = ''
runHook preCheck
./Exe | grep "Hello World"
runHook postCheck
'';
doCheck = true;

installPhase = ''
runHook preInstall
touch $out
runHook postInstall
'';
}
Loading