Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
107 lines (92 loc) · 3.1 KB
/
Copy pathflake.nix
File metadata and controls
107 lines (92 loc) · 3.1 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# AI generated and untested because I don't know nix.
{
description = "A fuzzy finder for the terminal, powered by nucleo";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
inherit (pkgs) lib;
# Use the latest stable Rust toolchain
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" "rust-analyzer" ];
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
# Source filtering to include only relevant files
# This helps avoid unnecessary rebuilds when non-source files change
src = lib.cleanSourceWith {
src = ./.;
filter = path: type:
(lib.hasSuffix ".rs" path) ||
(lib.hasSuffix ".toml" path) ||
(lib.hasSuffix ".lock" path) ||
(lib.hasInfix "/assets/" path) ||
(craneLib.filterCargoSources path type);
};
# Common arguments for craneLib functions
commonArgs = {
inherit src;
strictDeps = true;
# Runtime dependencies
buildInputs = with pkgs; [
# Add runtime dependencies here
] ++ lib.optionals stdenv.isDarwin [
libiconv
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.AppKit
];
# Build-time dependencies
nativeBuildInputs = with pkgs; [
pkg-config
];
};
# Build *just* the cargo dependencies
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# Build the main package
matchmaker = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
pname = "matchmaker";
cargoExtraArgs = "-p matchmaker-cli";
});
in
{
packages.default = matchmaker;
packages.matchmaker = matchmaker;
apps.default = flake-utils.lib.mkApp {
drv = matchmaker;
name = "mm";
};
devShells.default = craneLib.devShell {
inherit (commonArgs) buildInputs nativeBuildInputs;
packages = with pkgs; [
just
];
};
# Integration with `nix flake check`
checks = {
inherit matchmaker;
matchmaker-clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
matchmaker-fmt = craneLib.cargoFmt {
inherit src;
};
};
});
}