Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to flake-parts and nci #167

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
52 changes: 52 additions & 0 deletions crates.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{ ... }: {
perSystem = { pkgs, lib, ... }: {
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;
};
in
{
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"
'';

preBuild = ''
export ANTE_STDLIB_DIR=$out/lib
find stdlib -type f -exec install -Dm644 "{}" -t $ANTE_STDLIB_DIR \;
'';

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)
'';
};
};
};
};
};
}
63 changes: 10 additions & 53 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,53 +1,10 @@
let
ante =
{ installShellFiles
, lib
, libffi
, libxml2
, llvmPackages
, ncurses
, rustPlatform
}:

let
major = lib.versions.major llvmPackages.llvm.version;
minor = lib.versions.minor llvmPackages.llvm.version;
llvm-sys-ver = "${major}${builtins.substring 0 1 minor}";
toml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
in

rustPlatform.buildRustPackage {
pname = "ante";
src = ./.;
inherit (toml.package) version;
cargoHash = "sha256-Mn5LukLn9bz8Z4YTNEk4CK5ItYFRngoB7Zp9XJVhM74=";

nativeBuildInputs = [ llvmPackages.llvm installShellFiles ];
buildInputs = [ libffi libxml2 ncurses ];

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

shellHook = ''
export LLVM_SYS_${llvm-sys-ver}_PREFIX=${llvmPackages.llvm.dev}
'';

preBuild = ''
$shellHook
export ANTE_STDLIB_DIR=$out/lib
mkdir -p $ANTE_STDLIB_DIR
cp -r $src/stdlib/* $ANTE_STDLIB_DIR
'';

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)
'';
};
in
{ pkgs ? import <nixpkgs> { } }: with pkgs;
callPackage ante { llvmPackages = llvmPackages_13; }
(import
(
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }
).defaultNix
207 changes: 191 additions & 16 deletions flake.lock

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

Loading