-
Notifications
You must be signed in to change notification settings - Fork 33
/
flake.nix
105 lines (97 loc) · 3.16 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
{
description = "Idris 2 Language Server";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
idris = {
url = "github:idris-lang/Idris2";
inputs.nixpkgs.follows = "nixpkgs";
};
lspLib = {
url = "github:idris-community/LSP-lib";
inputs.nixpkgs.follows = "nixpkgs";
inputs.idris.follows = "idris";
inputs.idris2Lsp.follows = "idris2Lsp";
};
alejandra = {
url = "github:kamadorueda/alejandra/3.0.0";
inputs.nixpkgs.follows = "nixpkgs";
};
# chicken-and-egg situation: we don't want the version of the
# LSP we use to develop this package to use the version of Idris
# we are currently developing against or else you could not use
# a functioning LSP while addressing breaking changes.
idris2Lsp = {
url = "github:idris-community/idris2-lsp";
inputs.nixpkgs.follows = "nixpkgs";
inputs.alejandra.follows = "alejandra";
};
};
outputs = {
self,
nixpkgs,
alejandra,
idris,
lspLib,
idris2Lsp,
...
}: let
lib = nixpkgs.lib;
# support the same systems as Idris2
systems = builtins.attrNames idris.packages;
forEachSystem = with lib;
mkOutputs: let
outputsForSystem = system:
concatMapAttrs (k: v: {${k}.${system} = v;}) (mkOutputs system);
in
foldl' recursiveUpdate {} (map outputsForSystem systems);
in
forEachSystem (
system: let
pkgs = nixpkgs.legacyPackages.${system};
idrisPkgs = idris.packages.${system};
buildIdris = idris.buildIdris.${system};
lspLib' = lspLib.packages.${system}.default;
supportLibrariesPath = lib.makeLibraryPath [idrisPkgs.support];
supportSharePath = lib.makeSearchPath "share" [idrisPkgs.support];
globalLibraries = let
idrName = "idris2-${idris.version}";
in [
"\\$HOME/.nix-profile/lib/${idrName}"
"/run/current-system/sw/lib/${idrName}"
"${idrisPkgs.idris2}/${idrName}"
];
globalLibrariesPath = builtins.concatStringsSep ":" globalLibraries;
lspPkg = buildIdris {
ipkgName = "idris2-lsp";
inherit (idris) version;
src = ./.;
idrisLibraries = [idrisPkgs.idris2Api lspLib'];
buildInputs = [pkgs.makeWrapper];
postInstall = ''
wrapProgram $out/bin/idris2-lsp \
--run 'export IDRIS2_PREFIX=''${IDRIS2_PREFIX-"$HOME/.idris2"}' \
--suffix IDRIS2_LIBS ':' "${supportLibrariesPath}" \
--suffix IDRIS2_DATA ':' "${supportSharePath}" \
--suffix IDRIS2_PACKAGE_PATH ':' "${globalLibrariesPath}"
'';
};
in {
packages =
idrisPkgs
// rec {
idris2Lsp = lspPkg.executable;
default = idris2Lsp;
};
formatter = alejandra.packages.${system}.default;
devShells = {
default = nixpkgs.legacyPackages.${system}.mkShell {
inputsFrom = [self.packages.${system}.default];
packages = [
idris2Lsp.packages.${system}.default
idrisPkgs.idris2
];
};
};
}
);
}