Skip to content

Commit 473954d

Browse files
committed
Update flake dependencies and add formatting support
Add treefmt-nix input for code formatting with nixfmt, rustfmt, and taplo. Update nixpkgs, naersk, rust-overlay, and flake-utils to latest versions. Modernize flake outputs structure and improve package metadata.
1 parent 1223a7b commit 473954d

File tree

3 files changed

+142
-56
lines changed

3 files changed

+142
-56
lines changed

flake.lock

Lines changed: 33 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 101 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
2-
description = "Leet your code in command-line.";
2+
description = "Leet your code in command-line. Forked by yousiki.";
33

44
inputs = {
55
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6+
67
utils.url = "github:numtide/flake-utils";
78

89
naersk = {
@@ -14,17 +15,25 @@
1415
url = "github:oxalica/rust-overlay";
1516
inputs.nixpkgs.follows = "nixpkgs";
1617
};
18+
19+
treefmt-nix = {
20+
url = "github:numtide/treefmt-nix";
21+
inputs.nixpkgs.follows = "nixpkgs";
22+
};
1723
};
1824

19-
outputs = {
20-
self,
21-
nixpkgs,
22-
utils,
23-
naersk,
24-
rust-overlay,
25-
...
25+
outputs =
26+
{
27+
self,
28+
nixpkgs,
29+
utils,
30+
naersk,
31+
rust-overlay,
32+
treefmt-nix,
33+
...
2634
}:
27-
utils.lib.eachDefaultSystem (system:
35+
utils.lib.eachDefaultSystem (
36+
system:
2837
let
2938
overlays = [ (import rust-overlay) ];
3039

@@ -36,43 +45,61 @@
3645

3746
naersk' = pkgs.callPackage naersk {
3847
cargo = toolchain;
39-
rustc = toolchain;
4048
clippy = toolchain;
49+
rustc = toolchain;
4150
};
4251

4352
nativeBuildInputs = with pkgs; [
4453
pkg-config
4554
];
4655

47-
darwinBuildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [
48-
pkgs.darwin.apple_sdk.frameworks.Security
49-
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
50-
];
56+
darwinBuildInputs =
57+
with pkgs;
58+
lib.optionals stdenv.isDarwin [
59+
apple-sdk
60+
];
61+
62+
buildInputs =
63+
with pkgs;
64+
[
65+
dbus
66+
openssl
67+
sqlite
68+
]
69+
++ darwinBuildInputs;
5170

52-
buildInputs = with pkgs; [
53-
openssl
54-
dbus
55-
sqlite
56-
] ++ darwinBuildInputs;
71+
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
72+
73+
version = cargoToml.package.version;
74+
75+
package = naersk'.buildPackage {
76+
inherit version buildInputs nativeBuildInputs;
5777

58-
package = naersk'.buildPackage rec {
5978
pname = "leetcode-cli";
60-
version = "git";
6179

6280
src = ./.;
81+
6382
doCheck = true; # run `cargo test` on build
6483

65-
inherit buildInputs nativeBuildInputs;
84+
cargoTestOptions =
85+
x:
86+
x
87+
++ [
88+
"--all-features"
89+
];
90+
91+
nativeCheckInputs = with pkgs; [
92+
python3
93+
];
6694

6795
buildNoDefaultFeatures = true;
6896

6997
buildFeatures = "git";
7098

7199
meta = with pkgs.lib; {
72-
description = "Leet your code in command-line.";
73-
homepage = "https://github.com/clearloop/leetcode-cli";
100+
description = "Leet your code in command-line. Forked by yousiki.";
101+
homepage = "https://github.com/yousiki/leetcode-cli";
74102
licenses = licenses.mit;
75-
maintainers = with maintainers; [ congee ];
76103
mainProgram = "leetcode";
77104
};
78105

@@ -83,27 +110,57 @@
83110
# CFG_RELEASE = "${rustPlatform.rust.rustc.version}-stable";
84111
CFG_RELEASE_CHANNEL = "stable";
85112
};
113+
114+
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
86115
in
87-
{
88-
defaultPackage = package;
89-
overlay = final: prev: { leetcode-cli = package; };
90-
91-
devShell = with pkgs; mkShell {
92-
name = "shell";
93-
inherit nativeBuildInputs;
94-
95-
buildInputs = buildInputs ++ [
96-
toolchain
97-
cargo-edit
98-
cargo-bloat
99-
cargo-audit
100-
cargo-about
101-
cargo-outdated
102-
];
116+
{
117+
# Packages
118+
packages = {
119+
default = package;
120+
leetcode-cli = package;
121+
};
103122

104-
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
105-
RUST_BACKTRACE = "full";
106-
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
123+
# DevShells
124+
devShells.default =
125+
with pkgs;
126+
mkShell {
127+
name = "leetcode-cli-dev";
128+
inherit nativeBuildInputs;
129+
130+
buildInputs = buildInputs ++ [
131+
toolchain
132+
cargo-about
133+
cargo-audit
134+
cargo-bloat
135+
cargo-edit
136+
cargo-outdated
137+
];
138+
139+
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
140+
RUST_BACKTRACE = "full";
141+
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
142+
};
143+
144+
# Formatters
145+
formatter = treefmtEval.config.build.wrapper;
146+
147+
# Checks
148+
checks.formatting = treefmtEval.config.build.check self;
149+
}
150+
)
151+
// (
152+
let
153+
overlay = (
154+
final: prev: {
155+
inherit (self.packages) leetcode-cli;
156+
}
157+
);
158+
in
159+
{
160+
# Overlays
161+
overlays = {
162+
default = overlay;
163+
leetcode-cli = overlay;
107164
};
108165
}
109166
);

treefmt.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
_: {
2+
projectRootFile = "flake.nix";
3+
programs = {
4+
nixfmt.enable = true;
5+
rustfmt.enable = true;
6+
taplo.enable = true;
7+
};
8+
}

0 commit comments

Comments
 (0)