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 flake #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ WebAssembly backend.

[wasm-pack]: https://rustwasm.github.io/wasm-pack/

### Nix flake

There is a Nix flake available in the `contrib` directory. With it, you can get
a reproducible build of Jotdown by cloning the repo and running

```
$ nix build ./contrib
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is for development where it might be good to use 1.56 instead of nightly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not setup a derivation for building a development shell, just a derivation for building Jotdown itself. In it, I use the latest Rust, just to get the newest features and speed improvements. If you want, I could setup a development shell managed by Nix as well?

```

If you want to the run Jotdown CLI on any system that has Nix installed, you can
do it like this:

```
$ nix run github:hellux/jotdown?dir=contrib -- <arguments..>
```

## Status

### Correctness
Expand Down
121 changes: 121 additions & 0 deletions contrib/flake.lock

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

50 changes: 50 additions & 0 deletions contrib/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};

flake-utils.url = "github:numtide/flake-utils";

fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = {
nixpkgs,
crane,
flake-utils,
fenix,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
};

toolchain = with fenix.packages.${system};
combine [
default.rustc
default.cargo
default.clippy
default.rustfmt
];

craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
buildInputs = with pkgs; [];
in rec {
packages.default = craneLib.buildPackage {
inherit buildInputs;
src = pkgs.lib.cleanSourceWith {src = craneLib.path ../.;};
};

apps.default = flake-utils.lib.mkApp {
drv = packages.default;
};
});
}