-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathflake.nix
110 lines (89 loc) · 2.7 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
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
{
description = "Leet your code in command-line.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
utils,
naersk,
rust-overlay,
...
}:
utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = (import nixpkgs) {
inherit system overlays;
};
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
naersk' = pkgs.callPackage naersk {
cargo = toolchain;
rustc = toolchain;
clippy = toolchain;
};
nativeBuildInputs = with pkgs; [
pkg-config
];
darwinBuildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.Security
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
];
buildInputs = with pkgs; [
openssl
dbus
sqlite
] ++ darwinBuildInputs;
package = naersk'.buildPackage rec {
pname = "leetcode-cli";
version = "git";
src = ./.;
doCheck = true; # run `cargo test` on build
inherit buildInputs nativeBuildInputs;
buildNoDefaultFeatures = true;
buildFeatures = "git";
meta = with pkgs.lib; {
description = "Leet your code in command-line.";
homepage = "https://github.com/clearloop/leetcode-cli";
licenses = licenses.mit;
maintainers = with maintainers; [ congee ];
mainProgram = "leetcode";
};
# Env vars
# a nightly compiler is required unless we use this cheat code.
RUSTC_BOOTSTRAP = 0;
# CFG_RELEASE = "${rustPlatform.rust.rustc.version}-stable";
CFG_RELEASE_CHANNEL = "stable";
};
in
{
defaultPackage = package;
overlay = final: prev: { leetcode-cli = package; };
devShell = with pkgs; mkShell {
name = "shell";
inherit nativeBuildInputs;
buildInputs = buildInputs ++ [
toolchain
cargo-edit
cargo-bloat
cargo-audit
cargo-about
cargo-outdated
];
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
RUST_BACKTRACE = "full";
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
};
}
);
}