-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathflake.nix
More file actions
122 lines (101 loc) · 3.5 KB
/
flake.nix
File metadata and controls
122 lines (101 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
{
description = "eser - Eser's swiss-army-knife tooling for your terminal";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachSystem [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
] (system:
let
pkgs = import nixpkgs { inherit system; };
version = builtins.replaceStrings ["\n" " "] ["" ""] (builtins.readFile ./VERSION);
hashes = builtins.fromJSON (builtins.readFile ./nix/hashes.json);
targetMap = {
x86_64-linux = "x86_64-unknown-linux-gnu";
aarch64-linux = "aarch64-unknown-linux-gnu";
x86_64-darwin = "x86_64-apple-darwin";
aarch64-darwin = "aarch64-apple-darwin";
};
target = targetMap.${system};
src = pkgs.fetchurl {
url = "https://github.com/eser/stack/releases/download/v${version}/eser-v${version}-${target}.tar.gz";
hash = hashes.${target};
};
isLinux = builtins.elem system [ "x86_64-linux" "aarch64-linux" ];
isDarwin = builtins.elem system [ "x86_64-darwin" "aarch64-darwin" ];
# Platform-appropriate shared library extension
sharedLibExt = if isDarwin then "dylib" else "so";
sharedLibName = "libeser_ajan.${sharedLibExt}";
# Environment variable for shared library lookup
libPathVar = if isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH";
eser = pkgs.stdenv.mkDerivation {
pname = "eser";
inherit version src;
sourceRoot = ".";
nativeBuildInputs = [
pkgs.makeWrapper
] ++ pkgs.lib.optionals isLinux [
pkgs.autoPatchelfHook
];
buildInputs = pkgs.lib.optionals isLinux [
pkgs.stdenv.cc.cc.lib
];
installPhase = ''
mkdir -p $out/bin
# Install the main binary
cp eser $out/bin/eser
chmod +x $out/bin/eser
# Install the Go shared library if present in the archive
if [ -f "${sharedLibName}" ]; then
mkdir -p $out/lib
cp ${sharedLibName} $out/lib/${sharedLibName}
chmod +x $out/lib/${sharedLibName}
fi
# Install the C header if present in the archive
if [ -f "libeser_ajan.h" ]; then
mkdir -p $out/include
cp libeser_ajan.h $out/include/libeser_ajan.h
fi
'';
# Wrap the binary so it can find the shared library at runtime
postFixup = ''
if [ -f "$out/lib/${sharedLibName}" ]; then
wrapProgram $out/bin/eser \
--set ${libPathVar} "$out/lib"
fi
'';
meta = with pkgs.lib; {
description = "eser - Eser's swiss-army-knife tooling for your terminal";
homepage = "https://github.com/eser/stack";
license = licenses.asl20;
platforms = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
};
};
in
{
packages = {
default = eser;
eser = eser;
};
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
deno
go
nodejs
bun
git
];
};
}
);
}