Skip to content

Commit

Permalink
Update flake to include the language server (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehllie authored Jan 25, 2024
1 parent dbfee06 commit 5bed8cc
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 37 deletions.
2 changes: 1 addition & 1 deletion ante-ls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
ante = { path = ".." }
ante = { path = "..", default-features = false }
dashmap = "5.5.3"
env_logger = "0.10.2"
futures = "0.3.30"
Expand Down
87 changes: 55 additions & 32 deletions crates.nix
Original file line number Diff line number Diff line change
@@ -1,53 +1,76 @@
{ ... }: {
perSystem = { pkgs, lib, ... }: {
{
perSystem = { pkgs, lib, config, ... }: {
nci =
let
llvmPackages = pkgs.llvmPackages_16;
major = lib.versions.major llvmPackages.llvm.version;
minor = lib.versions.minor llvmPackages.llvm.version;
llvm-sys-ver = "${major}${builtins.substring 0 1 minor}";
env = {
"LLVM_SYS_${llvm-sys-ver}_PREFIX" = llvmPackages.llvm.dev;
env = { "LLVM_SYS_${llvm-sys-ver}_PREFIX" = llvmPackages.llvm.dev; };

stdlib = pkgs.stdenv.mkDerivation {
pname = "ante-stdlib";
version = config.packages.ante.version;
src = ./stdlib;
phases = [ "unpackPhase" "installPhase" ];
installPhase = ''
find . -type f -exec install -Dm644 "{}" -t $out/lib \;
'';
};
in
{
toolchainConfig = {
channel = "stable";
components = [ "rust-analyzer" "clippy" "rustfmt" "rust-src" ];
};
projects.ante.path = ./.;
crates.ante = {
depsDrvConfig = {
inherit env;
};
drvConfig = {
inherit env;
mkDerivation = {
nativeBuildInputs = [ pkgs.installShellFiles ];
buildInputs = lib.attrValues
{
inherit (pkgs)
libffi
libxml2
ncurses;
} ++ [ llvmPackages.llvm ];

postPatch = ''
substituteInPlace tests/golden_tests.rs --replace \
'target/debug' "target/$(rustc -vV | sed -n 's|host: ||p')/release"
'';
projects.ante = {
export = false;
path = ./.;
};

crates = {
ante-ls = {
profiles.release.features = [ ];
drvConfig.mkDerivation = {
preBuild = ''
export ANTE_STDLIB_DIR=$out/lib
find stdlib -type f -exec install -Dm644 "{}" -t $ANTE_STDLIB_DIR \;
export ANTE_STDLIB_DIR=${stdlib}/lib
'';
};
};

postInstall = ''
installShellCompletion --cmd ante \
--bash <($out/bin/ante --shell-completion bash) \
--fish <($out/bin/ante --shell-completion fish) \
--zsh <($out/bin/ante --shell-completion zsh)
'';
ante = {
depsDrvConfig = {
inherit env;
};
drvConfig = {
inherit env;
mkDerivation = {
nativeBuildInputs = [ pkgs.installShellFiles ];
buildInputs = lib.attrValues
{
inherit (pkgs)
libffi
libxml2
ncurses;
} ++ [ llvmPackages.llvm stdlib ];

postPatch = ''
substituteInPlace tests/golden_tests.rs --replace \
'target/debug' "target/$(rustc -vV | sed -n 's|host: ||p')/release"
'';

preBuild = ''
export ANTE_STDLIB_DIR=${stdlib}/lib
'';

postInstall = ''
installShellCompletion --cmd ante \
--bash <($out/bin/ante --shell-completion bash) \
--fish <($out/bin/ante --shell-completion fish) \
--zsh <($out/bin/ante --shell-completion zsh)
'';
};
};
};
};
Expand Down
19 changes: 15 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,22 @@
];

perSystem = { config, ... }:
let crateOutputs = config.nci.outputs.ante; in
let
anteCrate = config.nci.outputs.ante;
ante-lsCrate = config.nci.outputs.ante-ls;
in
{
overlayAttrs.ante = config.packages.default;
packages.default = crateOutputs.packages.release;
devShells.default = crateOutputs.devShell.overrideAttrs (_: {
overlayAttrs = {
inherit (config.packages)
ante
ante-ls;
};
packages = rec {
default = ante;
ante = anteCrate.packages.release;
ante-ls = ante-lsCrate.packages.release;
};
devShells.default = anteCrate.devShell.overrideAttrs (_: {
shellHook = ''
PATH=$PATH:$PWD/target/debug
'';
Expand Down

0 comments on commit 5bed8cc

Please sign in to comment.