Skip to content

Commit

Permalink
Add a Nix flake (take 2) (#210)
Browse files Browse the repository at this point in the history
* underpinnings of flake for LSP

* use LSP-lib. specify the same ENV as the compiler is wrapped in for the LSP executable.

* update Idris2 and LSP-lib submodules to latest commits
  • Loading branch information
mattpolzin authored Jan 14, 2024
1 parent 9e44cee commit 6c3475d
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@
/tests/**/output

src/Server/Generated.idr

#nix build output
/result
2 changes: 1 addition & 1 deletion Idris2
Submodule Idris2 updated 61 files
+1 −1 .github/pull_request_template.md
+2 −2 .github/workflows/ci-idris2-and-libs.yml
+3 −2 CHANGELOG.md
+54 −0 CHANGELOG_NEXT.md
+1 −1 CONTRIBUTING.md
+1 −0 CONTRIBUTORS
+21 −7 Makefile
+1 −1 Release/CHECKLIST
+10 −1 bootstrap-stage1-chez.sh
+7 −5 bootstrap-stage2.sh
+18 −3 flake.nix
+0 −4 idris2api.ipkg
+1 −1 libs/base/Data/List/Lazy.idr
+0 −0 libs/base/Data/List/Lazy/Quantifiers.idr
+6 −0 libs/base/Data/List/Quantifiers.idr
+15 −0 libs/base/Data/Primitives/Interpolation.idr
+2 −2 libs/base/Deriving/Common.idr
+3 −0 libs/base/base.ipkg
+94 −36 libs/contrib/System/Console/GetOpt.idr
+0 −3 libs/contrib/contrib.ipkg
+5 −5 libs/prelude/Builtin.idr
+3 −3 libs/prelude/Prelude/Show.idr
+33 −13 nix/buildIdris.nix
+34 −13 nix/package.nix
+24 −0 nix/support.nix
+2 −2 nix/templates/pkg/flake.nix
+5 −4 nix/templates/pkgWithDeps/flake.nix
+4 −4 nix/test.nix
+7 −2 src/Compiler/ES/Node.idr
+2 −3 src/Core/Binary/Prims.idr
+0 −2 src/Core/CompileExpr/Pretty.idr
+2 −1 src/Core/Name/Scoped.idr
+1 −1 src/Idris/Driver.idr
+1 −1 src/Idris/Pretty/Render.idr
+1 −39 src/Libraries/Data/List/HasLength.idr
+157 −13 src/Libraries/Data/List/Lazy.idr
+3 −1 src/Libraries/Data/List/Quantifiers/Extra.idr
+4 −3 src/Libraries/Data/List/SizeOf.idr
+1 −1 src/Libraries/Data/SnocList/HasLength.idr
+1 −1 src/Libraries/Data/SnocList/SizeOf.idr
+23 −4 src/Libraries/Data/String/Iterator.idr
+1 −3 src/Libraries/System/Directory/Tree.idr
+0 −27 src/Libraries/System/File.idr
+0 −101 src/Libraries/System/File/Buffer.idr
+0 −110 src/Libraries/System/File/Meta.idr
+1 −1 src/Libraries/Utils/Binary.idr
+0 −29 src/Libraries/Utils/Term.idr
+2 −1 support/js/support_system_file.js
+1 −1 tests/Makefile
+104 −0 tests/contrib/getOpt001/UseGetOpt.idr
+203 −0 tests/contrib/getOpt001/expected
+42 −0 tests/contrib/getOpt001/run
+6 −0 tests/contrib/getOpt001/test.ipkg
+12 −0 tests/idris2/total/total020/Check.idr
+6 −0 tests/node/executable/TestExecutable.idr
+2 −0 tests/node/executable/expected
+19 −0 tests/node/executable/run
+11 −0 tests/refc/callingConvention/Main.idr
+691 −0 tests/refc/callingConvention/expected
+5 −0 tests/refc/callingConvention/run
+4 −2 tests/testutils.sh
2 changes: 1 addition & 1 deletion LSP-lib
Submodule LSP-lib updated 3 files
+3 −0 .gitignore
+80 −0 flake.lock
+33 −0 flake.nix
5 changes: 5 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(import (fetchTarball
"https://github.com/edolstra/flake-compat/archive/master.tar.gz") {
src = builtins.fetchGit ./.;
})
.defaultNix
183 changes: 183 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 83 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
description = "Idris 2 Language Server";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs";

idris = {
url = "github:idris-lang/Idris2";
inputs.nixpkgs.follows = "nixpkgs";
};

lsp-lib = {
url = "github:idris-community/LSP-lib";
inputs.nixpkgs.follows = "nixpkgs";
inputs.idris.follows = "idris";
};

alejandra = {
url = "github:kamadorueda/alejandra/3.0.0";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = {
self,
nixpkgs,
alejandra,
idris,
lsp-lib,
}: 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 = lsp-lib.packages.${system}.default;
supportLibrariesPath = lib.makeLibraryPath [idrisPkgs.support];
supportSharePath = lib.makeSearchPath "share" [idrisPkgs.support];

globalLibraries = let
idrName = "idris2-${idris.version}";
libSuffix = "lib/${idrName}";
in [
"\\$HOME/.nix-profile/lib/${idrName}"
"/run/current-system/sw/lib/${idrName}"
"${idrisPkgs.idris2}/${idrName}"
];
globalLibrariesPath = builtins.concatStringsSep ":" globalLibraries;

lspPkg = buildIdris {
projectName = "idris2-lsp";
src = ./.;
idrisLibraries = [idrisPkgs.idris2-api 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 rec {
packages =
idrisPkgs
// rec {
idris2-lsp = lspPkg.executable;
default = idris2-lsp;
};
formatter = alejandra.packages.${system}.default;
}
);
}

0 comments on commit 6c3475d

Please sign in to comment.