-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
88 lines (84 loc) · 3.25 KB
/
default.nix
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
{
nixpkgs ? import <nixpkgs> {},
haskell-tools ? import (builtins.fetchTarball "https://github.com/danwdart/haskell-tools/archive/master.tar.gz") {
nixpkgs = nixpkgs;
compiler = compiler;
},
compiler ? "ghc910"
}:
let
pkgsForX86 = if builtins.currentSystem == "x86_64-linux" then nixpkgs else nixpkgs.pkgsCross.gnu64.pkgsBuildHost;
pkgsX86 = if builtins.currentSystem == "x86_64-linux" then nixpkgs else nixpkgs.pkgsCross.gnu64.pkgsHostHost;
gitignore = nixpkgs.nix-gitignore.gitignoreSourcePure [ ./.gitignore ];
tools = haskell-tools compiler;
lib = pkgsX86.haskell.lib;
myHaskellPackages = pkgsX86.haskell.packages.${compiler}.override {
overrides = self: super: rec {
openfaas-examples = lib.dontHaddock (self.callCabal2nix "openfaas-examples" (gitignore ./.) {});
openfaas = self.callCabal2nix "openfaas" (nixpkgs.fetchFromGitHub {
owner = "JolHarg";
repo = "hs-openfaas";
rev = "dba4ac306637d2a61e374760e10c4eef655ae677";
sha256 = "U0rvcA+RuYtSO7tdELz9PZ1OFztpxCjMLVUl6dYFIjY=";
}) {};
# Tests for aeson don't work because they should be run as host
# "Couldn't find a target code interpreter. Try with -fexternal-interpreter"
aeson = if builtins.currentSystem == "x86_64-linux" then super.aeson else lib.dontCheck super.aeson;
};
};
shell = myHaskellPackages.shellFor {
packages = p: [
p.openfaas-examples
];
shellHook = ''
gen-hie > hie.yaml
for i in $(find -type f | grep -v dist-newstyle); do krank $i; done
cabal update
build() {
nix-build -A openfaas-examples -o build
for PACKAGE in packages/*/*/
do
rm -rf $PACKAGE/openfaas-examples
cp build/bin/openfaas-examples $PACKAGE/openfaas-examples
rm -rf $PACKAGE/*.so*
cp ${pkgsX86.libffi.outPath}/lib64/libffi.so.8.1.2 $PACKAGE/libffi.so.8
cp ${pkgsX86.gmp.outPath}/lib/libgmp.so.10.5.0 $PACKAGE/libgmp.so.10
cp ${pkgsX86.glibc.outPath}/lib/{libc.so.6,libm.so.6,librt.so.1,libdl.so.2,ld-linux-x86-64.so.2} $PACKAGE/
#x86_64-unknown-linux-gnu-strip $PACKAGE/openfaas-examples
chmod +w $PACKAGE/*
patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 $PACKAGE/libc.so.6
done
}
clean() {
git clean -Xf packages
}
[[ -f packages/openfaas-examples/debug/libc.so.6 ]] || build
# wget -c https://raw.githubusercontent.com/oufm/packelf/master/packelf.sh
# chmod +x packelf.sh
# export GHC=${if builtins.currentSystem == "aarch64-linux" then "x86_64-unknown-linux-ghc" else "ghc"}
'';
buildInputs = tools.defaultBuildTools ++ (with nixpkgs; [
nodejs_20
closurecompiler
pkgsForX86.cabal-install
pkgsForX86.gcc
pkgsX86.gmp
pkgsX86.libffi
pkgsX86.glibc
]);
nativeBuildInputs = tools.defaultBuildTools ++ (with nixpkgs; [
nodejs_20
closurecompiler
pkgsForX86.cabal-install
pkgsForX86.gcc
pkgsX86.gmp
pkgsX86.libffi
pkgsX86.glibc
]);
withHoogle = false;
};
in
{
inherit shell;
openfaas-examples = lib.justStaticExecutables (myHaskellPackages.openfaas-examples);
}