Move devenv for mcu into subdirectory

This commit is contained in:
Jack O'Sullivan 2024-08-04 20:15:24 +01:00
parent 32849eab29
commit 1c500e015c
3 changed files with 58 additions and 110 deletions

81
flake.lock generated
View File

@ -41,11 +41,11 @@
"pre-commit-hooks": "pre-commit-hooks"
},
"locked": {
"lastModified": 1715246369,
"narHash": "sha256-gpdfUGNLXr64y+EAUMA3YP/sUO0wBVthrlPIm2PDJpw=",
"lastModified": 1722605649,
"narHash": "sha256-T5dzUFRb2ocZ+LB2qBZufewdUFQs0pB4fnLKIWBLd9Y=",
"owner": "cachix",
"repo": "devenv",
"rev": "8f089ccfdef53f2ea5e0bfabe25dba4769f5390f",
"rev": "a07842582c030fdf2ccf07d3b1402b2a46908856",
"type": "github"
},
"original": {
@ -85,27 +85,6 @@
"type": "github"
}
},
"devshell": {
"inputs": {
"flake-utils": "flake-utils_3",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1713532798,
"narHash": "sha256-wtBhsdMJA3Wa32Wtm1eeo84GejtI43pMrFrmwLXrsEc=",
"owner": "numtide",
"repo": "devshell",
"rev": "12e914740a25ea1891ec619bb53cf5e6ca922e40",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
@ -143,11 +122,11 @@
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1714641030,
"narHash": "sha256-yzcRNDoyVP7+SCNX0wmuDju1NUCt8Dz9+lyUXEI0dbI=",
"lastModified": 1722555600,
"narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "e5d10a24b66c3ea8f150e47dfdb0416ab7c3390e",
"rev": "8471fe90ad337a8074e957b69ca4d0089218391d",
"type": "github"
},
"original": {
@ -192,24 +171,6 @@
"type": "github"
}
},
"flake-utils_3": {
"inputs": {
"systems": "systems_3"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
@ -327,14 +288,14 @@
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1714640452,
"narHash": "sha256-QBx10+k6JWz6u7VsohfSw8g8hjdBZEf8CFzXH1/1Z94=",
"lastModified": 1722555339,
"narHash": "sha256-uFf2QeW7eAHlYXuDktm9c25OxOyCoUOQmh5SZ9amE5Q=",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz"
"url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz"
"url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz"
}
},
"nixpkgs-regression": {
@ -387,11 +348,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1715037484,
"narHash": "sha256-OUt8xQFmBU96Hmm4T9tOWTu4oCswCzoVl+pxSq/kiFc=",
"lastModified": 1722640603,
"narHash": "sha256-TcXjLVNd3VeH1qKPH335Tc4RbFDbZQX+d7rqnDUoRaY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ad7efee13e0d216bf29992311536fce1d3eefbef",
"rev": "81610abc161d4021b29199aa464d6a1a521e0cc9",
"type": "github"
},
"original": {
@ -455,7 +416,6 @@
"root": {
"inputs": {
"devenv": "devenv",
"devshell": "devshell",
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs_2",
"rootdir": "rootdir"
@ -502,21 +462,6 @@
"repo": "default",
"type": "github"
}
},
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",

View File

@ -1,8 +1,6 @@
{
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
devshell.url = "github:numtide/devshell";
devshell.inputs.nixpkgs.follows = "nixpkgs";
devenv.url = "github:cachix/devenv";
devenv.inputs.nixpkgs.follows = "nixpkgs";
@ -19,54 +17,23 @@
];
systems = [ "x86_64-linux" ];
perSystem = { inputs', system, pkgs, config, ... }:
perSystem = { inputs', system, lib, pkgs, config, ... }:
let
inherit (lib) mkMerge;
rootdirOpt =
let
rootFileContent = builtins.readFile rootdir.outPath;
in
pkgs.lib.mkIf (rootFileContent != "") rootFileContent;
ocdInterface = mcu/tigard-swd.cfg;
withRootdir = f: mkMerge [
(import f)
{ devenv.root = rootdirOpt; }
];
in
{
devenv.shells.mcu = {
devenv.root = rootdirOpt;
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 ${ocdInterface} -f target/rp2040.cfg
'';
gdb.exec = ''
arm-none-eabi-gdb -x .gdbinit build/qclk.elf
'';
};
devenv.shells = {
mcu = withRootdir mcu/devenv.nix;
};
};
};

36
mcu/devenv.nix Normal file
View File

@ -0,0 +1,36 @@
{ 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
'';
};
}