-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
138 lines (114 loc) · 5.62 KB
/
flake.nix
File metadata and controls
138 lines (114 loc) · 5.62 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
{
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.haskellNix.url = "github:input-output-hk/haskell.nix/9c5956641f45b6b02607e318485aad01c18e65b0";
inputs.gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
inputs.nixpkgs.url = "github:NixOS/nixpkgs/release-25.11";
outputs = { self, flake-utils, gitignore, haskellNix, nixpkgs }:
flake-utils.lib.eachSystem ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"] (system:
let
compiler-nix-name = "ghc9122";
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 {};
# Build go-parser from source (stdlib only, no vendorHash needed)
go-parser = pkgs.buildGoModule {
pname = "go-parser";
version = "0.1.0";
src = ./go-parser;
vendorHash = null;
meta = with pkgs.lib; {
description = "Go notebook code parser using go/scanner";
license = licenses.bsd3;
platforms = platforms.unix;
mainProgram = "go-parser";
};
};
mkWrapped = gnls: pkgs.runCommand "go-notebook-language-server-${gnls.version}-wrapped" {
nativeBuildInputs = [ pkgs.makeWrapper ];
} ''
mkdir -p $out/bin
makeWrapper ${gnls}/bin/go-notebook-language-server $out/bin/go-notebook-language-server \
--prefix PATH : ${go-parser}/bin
'';
packageForGitHub' = systemToUse: cnls: pkgs.runCommand "go-notebook-language-server-${cnls.version}-${systemToUse}" {} ''
name="go-notebook-language-server-${cnls.version}-${systemToUse}"
mkdir -p to_zip
cp -r ${cnls}/* to_zip
mkdir -p $out
tar -czvf $out/$name.tar.gz -C to_zip .
'';
in
{
devShells = {
default = pkgs.mkShell {
NIX_PATH = "nixpkgs=${pkgs.path}";
buildInputs = with pkgs; [
stack
haskell.compiler.ghc9122
pcre
zlib
go-parser
];
};
};
packages = (rec {
inherit (pkgs) cabal2nix stack;
default = static;
inherit go-parser;
dynamicWrapped = mkWrapped dynamic;
staticWrapped = mkWrapped static;
static = flakeStatic.packages."go-notebook-language-server:exe:go-notebook-language-server";
dynamic = flake.packages."go-notebook-language-server:exe:go-notebook-language-server";
darwin = flakeDarwin.packages."go-notebook-language-server:exe:go-notebook-language-server";
aarch64Linux = let
executable = flakeAarch64Linux.packages."go-notebook-language-server:exe:go-notebook-language-server";
libs = pkgs.callPackage ./nix/dynamic-aarch64-closure.nix {
inherit executable;
executableName = "go-notebook-language-server";
pkgsCross = pkgs.pkgsCross.aarch64-multiplatform;
};
in pkgs.runCommand "go-notebook-language-server-aarch64-dynamic" { passthru = { inherit (executable) version; }; } ''
mkdir -p $out/bin
cp -r ${executable}/bin/* $out/bin
cp -r ${libs}/lib/* $out/bin
'';
staticAarch64Linux = flakeStaticAarch64Linux.packages."go-notebook-language-server:exe:go-notebook-language-server";
# 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 go go-parser])}
'';
grandCombinedGithubArtifacts = pkgs.symlinkJoin {
name = "go-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)
];
};
nixpkgsPath = pkgs.writeShellScriptBin "nixpkgsPath.sh" "echo -n ${pkgs.path}";
# 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/go-notebook-language-server"
(echo "$(ldd ${dynamic}/bin/go-notebook-language-server)" | grep libgmp) && exit 1
exit 0
'';
});
inherit flake;
}
);
}