initial commit
This commit is contained in:
commit
3f6f81f8ab
2 files changed
+112
No files matched your search
Generated
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1791883866,
|
||||
"narHash": "sha256-yvkDdToRZ4IgPc9tSBzzCYJvTLf8n5eE3rgUkpCuD5A=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a033e66ab94a6bedf2c3d58d93a36319d3cbbbaf",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-26.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
{
|
||||
description = "ch32fun with devshell.";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-26.05";
|
||||
};
|
||||
|
||||
outputs = inputs@{ self, nixpkgs }:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
system = "x86_64-linux";
|
||||
};
|
||||
riscv32Pkgs = import nixpkgs {
|
||||
system = "x86_64-linux";
|
||||
crossSystem = {
|
||||
system = "riscv32-none-elf";
|
||||
};
|
||||
};
|
||||
|
||||
ch32fun = pkgs.stdenv.mkDerivation {
|
||||
pname = "ch32fun";
|
||||
version = "1.0rc2";
|
||||
src = pkgs.fetchgit {
|
||||
url = "https://github.com/cnlohr/ch32fun.git";
|
||||
rev = "72957fb697fe18c875f09126858c94c2590f9ae9";
|
||||
hash = "sha256-xaSlC8R3mgSaodOWiRRWkVxcdikoDdSpUN31R2guBR4=";
|
||||
};
|
||||
|
||||
buildInputs = with pkgs; [ coreutils udev libusb1 ];
|
||||
|
||||
postUnpack = ''
|
||||
export sourceRoot="$sourceRoot/minichlink"
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/{share,src}
|
||||
cp -rv ../ch32fun/ $out/src/
|
||||
cp -rv ../extralibs/ $out/src/
|
||||
cp -rv ../misc/ $out/src/
|
||||
rm $out/src/ch32fun/README.md
|
||||
sed -i 's/PREFIX_DEFAULT:=riscv64-elf/PREFIX_DEFAULT:=riscv32-unknown-none-elf/' $out/src/ch32fun/ch32fun.mk
|
||||
sed -i 's/MINICHLINK?=$(CH32FUN)\/..\/minichlink/MINICHLINK?=$(CH32FUN)\/..\/..\/bin/' $out/src/ch32fun/ch32fun.mk
|
||||
sed -i 's/GENERATED_LD_FILE:=$(CH32FUN)\/generated_$(TARGET_MCU_PACKAGE)_$(TARGET_MCU_MEMORY_SPLIT).ld/GENERATED_LD_FILE:=.\/generated_$(TARGET_MCU_PACKAGE)_$(TARGET_MCU_MEMORY_SPLIT).ld/' $out/src/ch32fun/ch32fun.mk
|
||||
|
||||
mkdir -p $out/{bin,lib}
|
||||
mkdir -p $out/lib/udev/rules.d
|
||||
cp -v minichlink $out/bin
|
||||
cp -v minichlink.so $out/lib
|
||||
cp -v 99-minichlink.rules $out/lib/udev/rules.d/
|
||||
|
||||
mkdir -p $out/share/{doc,examples}
|
||||
ls -al $out/share/doc
|
||||
cp -v ../ch32fun/README.md $out/share/doc
|
||||
ls -al $out/share/doc
|
||||
mv $out/share/doc/README.md $out/share/doc/compability.md
|
||||
ls -al $out/share/doc
|
||||
cp -v ../README.md $out/share/doc/README.md
|
||||
ls -al $out/share/doc
|
||||
cp -rv ../examples* $out/share/examples/
|
||||
ls -al $out/share/doc
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
whereis-ch32fun = pkgs.writeShellScriptBin "whereis-ch32fun" ''
|
||||
echo "${ch32fun}/src/ch32fun"
|
||||
'';
|
||||
|
||||
shellProfile = riscv32Pkgs.mkShell {
|
||||
name = "WCH ch32";
|
||||
packages = [
|
||||
pkgs.wlink
|
||||
ch32fun
|
||||
whereis-ch32fun
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
packages.x86_64-linux.default = ch32fun;
|
||||
devShells.x86_64-linux.default = shellProfile;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user