mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-08 05:54:24 +00:00
e9ee0ff4b0
The mime module relies on the `/etc/mime.types` file. We may hardcode it
like the Golang recipe[0].
Also add a `passthru.tests.mimeModule` so that we can be certain that
the module is working.
[0]: f1010e0469/pkgs/development/compilers/go/1.22.nix (L79)
29 lines
671 B
Nix
29 lines
671 B
Nix
{
|
|
hare,
|
|
runCommandNoCC,
|
|
writeText,
|
|
}:
|
|
let
|
|
mainDotHare = writeText "main.ha" ''
|
|
use fmt;
|
|
use mime;
|
|
export fn main() void = {
|
|
const ext = "json";
|
|
match(mime::lookup_ext(ext)) {
|
|
case let mime: const *mime::mimetype =>
|
|
fmt::printfln("Found mimetype for extension `{}`: {}", ext, mime.mime)!;
|
|
case null =>
|
|
fmt::fatalf("Could not find mimetype for `{}`", ext);
|
|
};
|
|
};
|
|
'';
|
|
in
|
|
runCommandNoCC "mime-module-test" { nativeBuildInputs = [ hare ]; } ''
|
|
HARECACHE="$(mktemp -d)"
|
|
export HARECACHE
|
|
readonly binout="test-bin"
|
|
hare build -qRo "$binout" ${mainDotHare}
|
|
./$binout
|
|
: 1>$out
|
|
''
|