Compare commits

...

2 Commits

Author SHA1 Message Date
97cb513fd5 Update inputs 2024-08-31 15:03:11 +01:00
ea12d87356 Move mcu into full flake-parts module 2024-08-31 15:00:30 +01:00
4 changed files with 56 additions and 51 deletions

18
flake.lock generated
View File

@ -41,11 +41,11 @@
"pre-commit-hooks": "pre-commit-hooks"
},
"locked": {
"lastModified": 1722605649,
"narHash": "sha256-T5dzUFRb2ocZ+LB2qBZufewdUFQs0pB4fnLKIWBLd9Y=",
"lastModified": 1724763216,
"narHash": "sha256-oW2bwCrJpIzibCNK6zfIDaIQw765yMAuMSG2gyZfGv0=",
"owner": "cachix",
"repo": "devenv",
"rev": "a07842582c030fdf2ccf07d3b1402b2a46908856",
"rev": "1e4ef61205b9aa20fe04bf1c468b6a316281c4f1",
"type": "github"
},
"original": {
@ -122,11 +122,11 @@
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1722555600,
"narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=",
"lastModified": 1725024810,
"narHash": "sha256-ODYRm8zHfLTH3soTFWE452ydPYz2iTvr9T8ftDMUQ3E=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "8471fe90ad337a8074e957b69ca4d0089218391d",
"rev": "af510d4a62d071ea13925ce41c95e3dec816c01d",
"type": "github"
},
"original": {
@ -348,11 +348,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1722640603,
"narHash": "sha256-TcXjLVNd3VeH1qKPH335Tc4RbFDbZQX+d7rqnDUoRaY=",
"lastModified": 1725067332,
"narHash": "sha256-bMi5zhDwR6jdmN5mBHEu9gQQf9CibIEasA/6mc34Iek=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "81610abc161d4021b29199aa464d6a1a521e0cc9",
"rev": "192e7407cc66e2eccc3a6c5ad3834dd62fae3800",
"type": "github"
},
"original": {

View File

@ -14,6 +14,8 @@
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
devenv.flakeModule
./mcu
];
systems = [ "x86_64-linux" ];
@ -26,14 +28,13 @@
rootFileContent = builtins.readFile rootdir.outPath;
in
pkgs.lib.mkIf (rootFileContent != "") rootFileContent;
withRootdir = f: mkMerge [
(import f)
{ devenv.root = rootdirOpt; }
];
in
{
devenv.shells = {
mcu = withRootdir mcu/devenv.nix;
_module.args.libMy = {
withRootdir = c: mkMerge [
c
{ devenv.root = rootdirOpt; }
];
};
};
};

40
mcu/default.nix Normal file
View File

@ -0,0 +1,40 @@
{
perSystem = { libMy, pkgs, ... }: {
devenv.shells.mcu = libMy.withRootdir {
packages = with pkgs; [
gnumake
cmake
pkgsCross.arm-embedded.buildPackages.gdb # ARM one is broken
gcc-arm-embedded
python3
picotool
openocd-rp2040
];
env = {
PICO_SDK_PATH = "${pkgs.pico-sdk}/lib/pico-sdk";
};
scripts = {
build.exec = ''
cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -D PICO_STDIO_SEMIHOSTING=1
cmake --build build --parallel
'';
build-rel.exec = ''
cmake -S . -B build-release -D CMAKE_BUILD_TYPE=Release
cmake --build build-release --parallel
'';
clean.exec = ''
rm -rf build/ build-release/
'';
ocd.exec = ''
openocd -f ${./tigard-swd.cfg} -f target/rp2040.cfg
'';
gdb.exec = ''
arm-none-eabi-gdb -x .gdbinit build/qclk.elf
'';
};
};
};
}

View File

@ -1,36 +0,0 @@
{ pkgs, ... }: {
packages = with pkgs; [
gnumake
cmake
pkgsCross.arm-embedded.buildPackages.gdb # ARM one is broken
gcc-arm-embedded
python3
picotool
openocd-rp2040
];
env = {
PICO_SDK_PATH = "${pkgs.pico-sdk}/lib/pico-sdk";
};
scripts = {
build.exec = ''
cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -D PICO_STDIO_SEMIHOSTING=1
cmake --build build --parallel
'';
build-rel.exec = ''
cmake -S . -B build-release -D CMAKE_BUILD_TYPE=Release
cmake --build build-release --parallel
'';
clean.exec = ''
rm -rf build/ build-release/
'';
ocd.exec = ''
openocd -f ${./tigard-swd.cfg} -f target/rp2040.cfg
'';
gdb.exec = ''
arm-none-eabi-gdb -x .gdbinit build/qclk.elf
'';
};
}