-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
flake.nix
65 lines (57 loc) · 1.83 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{
description = "Rust-based parser for nix files";
inputs = {
utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
import-cargo.url = "github:edolstra/import-cargo";
};
# first comment
# second comment
outputs = { self, nixpkgs, utils, import-cargo }:
{
overlay = final: prev: let
target = final.rust.toRustTarget final.stdenv.hostPlatform;
flags = "--release --offline --target ${target}";
inherit (import-cargo.builders) importCargo;
in {
rnix-parser = final.stdenv.mkDerivation {
pname = "rnix-parser";
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version;
src = final.lib.cleanSource ./.;
nativeBuildInputs = with final; [
rustc cargo
(importCargo { lockFile = ./Cargo.lock; inherit (final) pkgs; }).cargoHome
];
outputs = [ "out" "doc" ];
doCheck = true;
buildPhase = ''
cargo build ${flags}
cargo doc ${flags}
'';
checkPhase = ''
cargo test ${flags}
cargo bench
'';
installPhase = ''
mkdir -p $out/lib
mkdir -p $doc/share/doc/rnix
cp -r ./target/${target}/doc $doc/share/doc/rnix
cp ./target/${target}/release/librnix.rlib $out/lib/
'';
};
};
}
// utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; overlays = [ self.overlay ]; };
in
rec {
# `nix develop`
devShell = pkgs.mkShell {
buildInputs = with pkgs; [ rustfmt rustc cargo clippy ];
};
packages.rnix-parser = pkgs.rnix-parser;
defaultPackage = packages.rnix-parser;
}
);
}