Skip to content

Commit 0b4807c

Browse files
authored
fix: fixing nix run (#115)
1 parent 00c54bb commit 0b4807c

3 files changed

Lines changed: 48 additions & 38 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
*.d
2222
host/funcheck
2323
/.vscode
24-
/.vscode/*
24+
/.vscode/*

flake.lock

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,60 @@
55
flake-utils.url = "github:numtide/flake-utils";
66
};
77

8-
outputs = {
9-
self,
10-
nixpkgs,
11-
flake-utils,
12-
}:
8+
outputs =
9+
{
10+
self,
11+
nixpkgs,
12+
flake-utils,
13+
}:
1314
flake-utils.lib.eachDefaultSystem (
14-
system: let
15+
system:
16+
let
1517
pkgs = nixpkgs.legacyPackages.${system};
1618
llvm = pkgs.llvm_18;
17-
commit =
18-
if self ? rev then builtins.substring 0 12 self.rev
19-
else if self ? dirtyRev then builtins.substring 0 12 (pkgs.lib.removeSuffix "-dirty" self.dirtyRev)
20-
else "1.1.4";
19+
commit =
20+
if self ? rev then
21+
builtins.substring 0 12 self.rev
22+
else if self ? dirtyRev then
23+
builtins.substring 0 12 (pkgs.lib.removeSuffix "-dirty" self.dirtyRev)
24+
else
25+
"1.1.4";
2126
funcheck_drv = pkgs.stdenv.mkDerivation (final: {
2227
pname = "funcheck";
2328
version = commit;
2429
src = ./.;
2530
patches = [
26-
(
27-
builtins.toFile
28-
"remove_fwrite_unlocked.patch"
29-
''
30-
diff --git a/library/srcs/hook/functions/stdio.c b/library/srcs/hook/functions/stdio.c
31-
index dbb9e2a..2d6b9dd 100644
32-
--- a/library/srcs/hook/functions/stdio.c
33-
+++ b/library/srcs/hook/functions/stdio.c
34-
@@ -104,7 +104,7 @@ DEFINE_HOOK_FUNCTION(size_t, fwrite, EIO, 0, const void *, ptr, size_t, size, si
31+
(builtins.toFile "remove_fwrite_unlocked.patch" ''
32+
diff --git a/library/srcs/hook/functions/stdio.c b/library/srcs/hook/functions/stdio.c
33+
index dbb9e2a..2d6b9dd 100644
34+
--- a/library/srcs/hook/functions/stdio.c
35+
+++ b/library/srcs/hook/functions/stdio.c
36+
@@ -104,7 +104,7 @@ DEFINE_HOOK_FUNCTION(size_t, fwrite, EIO, 0, const void *, ptr, size_t, size, si
3537
36-
DEFINE_HOOK_FUNCTION(int, fputs_unlocked, EIO, 0, const char *, s, FILE *, stream);
37-
DEFINE_HOOK_FUNCTION(size_t, fread_unlocked, EIO, 0, void *, ptr, size_t, size, size_t, nmemb, FILE *, stream);
38-
-DEFINE_HOOK_FUNCTION(size_t, fwrite_unlocked, EIO, 0, const void *, ptr, size_t, size, size_t, nmemb, FILE *, stream);
39-
+//DEFINE_HOOK_FUNCTION(size_t, fwrite_unlocked, EIO, 0, const void *, ptr, size_t, size, size_t, nmemb, FILE *, stream);
38+
DEFINE_HOOK_FUNCTION(int, fputs_unlocked, EIO, 0, const char *, s, FILE *, stream);
39+
DEFINE_HOOK_FUNCTION(size_t, fread_unlocked, EIO, 0, void *, ptr, size_t, size, size_t, nmemb, FILE *, stream);
40+
-DEFINE_HOOK_FUNCTION(size_t, fwrite_unlocked, EIO, 0, const void *, ptr, size_t, size, size_t, nmemb, FILE *, stream);
41+
+//DEFINE_HOOK_FUNCTION(size_t, fwrite_unlocked, EIO, 0, const void *, ptr, size_t, size, size_t, nmemb, FILE *, stream);
4042
41-
DEFINE_HOOK_FUNCTION(int, fseek, EIO, -1, FILE *, stream, long, offset, int, whence);
42-
DEFINE_HOOK_FUNCTION(long, ftell, EIO, -1, FILE *, stream);
43+
DEFINE_HOOK_FUNCTION(int, fseek, EIO, -1, FILE *, stream, long, offset, int, whence);
44+
DEFINE_HOOK_FUNCTION(long, ftell, EIO, -1, FILE *, stream);
4345
44-
''
45-
)
46+
'')
4647
];
47-
nativeBuildInputs = [pkgs.makeWrapper pkgs.minilibx pkgs.gnumake pkgs.xorg.libX11];
48-
buildInputs = [llvm];
48+
nativeBuildInputs = with pkgs; [
49+
makeWrapper
50+
minilibx
51+
gnumake
52+
libX11
53+
];
54+
buildInputs = [ llvm ];
4955
buildPhase = ''
5056
ls -la
5157
export CFLAGS="-Werror -Wextra -Wall -Wno-stringop-truncation \
5258
-Wno-attributes -Wno-array-parameter -Wno-unused-result \
59+
-Wno-implicit-function-declaration -Wno-int-conversion \
5360
-DABSOLUTE_LIBRARY_PATH=\\\"$out/share/funcheck/libfuncheck.so\\\" \
54-
-g -fPIC -fvisibility=hidden"
61+
-g -fPIC -fvisibility=hidden -Wno-deprecated-declarations -std=gnu99"
5562
make -C library "CC=$CC" "CFLAGS=$CFLAGS" "VERSION=${final.version}"
5663
make -C host "CC=$CC" "CFLAGS=$CFLAGS" "VERSION=${final.version}"
5764
'';
@@ -61,16 +68,17 @@
6168
cp ./host/funcheck "$out/bin/funcheck"
6269
cp ./library/libfuncheck.so "$out/share/funcheck/libfuncheck.so"
6370
wrapProgram $out/bin/funcheck \
64-
--prefix PATH : ${pkgs.lib.makeBinPath [llvm]}
71+
--prefix PATH : ${pkgs.lib.makeBinPath [ llvm ]}
6572
'';
6673
});
67-
in {
74+
in
75+
{
6876
packages = rec {
6977
funcheck = default;
7078
default = funcheck_drv;
7179
};
7280
apps = rec {
73-
funcheck = flake-utils.lib.mkApp {drv = self.packages.${system}.funcheck;};
81+
funcheck = flake-utils.lib.mkApp { drv = self.packages.${system}.funcheck; };
7482
default = funcheck;
7583
};
7684
}

0 commit comments

Comments
 (0)