-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathflake.nix
150 lines (140 loc) · 4.49 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# 🍳 cookin 👩🍳
{
description = "python data aquisition flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
utils.url = "github:numtide/flake-utils";
mcap-protobuf.url = "github:RCMast3r/mcap-protobuf-support-flake";
flake-utils.url = "github:numtide/flake-utils";
mcap.url = "github:RCMast3r/py_mcap_nix";
foxglove-websocket.url = "github:RCMast3r/py_foxglove_webserver_nix";
asyncudp.url = "github:RCMast3r/asyncudp_nix";
ht_can_pkg_flake.url = "github:hytech-racing/ht_can/40";
nix-proto = { url = "github:notalltim/nix-proto"; };
};
outputs =
{ self
, nixpkgs
, utils
, mcap-protobuf
, mcap
, foxglove-websocket
, asyncudp
, nix-proto
, ht_can_pkg_flake
, flake-utils
, ...
}@inputs:
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-darwin" "x86_64-darwin" "aarch64-linux" ] (system:
let
makePackageSet = pkgs: {
py_data_acq_pkg = pkgs.py_data_acq_pkg;
py_dbc_proto_gen_pkg = pkgs.py_dbc_proto_gen_pkg;
proto_gen_pkg = pkgs.proto_gen_pkg;
hytech_np = pkgs.hytech_np;
hytech_np_proto_py = pkgs.hytech_np_proto_py;
default = pkgs.py_data_acq_pkg;
};
py_data_acq_overlay = final: prev: {
py_data_acq_pkg = final.callPackage ./default.nix { };
};
py_dbc_proto_gen_overlay = final: prev: {
py_dbc_proto_gen_pkg = final.callPackage ./dbc_proto_gen_script.nix { };
};
proto_gen_overlay = final: prev: {
proto_gen_pkg = final.callPackage ./dbc_proto_bin_gen.nix { };
};
nix_protos_overlays = nix-proto.generateOverlays' {
hytech_np = { proto_gen_pkg }:
nix-proto.mkProtoDerivation {
name = "hytech_np";
buildInputs = [ proto_gen_pkg ];
src = proto_gen_pkg.out + "/proto";
version = "1.0.0";
};
};
my_overlays = [
(self: super: {
cantools = super.cantools.overridePythonAttrs (old: rec {
version = "39.4.5";
src = old.fetchPypi {
pname = "cantools";
inherit version;
# hash = "sha256-JQn+rtpy/OA2deLszSKEuxyttqBzcAil50H+JDHUdCE=";
};
});
})
py_dbc_proto_gen_overlay
py_data_acq_overlay
proto_gen_overlay
ht_can_pkg_flake.overlays.default
mcap-protobuf.overlays.default
mcap.overlays.default
asyncudp.overlays.default
foxglove-websocket.overlays.default
] ++ nix-proto.lib.overlayToList nix_protos_overlays;
pkgs = import nixpkgs {
overlays = my_overlays;
inherit system;
};
shared_shell = pkgs.mkShell rec {
name = "nix-devshell";
packages = with pkgs; [
jq
py_data_acq_pkg
py_dbc_proto_gen_pkg
proto_gen_pkg
ht_can_pkg
cmake
can-utils
python311Packages.scipy
];
# Setting up the environment variables you need during
# development.
shellHook =
let icon = "f121";
in ''
path=${pkgs.proto_gen_pkg}
bin_path=$path"/bin"
dbc_path=${pkgs.ht_can_pkg}
export BIN_PATH=$bin_path
export DBC_PATH=$dbc_path
echo -e "PYTHONPATH=$PYTHONPATH\nBIN_PATH=$bin_path\nDBC_PATH=$dbc_path\n" > .env
export PS1="$(echo -e '\u${icon}') {\[$(tput sgr0)\]\[\033[38;5;228m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]} (${name}) \\$ \[$(tput sgr0)\]"
'';
};
ci_shell = pkgs.mkShell rec {
# Update the name to something that suites your project.
name = "nix-devshell";
packages = with pkgs; [
# Development Tools
py_dbc_proto_gen_pkg
proto_gen_pkg
ht_can_pkg
protobuf
];
shellHook =
''
path=${pkgs.proto_gen_pkg}
bin_path=$path"/bin"
dbc_path=${pkgs.ht_can_pkg}
export BIN_PATH=$bin_path
export DBC_PATH=$dbc_path
'';
};
in
{
overlays = my_overlays;
devShells = {
default = shared_shell;
ci = ci_shell;
};
packages = rec {
default = pkgs.py_data_acq_pkg;
py_dbc_proto_gen_pkg = pkgs.py_data_acq_pkg;
proto_gen_pkg = pkgs.proto_gen_pkg;
hytech_np = pkgs.hytech_np;
hytech_np_proto_py = pkgs.hytech_np_proto_py;
};
});
}