-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
90 lines (90 loc) · 2.56 KB
/
flake.nix
File metadata and controls
90 lines (90 loc) · 2.56 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
flake-utils.url = "github:numtide/flake-utils";
crane.url = "github:ipetkov/crane";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
# This is the last stable release with a Git version earlier than v2.48.0,
# which introduced a bug that sometimes causes `git fetch` to fail on
# partial clones like the one `npc` uses:
# https://lore.kernel.org/git/20251017155754.1425091-1-sam@samestep.com/
nixpkgs-git.url = "github:NixOS/nixpkgs/nixos-24.11";
};
outputs =
{
self,
nixpkgs,
flake-utils,
crane,
rust-overlay,
nixpkgs-git,
}:
let
env = pkgs: {
GIT_BIN = "${(import nixpkgs-git { system = pkgs.stdenv.hostPlatform.system; }).git}/bin/git";
NIX_BIN = "${pkgs.nix}/bin/nix";
NPC_REV = self.rev or "main";
};
overlay =
final: prev:
let
craneLib = crane.mkLib final;
commonArgs = {
src = craneLib.cleanCargoSource ./.;
strictDeps = true;
};
in
{
npc = craneLib.buildPackage (
commonArgs
// {
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
inherit (env final) GIT_BIN NIX_BIN NPC_REV;
}
);
};
in
{
overlays.default = overlay;
}
// flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
(import rust-overlay)
overlay
];
};
in
{
packages.default = pkgs.npc;
checks = {
build = pkgs.npc;
markdown-toc = pkgs.runCommand "npc-markdown-toc" { buildInputs = [ pkgs.markdown-toc ]; } ''
cp --no-preserve=mode ${./README.md} README.md
markdown-toc --bullets="-" -i README.md
diff ${./README.md} README.md
touch $out
'';
svg-term = pkgs.runCommand "npc-svg-term" { buildInputs = [ pkgs.svg-term ]; } ''
svg-term --window --in ${./example.cast} --out example.svg
diff ${./example.svg} example.svg
touch $out
'';
};
devShells.default = pkgs.mkShell {
buildInputs = [
pkgs.markdown-toc
pkgs.rust-bin.stable.latest.default
pkgs.svg-term
];
inherit (env pkgs) GIT_BIN NIX_BIN NPC_REV;
};
}
);
}