Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
163 lines (132 loc) · 6.91 KB
/
Copy pathflake.nix
File metadata and controls
163 lines (132 loc) · 6.91 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
{
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.haskellNix.url = "github:input-output-hk/haskell.nix/1dde0b46d3daa5bf0ff3ea6332d579a1943b4a0c";
inputs.gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
inputs.nixpkgs.url = "github:NixOS/nixpkgs/7993f34ee47e28a3d607a525aadc6c94b73be728";
inputs.linux-dynamic-bundler.url = "github:codedownio/linux-dynamic-bundler";
outputs = { self, flake-utils, gitignore, haskellNix, nixpkgs, linux-dynamic-bundler }:
flake-utils.lib.eachSystem ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"] (system:
let
compiler-nix-name = "ghc9124";
overlays = [
haskellNix.overlay
# Set enableNativeBignum flag on compiler
(import ./nix/overlays/native-bignum.nix { inherit compiler-nix-name; })
# Configure hixProject
(import ./nix/overlays/hix-project.nix { inherit compiler-nix-name gitignore system; })
];
pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; };
flake = (pkgs.hixProject compiler-nix-name).flake {};
flakeStatic = (pkgs.pkgsCross.musl64.hixProject compiler-nix-name).flake {};
flakeDarwin = (pkgs.pkgsCross.aarch64-darwin.hixProject compiler-nix-name).flake {};
flakeAarch64Linux = (pkgs.pkgsCross.aarch64-multiplatform.hixProject compiler-nix-name).flake {};
flakeStaticAarch64Linux = (pkgs.pkgsCross.aarch64-multiplatform-musl.hixProject compiler-nix-name).flake {};
aarch64LinuxExe = flakeAarch64Linux.packages."java-notebook-language-server:exe:java-notebook-language-server";
packageForGitHub = packageForGitHub' system;
packageForGitHub' = systemToUse: jnls: pkgs.runCommand "java-notebook-language-server-${jnls.version}-${systemToUse}" {} ''
name="java-notebook-language-server-${jnls.version}-${systemToUse}"
mkdir -p to_zip
cp -r ${jnls}/* to_zip
mkdir -p $out
tar -czvf $out/$name.tar.gz -C to_zip .
'';
# The snippet classifier. See java-parser/default.nix.
java-parser = pkgs.callPackage ./java-parser {};
mkWrapped = jnls: pkgs.runCommand "java-notebook-language-server-${jnls.version}-wrapped" {
nativeBuildInputs = [ pkgs.makeWrapper ];
} ''
mkdir -p $out/bin
makeWrapper ${jnls}/bin/java-notebook-language-server $out/bin/java-notebook-language-server \
--prefix PATH : ${java-parser}/bin
'';
testExe = flake.packages."java-notebook-language-server:test:java-notebook-language-server-test";
devShellInputs = with pkgs; [
stack
haskell.compiler.ghc9124
pcre
zlib
java-parser
];
in
{
devShells = {
default = pkgs.mkShell {
NIX_PATH = "nixpkgs=${pkgs.path}";
buildInputs = devShellInputs;
};
};
packages = (rec {
inherit (pkgs) cabal2nix stack;
default = static;
inherit java-parser;
dynamicWrapped = mkWrapped dynamic;
staticWrapped = mkWrapped static;
tests = pkgs.runCommand "java-notebook-language-server-tests" {
nativeBuildInputs = [pkgs.makeWrapper];
} ''
mkdir -p $out/bin
makeWrapper ${testExe}/bin/java-notebook-language-server-test $out/bin/java-notebook-language-server-test \
--prefix PATH : ${java-parser}/bin
'';
static = flakeStatic.packages."java-notebook-language-server:exe:java-notebook-language-server";
dynamic = flake.packages."java-notebook-language-server:exe:java-notebook-language-server";
darwin = flakeDarwin.packages."java-notebook-language-server:exe:java-notebook-language-server";
aarch64Linux = let
executable = aarch64LinuxExe;
in linux-dynamic-bundler.lib.bundle {
inherit pkgs;
binaryDrv = executable;
binaryName = "java-notebook-language-server";
};
staticAarch64Linux = flakeStaticAarch64Linux.packages."java-notebook-language-server:exe:java-notebook-language-server";
grandCombinedGithubArtifacts = pkgs.symlinkJoin {
name = "java-notebook-language-server-grand-combined-artifacts";
paths = [
(packageForGitHub' "x86_64-linux" self.packages.x86_64-linux.static)
(packageForGitHub' "aarch64-linux" aarch64Linux)
(packageForGitHub' "x86_64-darwin" self.packages.x86_64-darwin.dynamic)
(packageForGitHub' "aarch64-darwin" self.packages.aarch64-darwin.dynamic)
];
};
# Print a trivial PATH that we can use to run kernel and LSP tests, to ensure
# they aren't depending on anything on the test machine's PATH.
print-basic-path = pkgs.writeShellScriptBin "basic-path.sh" ''
echo ${pkgs.lib.makeBinPath (with pkgs; [coreutils bash])}
'';
# No GMP (we test the dynamic builds to make sure GMP doesn't end up in the static builds)
verify-no-gmp = pkgs.writeShellScriptBin "verify-no-gmp.sh" ''
echo "Checking for libgmp in ${dynamic}/bin/java-notebook-language-server"
(echo "$(ldd ${dynamic}/bin/java-notebook-language-server)" | grep libgmp) && exit 1
exit 0
'';
gcroots = let
# Our own components rebuild on any source change, so only the deps are worth rooting.
inputsOf = d: pkgs.lib.filter (p: !(pkgs.lib.hasInfix "java-notebook-language-server" (p.name or "")))
(d.buildInputs ++ d.nativeBuildInputs);
# The cross builds can't be made from darwin, where the native build is what matters.
hostInputs = if pkgs.stdenv.hostPlatform.isDarwin
then inputsOf dynamic
else inputsOf dynamic ++ inputsOf static ++ inputsOf aarch64LinuxExe;
in pkgs.writeText "java-notebook-language-server-gc-roots" ''
${pkgs.symlinkJoin {
name = "java-notebook-language-server-deps";
paths = pkgs.lib.unique (hostInputs ++ devShellInputs);
}}
'';
nixpkgsPath = pkgs.writeShellScriptBin "nixpkgsPath.sh" "echo -n ${pkgs.path}";
});
inherit flake;
}
);
# nixConfig = {
# # This sets the flake to use the IOG nix cache.
# # Nix should ask for permission before using it,
# # but remove it here if you do not want it to.
# extra-substituters = ["https://cache.iog.io"];
# extra-tcpped-public-keys = ["hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="];
# allow-import-from-derivation = "true";
# };
}