First working version of the flake
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
This commit is contained in:
parent
c878871381
commit
a4727d4963
4 changed files with 201 additions and 0 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
|
@ -0,0 +1 @@
|
|||
use flake
|
||||
64
flake.lock
generated
Normal file
64
flake.lock
generated
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": [
|
||||
"systems"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1747426396,
|
||||
"narHash": "sha256-826f9fjpBgY4drKlk37PW9bQC95uFKFNfAOUjNSadUw=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "05103c54f28fafc230f3a5b95d9d626143bf5933",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "release-24.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"systems": "systems"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"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",
|
||||
"version": 7
|
||||
}
|
||||
30
flake.nix
Normal file
30
flake.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
description = "flake for rp2040 dev";
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/release-24.11";
|
||||
systems.url = "github:nix-systems/default";
|
||||
flake-utils = {
|
||||
url = "github:numtide/flake-utils";
|
||||
inputs.systems.follows = "systems";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ nixpkgs, flake-utils, ... }@inputs:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
openocd = pkgs.callPackage ./openocd.nix { };
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
openocd
|
||||
];
|
||||
};
|
||||
default = openocd;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
106
openocd.nix
Normal file
106
openocd.nix
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
{
|
||||
stdenv,
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
pkg-config,
|
||||
libtool,
|
||||
autoconf,
|
||||
automake,
|
||||
tcl,
|
||||
}:
|
||||
let
|
||||
|
||||
isWindows = stdenv.hostPlatform.isWindows;
|
||||
notWindows = !isWindows;
|
||||
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "openocd-pico";
|
||||
version = "sdk-2.0.0";
|
||||
src = fetchFromGitHub {
|
||||
owner = "raspberrypi";
|
||||
repo = "openocd";
|
||||
rev = "cf9c0b41cd5c45b2faf01b4fd1186f160342b7b7";
|
||||
hash = "sha256-8PpBT+RRd8FiVBhzfsTRcIrzwrd1Y4zNYEfDga+11qU=";
|
||||
leaveDotGit = true;
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
libtool
|
||||
tcl
|
||||
autoconf
|
||||
automake
|
||||
];
|
||||
|
||||
# This emulates the bootstrap script, but is ran as a hook so it can use
|
||||
# the native build inputs.
|
||||
preConfigure = ''
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
# Run the autotools bootstrap sequence to create the configure script
|
||||
|
||||
# Abort execution on error
|
||||
set -e
|
||||
|
||||
# bootstrap the autotools
|
||||
(
|
||||
set -x
|
||||
aclocal --warnings=all
|
||||
# Apparently, not all versions of libtoolize support option --warnings=all .
|
||||
libtoolize --automake --copy
|
||||
autoconf --warnings=all
|
||||
autoheader --warnings=all
|
||||
automake --warnings=all --gnu --add-missing --copy
|
||||
)
|
||||
|
||||
if [ -x src/jtag/drivers/libjaylink/autogen.sh ]; then
|
||||
(
|
||||
cd src/jtag/drivers/libjaylink
|
||||
./autogen.sh
|
||||
)
|
||||
fi
|
||||
|
||||
echo "Bootstrap complete. Quick build instructions:"
|
||||
echo "./configure ...."
|
||||
'';
|
||||
|
||||
|
||||
configureFlags = [
|
||||
"--disable-werror"
|
||||
];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
|
||||
mkdir -p "$out/etc/udev/rules.d"
|
||||
rules="$out/share/openocd/contrib/60-openocd.rules"
|
||||
if [ ! -f "$rules" ]; then
|
||||
echo "$rules is missing, must update the Nix file."
|
||||
exit 1
|
||||
fi
|
||||
ln -s "$rules" "$out/etc/udev/rules.d/"
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Free and Open On-Chip Debugging, In-System Programming and Boundary-Scan Testing";
|
||||
mainProgram = "openocd";
|
||||
longDescription = ''
|
||||
OpenOCD provides on-chip programming and debugging support with a layered
|
||||
architecture of JTAG interface and TAP support, debug target support
|
||||
(e.g. ARM, MIPS), and flash chip drivers (e.g. CFI, NAND, etc.). Several
|
||||
network interfaces are available for interactiving with OpenOCD: HTTP,
|
||||
telnet, TCL, and GDB. The GDB server enables OpenOCD to function as a
|
||||
"remote target" for source-level debugging of embedded systems using the
|
||||
GNU GDB program.
|
||||
'';
|
||||
homepage = "https://openocd.sourceforge.net/";
|
||||
license = licenses.gpl2Plus;
|
||||
maintainers = with maintainers; [
|
||||
bjornfor
|
||||
prusnak
|
||||
];
|
||||
platforms = platforms.unix ++ platforms.windows;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue