-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
112 lines (91 loc) · 4.2 KB
/
flake.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
{
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.haskellNix.url = "github:input-output-hk/haskell.nix/angerman/fix-install_name_tool";
inputs.gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
inputs.nixpkgs.url = "github:NixOS/nixpkgs/release-24.05";
inputs.nixpkgsMaster.url = "github:NixOS/nixpkgs/master";
outputs = { self, flake-utils, gitignore, haskellNix, nixpkgs, nixpkgsMaster }:
flake-utils.lib.eachSystem ["x86_64-linux" "x86_64-darwin" "aarch64-darwin"] (system:
let
compiler-nix-name = "ghc966";
overlays = [
haskellNix.overlay
# Set enableNativeBignum flag on compiler
(final: prev: {
haskell-nix = let
shouldPatch = name: compiler: prev.lib.hasPrefix compiler-nix-name name;
overrideCompiler = name: compiler: (compiler.override {
enableNativeBignum = true;
});
in
prev.lib.recursiveUpdate prev.haskell-nix {
compiler = prev.lib.mapAttrs overrideCompiler (prev.lib.filterAttrs shouldPatch prev.haskell-nix.compiler);
};
})
# Configure hixProject
(final: prev: {
hixProject = compiler-nix-name:
final.haskell-nix.hix.project {
src = gitignore.lib.gitignoreSource ./.;
evalSystem = system;
inherit compiler-nix-name;
modules = [{
packages.rust-notebook-language-server.components.exes.rust-notebook-language-server.dontStrip = false;
} (
pkgs.lib.optionalAttrs pkgs.stdenv.isDarwin (import ./nix/macos-modules.nix { inherit pkgs; })
)];
};
})
];
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 {};
packageForGitHub = rnls: pkgs.runCommand "rust-notebook-language-server-${rnls.version}-${system}" {} ''
name="rust-notebook-language-server-${rnls.version}-${system}"
mkdir -p $out
cp ${rnls}/bin/rust-notebook-language-server $out/$name
cd $out
tar -czvf $name.tar.gz $name
'';
in
{
packages = (rec {
inherit (pkgs) cabal2nix stack;
default = static;
static = flakeStatic.packages."rust-notebook-language-server:exe:rust-notebook-language-server";
dynamic = flake.packages."rust-notebook-language-server:exe:rust-notebook-language-server";
githubArtifacts = packageForGitHub (if pkgs.stdenv.isDarwin then dynamic else static);
grandCombinedGithubArtifacts = pkgs.symlinkJoin {
name = "rust-notebook-language-server-grand-combined-artifacts";
paths = [
self.packages.x86_64-linux.githubArtifacts
self.packages.x86_64-darwin.githubArtifacts
self.packages.aarch64-darwin.githubArtifacts
];
};
# 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/rust-notebook-language-server"
(echo "$(ldd ${dynamic}/bin/rust-notebook-language-server)" | grep libgmp) && exit 1
exit 0
'';
nixpkgsPath = let
pkgsMaster = import nixpkgsMaster { inherit system; };
in
pkgsMaster.writeShellScriptBin "nixpkgsPath.sh" "echo -n ${pkgsMaster.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-trusted-public-keys = ["hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="];
# allow-import-from-derivation = "true";
# };
}