-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
91 lines (79 loc) · 2.37 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
{
description = "A Python Maze Solver";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
buildScript = pkgs.writeScriptBin "build" ''
#!${pkgs.bash}/bin/bash
PYTHONPATH=$PYTHONPATH:. ${pkgs.python312Full}/bin/python3 -m src.main
'';
testScript = pkgs.writeScriptBin "tests" ''
#!${pkgs.bash}/bin/bash
PYTHONPATH=$PYTHONPATH. ${pkgs.python312Full}/bin/python3 -m unittest discover -s tests
'';
formatScript = pkgs.writeScriptBin "format" ''
#!${pkgs.bash}/bin/bash
show_usage() {
echo "Format Python code using Black"
echo "Usage:"
echo " * format check - Check file formatting"
echo " * format fix - Format all files in project"
}
case "$1" in
"check")
${pkgs.black}/bin/black --check .
;;
"fix")
${pkgs.black}/bin/black .
;;
*)
show_usage
;;
esac
'';
lintScript = pkgs.writeScriptBin "lint" ''
#!${pkgs.bash}/bin/bash
${pkgs.basedpyright}/bin/basedpyright .
'';
in
{
packages.default = buildScript;
devShells.default = pkgs.mkShell {
packages = [ pkgs.zsh ];
buildInputs = [
pkgs.python312Full
pkgs.black
pkgs.basedpyright
buildScript
testScript
formatScript
lintScript
];
shellHook = ''
export SHELL=${pkgs.zsh}/bin/zsh
echo "Development environment loaded!"
echo "Available commands:"
echo " * build - Run the maze solver"
echo " * tests - Execute unit tests"
echo " * format check - Check file formatting"
echo " * format fix - Format files in project"
echo " * lint - Lint files with basedpyright"
if [[ $SHELL != ${pkgs.zsh}/bin/zsh ]]; then
exec ${pkgs.zsh}/bin/zsh
fi
'';
};
}
);
}