-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathflake.nix
More file actions
134 lines (115 loc) · 3.5 KB
/
flake.nix
File metadata and controls
134 lines (115 loc) · 3.5 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{
description = "A command line tool with interactive TUI for managing financial investment portfolios written in Rust";
nixConfig = {
extra-substituters = [
"https://nix-community.cachix.org"
];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
crane,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = nixpkgs.legacyPackages.${system};
craneLib = crane.mkLib pkgs;
commonArgs = {
src = pkgs.lib.cleanSourceWith {
src = ./.;
filter = path: type:
(craneLib.filterCargoSources path type)
|| (pkgs.lib.hasSuffix ".json" path);
};
strictDeps = true;
nativeBuildInputs = with pkgs; [
pkg-config
];
buildInputs = with pkgs;
[
openssl
]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
libiconv
];
};
# Build just the dependencies (for faster incremental builds)
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# Build the actual package
portfolio_rs = craneLib.buildPackage (commonArgs
// {
inherit cargoArtifacts;
doCheck = false; # Tests are run via the separate portfolio_rs-test check
meta = with pkgs.lib; {
description = "Command line tool for managing financial investment portfolios";
homepage = "https://github.com/MarkusZoppelt/portfolio_rs";
license = licenses.mit;
maintainers = [maintainers.MarkusZoppelt];
mainProgram = "portfolio_rs";
};
});
in {
packages = {
default = portfolio_rs;
portfolio_rs = portfolio_rs;
};
# App for `nix run`
apps.default = flake-utils.lib.mkApp {
drv = portfolio_rs;
};
# Development shell
devShells.default = craneLib.devShell {
packages = with pkgs;
[
# Rust tooling
rust-analyzer
rustfmt
clippy
cargo-watch
cargo-audit
# Formatters
alejandra # Nix formatter
# Build dependencies
pkg-config
openssl
]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
libiconv
];
};
# Checks for `nix flake check`
checks = {
inherit portfolio_rs;
portfolio_rs-clippy = craneLib.cargoClippy (commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
portfolio_rs-fmt = craneLib.cargoFmt {
inherit (commonArgs) src;
};
portfolio_rs-test = craneLib.cargoTest (commonArgs
// {
inherit cargoArtifacts;
});
};
# Nix formatter for `nix fmt`
formatter = pkgs.alejandra;
}
)
// {
# Overlay for easy integration
overlays.default = final: prev: {
portfolio_rs = self.packages.${final.system}.portfolio_rs;
};
};
}