-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
flake.nix
73 lines (71 loc) · 2.32 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
{
description = "fak";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
naersk.url = "github:nix-community/naersk";
parts.url = "github:hercules-ci/flake-parts";
devshell.url = "github:numtide/devshell";
};
outputs = inputs:
inputs.parts.lib.mkFlake { inherit inputs; } {
imports = [inputs.devshell.flakeModule];
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
perSystem = { config, pkgs, system, ... }: let
pkgs-unstable = import inputs.nixpkgs-unstable { inherit system; };
naersk = pkgs.callPackage inputs.naersk {};
wchisp = naersk.buildPackage rec {
pname = "wchisp";
version = "0.3-git";
src = pkgs.fetchFromGitHub {
owner = "ch32-rs";
repo = pname;
rev = "4b4787243ef9bc87cbbb0d95c7482b4f7c9838f1";
hash = "sha256-Ju2DBv3R4O48o8Fk/AFXOBIsvGMK9hJ8Ogxk47f7gcU=";
};
};
commands = [
{
help = "build and flash to central";
name = "flash";
command = "python $PRJ_ROOT/fak.py flash";
}
{
help = "build and flash to peripheral";
name = "flash-peripheral";
command = "python $PRJ_ROOT/fak.py flash_p";
}
{
help = "just build the firmware";
name = "compile";
command = "python $PRJ_ROOT/fak.py compile";
}
{
help = "clean up the build dir";
name = "clean";
command = "python $PRJ_ROOT/fak.py clean";
}
];
contents = with pkgs; [
sdcc
pkgs-unstable.nickel
pkgs-unstable.nls
pkgs-unstable.topiary
meson
python311
ninja
wchisp
# meson checks for C compilers to work. It doesn't count SDCC.
# Even though we don't use it, here we add gcc just to satisfy meson.
gcc
];
in {
packages.container = pkgs.dockerTools.buildImage {
name = "fak-devenv";
tag = "latest";
inherit contents;
};
devshells.default = { inherit commands; devshell = { packages = contents; }; };
};
};
}