Skip to content

Commit 00f8b06

Browse files
committed
Add Nix flake for development environment
1 parent 1557e48 commit 00f8b06

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed

flake.lock

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

flake.nix

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
description = "Advent of Code 2020 in Rust";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs =
10+
{
11+
self,
12+
nixpkgs,
13+
flake-utils,
14+
}:
15+
flake-utils.lib.eachDefaultSystem (
16+
system:
17+
let
18+
pkgs = nixpkgs.legacyPackages.${system};
19+
in
20+
{
21+
devShells.default = pkgs.mkShell {
22+
buildInputs = with pkgs; [
23+
cargo
24+
rustc
25+
clippy
26+
rustfmt
27+
rust-analyzer
28+
29+
# Additional development tools
30+
cargo-watch
31+
cargo-edit
32+
cargo-audit
33+
34+
# Git and other useful tools
35+
git
36+
ripgrep
37+
fd
38+
39+
# Optional: Editor support
40+
nil # Nix language server
41+
];
42+
43+
shellHook = ''
44+
echo "🎄 Advent of Code 2020 - Rust Development Environment"
45+
echo ""
46+
echo "Available commands:"
47+
echo " cargo build --release # Build optimized binary"
48+
echo " cargo run --release -- # Run all days"
49+
echo " cargo run --release -- 5 # Run day 5"
50+
echo " cargo test # Run all tests"
51+
echo " cargo test day05 # Test specific day"
52+
echo " cargo clippy # Lint code"
53+
echo " cargo fmt # Format code"
54+
echo " cargo watch -x check # Watch for changes"
55+
echo ""
56+
echo "Happy coding! 🦀"
57+
'';
58+
};
59+
60+
# For compatibility with older nix versions
61+
devShell = self.devShells.${system}.default;
62+
}
63+
);
64+
}

0 commit comments

Comments
 (0)