mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 15:33:13 +00:00
Merge pull request #311688 from onemoresuza/hare-fix-mime-module
This commit is contained in:
commit
8c1597626f
13
pkgs/by-name/ha/hare/003-use-mailcap-for-mimetypes.patch
Normal file
13
pkgs/by-name/ha/hare/003-use-mailcap-for-mimetypes.patch
Normal file
@ -0,0 +1,13 @@
|
||||
diff --git a/mime/system.ha b/mime/system.ha
|
||||
index 73ff3496..42e7b640 100644
|
||||
--- a/mime/system.ha
|
||||
+++ b/mime/system.ha
|
||||
@@ -11,7 +11,7 @@ use strings;
|
||||
use types;
|
||||
|
||||
// Path to the system MIME database.
|
||||
-export def SYSTEM_DB: str = "/etc/mime.types";
|
||||
+export def SYSTEM_DB: str = "@mailcap@/etc/mime.types";
|
||||
|
||||
@init fn init() void = {
|
||||
// Done in a separate function so we can discard errors here
|
28
pkgs/by-name/ha/hare/mime-module-test.nix
Normal file
28
pkgs/by-name/ha/hare/mime-module-test.nix
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
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
|
||||
''
|
@ -7,6 +7,7 @@
|
||||
gitUpdater,
|
||||
scdoc,
|
||||
tzdata,
|
||||
mailcap,
|
||||
substituteAll,
|
||||
fetchpatch,
|
||||
callPackage,
|
||||
@ -116,6 +117,11 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
url = "https://git.sr.ht/~sircmpwn/hare/commit/e35f2284774436f422e06f0e8d290b173ced1677.patch";
|
||||
hash = "sha256-A59bGO/9tOghV8/MomTxd8xRExkHVdoMom2d+HTfQGg=";
|
||||
})
|
||||
# Use mailcap `/etc/mime.types` for Hare's mime module
|
||||
(substituteAll {
|
||||
src = ./003-use-mailcap-for-mimetypes.patch;
|
||||
inherit mailcap;
|
||||
})
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
@ -169,9 +175,13 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
|
||||
passthru = {
|
||||
updateScript = gitUpdater { };
|
||||
tests = lib.optionalAttrs enableCrossCompilation {
|
||||
crossCompilation = callPackage ./cross-compilation-tests.nix { hare = finalAttrs.finalPackage; };
|
||||
};
|
||||
tests =
|
||||
lib.optionalAttrs enableCrossCompilation {
|
||||
crossCompilation = callPackage ./cross-compilation-tests.nix { hare = finalAttrs.finalPackage; };
|
||||
}
|
||||
// lib.optionalAttrs (stdenv.buildPlatform.canExecute stdenv.hostPlatform) {
|
||||
mimeModule = callPackage ./mime-module-test.nix { hare = finalAttrs.finalPackage; };
|
||||
};
|
||||
};
|
||||
|
||||
meta = {
|
||||
|
Loading…
Reference in New Issue
Block a user