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

Add Nix shell #1565

Merged
merged 21 commits into from
Dec 20, 2024
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Available as a command-line utility, a library and a [GitHub Action](https://git
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
## Table of Contents

- [Development](#development)
- [Installation](#installation)
- [Features](#features)
- [Commandline usage](#commandline-usage)
Expand All @@ -34,6 +35,12 @@ Available as a command-line utility, a library and a [GitHub Action](https://git

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Development

After [installing Rust](https://www.rust-lang.org/tools/install) use [Cargo](https://doc.rust-lang.org/cargo/) for building and testing.
thomas-zahner marked this conversation as resolved.
Show resolved Hide resolved
On Linux the OpenSSL package [is required](https://github.com/seanmonstar/reqwest?tab=readme-ov-file#requirements) to compile `reqwest`, a dependency of lychee.
For Nix we provide a flake so you can use `nix develop` and `nix build`.

## Installation

### Arch Linux
Expand Down
62 changes: 62 additions & 0 deletions flake.lock

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

67 changes: 67 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
description = "A flake for building and developing lychee";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
};

outputs =
{
nixpkgs,
rust-overlay,
self,
...
}:
let
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
rustVersion = "latest"; # using a specific version: "1.62.0"
in
{
devShells = forAllSystems (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
rust = pkgs.rust-bin.stable.${rustVersion}.default.override {
extensions = [
"rust-src" # for rust-analyzer
"rust-analyzer" # usable by IDEs like zed-editor
"clippy"
];
};
in
{
default = pkgs.mkShell {
packages = [
pkgs.pkg-config
pkgs.openssl
rust
];
};
}
);

packages = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
default = pkgs.lychee.overrideAttrs {
src = ./.;
version = self.rev or self.dirtyShortRev;
cargoDeps = pkgs.rustPlatform.importCargoLock {
lockFile = ./Cargo.lock;
};
};
}
);
};
}
Loading