initial packaging

This commit is contained in:
Robin Appelman 2023-09-29 13:02:35 +02:00
commit 9f649d70d7
5 changed files with 149 additions and 0 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
result
.direnv

60
flake.lock generated Normal file
View file

@ -0,0 +1,60 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1694697629,
"narHash": "sha256-NnG0CCWNVFLEvDhGyotVpdefDS+PeUQFsb7bb8evSC4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d50196723e62068692f2465d99573a9f040d0a67",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "release-23.05",
"type": "indirect"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"utils": "utils"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

23
flake.nix Normal file
View file

@ -0,0 +1,23 @@
{
inputs = {
utils.url = "github:numtide/flake-utils";
nixpkgs.url = "nixpkgs/release-23.05";
};
outputs = {
self,
nixpkgs,
utils,
}:
utils.lib.eachDefaultSystem (system: let
pkgs = (import nixpkgs) {
inherit system;
# nrf5-sdk is unfree
config.allowUnfree = true;
};
in rec {
packages = {
default = pkgs.callPackage ./package.nix {};
};
});
}

63
package.nix Normal file
View file

@ -0,0 +1,63 @@
{
stdenv,
cmake,
lv_img_conv,
nodePackages,
python3,
gcc-arm-embedded-10,
nrf5-sdk,
fetchzip,
patch,
git,
fetchgit,
}: let
infinitime-nrf5-sdk = nrf5-sdk.overrideAttrs (old: {
version = "15.3.0";
src = fetchzip {
url = "https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/sdks/nrf5/binaries/nrf5sdk153059ac345.zip";
sha256 = "sha256-pfmhbpgVv5x2ju489XcivguwpnofHbgVA7bFUJRTj08=";
};
});
in stdenv.mkDerivation rec {
name = "infinitime";
src = fetchgit {
url = "https://github.com/InfiniTimeOrg/InfiniTime";
rev = "1.13.0";
hash = "sha256-d2zW1JxoQ2j1Yezp3AeDDY7KObyqZ3N8JO4WCbV02sc=";
deepClone = true;
fetchSubmodules = true;
};
nativeBuildInputs = [
cmake
lv_img_conv
nodePackages.lv_font_conv
python3
python3.pkgs.cbor
python3.pkgs.click
python3.pkgs.cryptography
python3.pkgs.intelhex
python3.pkgs.adafruit-nrfutil
patch
git
];
postPatch = ''
# /usr/bin/env is not available in the build sandbox
substituteInPlace src/displayapp/fonts/generate.py --replace "'/usr/bin/env', 'patch'" "'patch'"
substituteInPlace tools/mcuboot/imgtool.py --replace "/usr/bin/env python3" "${python3}/bin/python3"
'';
cmakeFlags = [
''-DARM_NONE_EABI_TOOLCHAIN_PATH=${gcc-arm-embedded-10}''
''-DNRF5_SDK_PATH=${infinitime-nrf5-sdk}/share/nRF5_SDK''
''-DBUILD_DFU=1''
''-DBUILD_RESOURCES=1''
''-DCMAKE_SOURCE_DIR=${src}''
];
installPhase = ''
SOURCES_DIR=${src} BUILD_DIR=. OUTPUT_DIR=$out ./post_build.sh
'';
}