2023-02-10 21:01:32 +00:00
|
|
|
{ depot
|
|
|
|
, pkgs ? import <nixpkgs> {}
|
2024-09-16 00:18:02 +00:00
|
|
|
, lib ? pkgs.lib
|
2022-08-28 16:33:45 +00:00
|
|
|
, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
heatshrink2 = pm: pm.buildPythonPackage rec {
|
|
|
|
pname = "heatshrink2";
|
2024-04-26 17:02:55 +00:00
|
|
|
version = "0.13.0";
|
2022-08-28 16:33:45 +00:00
|
|
|
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
owner = "eerimoq";
|
|
|
|
repo = "pyheatshrink";
|
|
|
|
rev = version;
|
2024-04-26 17:02:55 +00:00
|
|
|
hash = "sha256:13hvzmp58vinwb77ijssr6bd35bisnl78n0n3azyvibjf5vlrjl2";
|
2022-08-28 16:33:45 +00:00
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
propagatedBuildInputs = with pm; [
|
|
|
|
cython
|
|
|
|
];
|
|
|
|
};
|
2022-12-04 06:40:03 +00:00
|
|
|
scons = pkgs.scons.overridePythonAttrs (_: rec {
|
|
|
|
version = "4.4.0";
|
2024-01-28 03:01:56 +00:00
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
owner = "Scons";
|
|
|
|
repo = "scons";
|
|
|
|
rev = version;
|
|
|
|
sha256 = "sha256:1czswx1fj2j48rspkrvarkr43k0vii9rsmz054c9yby1dq362fgr";
|
2022-12-04 06:40:03 +00:00
|
|
|
};
|
|
|
|
});
|
2024-09-16 00:18:02 +00:00
|
|
|
oslex = pm: pm.buildPythonPackage rec {
|
|
|
|
pname = "oslex";
|
|
|
|
version = "0.1.3";
|
|
|
|
pyproject = true;
|
|
|
|
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
owner = "petamas";
|
|
|
|
repo = "oslex";
|
|
|
|
rev = "release/v${version}";
|
|
|
|
hash = "sha256-OcmBtxGS1Cq2kEcxF0Il62LUGbAAcG4lieokr/nK2/4=";
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = with pm; [
|
|
|
|
hatchling
|
|
|
|
pythonRelaxDepsHook
|
|
|
|
];
|
|
|
|
|
|
|
|
pythonRemoveDeps = true;
|
|
|
|
|
|
|
|
postPatch = ''
|
2024-11-23 22:46:53 +00:00
|
|
|
substituteInPlace pyproject.toml \
|
|
|
|
--replace-fail '"mslex",' ""
|
2024-09-16 00:18:02 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
cxxheaderparser = pm: pm.buildPythonPackage rec {
|
|
|
|
pname = "cxxheaderparser";
|
|
|
|
version = "1.3.4";
|
|
|
|
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
owner = "robotpy";
|
|
|
|
repo = "cxxheaderparser";
|
|
|
|
rev = version;
|
|
|
|
hash = "sha256-Cyo+18mH1p5Zy4dWP3mjZRIkZZOyb61ABedk/amDi0g=";
|
|
|
|
};
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
echo '__version__ = "${version}"' > cxxheaderparser/version.py
|
|
|
|
'';
|
|
|
|
};
|
2022-08-28 16:33:45 +00:00
|
|
|
python-with-deps = pkgs.python3.withPackages (pm: with pm; [
|
|
|
|
pillow
|
|
|
|
(heatshrink2 pm)
|
|
|
|
protobuf
|
|
|
|
setuptools
|
|
|
|
pyserial
|
2024-01-28 03:02:53 +00:00
|
|
|
protobuf
|
2022-12-04 06:40:03 +00:00
|
|
|
(pm.toPythonModule scons)
|
2024-09-16 00:18:02 +00:00
|
|
|
(oslex pm)
|
|
|
|
(cxxheaderparser pm)
|
2022-12-04 06:40:03 +00:00
|
|
|
ansi
|
|
|
|
colorlog
|
2023-07-19 02:54:50 +00:00
|
|
|
pyelftools
|
2022-08-28 16:33:45 +00:00
|
|
|
]);
|
|
|
|
deps = with pkgs; [
|
2024-03-02 11:41:07 +00:00
|
|
|
gcc-arm-embedded-12
|
2022-08-28 16:33:45 +00:00
|
|
|
openocd
|
|
|
|
clang
|
|
|
|
dfu-util
|
|
|
|
git
|
|
|
|
protobuf
|
|
|
|
python-with-deps
|
|
|
|
];
|
2023-02-26 10:25:47 +00:00
|
|
|
|
|
|
|
versionData = builtins.fromJSON (builtins.readFile ./version.json);
|
2022-08-28 16:33:45 +00:00
|
|
|
in
|
|
|
|
pkgs.stdenvNoCC.mkDerivation rec {
|
|
|
|
pname = "flipper-firmware";
|
2023-02-26 10:25:47 +00:00
|
|
|
inherit (versionData) version upstreamVersion;
|
2022-08-28 16:33:45 +00:00
|
|
|
|
2022-08-28 20:47:44 +00:00
|
|
|
src = pkgs.fetchgit {
|
2023-02-26 10:25:47 +00:00
|
|
|
inherit (versionData.src) url rev sha256 fetchLFS fetchSubmodules deepClone leaveDotGit;
|
2022-08-28 20:47:44 +00:00
|
|
|
};
|
2022-08-28 16:33:45 +00:00
|
|
|
|
|
|
|
patches = [
|
2022-10-22 19:17:54 +00:00
|
|
|
./0001-simply-do-not-run-git.patch
|
|
|
|
./0002-proto_ver_generator-use-changelog-not-git.patch
|
|
|
|
./0003-scripts-fbt-version-no-git.patch
|
|
|
|
./0004-scripts-sconsdist-disable-strict_timestamps-allow-FS.patch
|
2023-07-19 02:54:50 +00:00
|
|
|
./0005-pass-SOURCE_DATE_EPOCH-to-tooling.patch
|
2022-08-28 16:33:45 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = deps;
|
|
|
|
|
2022-08-28 20:47:44 +00:00
|
|
|
WORKFLOW_BRANCH_OR_TAG = version;
|
|
|
|
DIST_SUFFIX = "";
|
|
|
|
CUSTOM_FLIPPER_NAME = "";
|
|
|
|
|
2022-08-28 16:33:45 +00:00
|
|
|
FBT_NOENV = 1;
|
|
|
|
FBT_NO_SYNC = 1;
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
mkdir -p $NIX_BUILD_TOP/bin
|
|
|
|
ln -s $(command -v arm-none-eabi-gcc) $NIX_BUILD_TOP/bin/arm-none-eabi-cc
|
2024-03-02 11:41:07 +00:00
|
|
|
ln -s $(command -v arm-none-eabi-gdb) $NIX_BUILD_TOP/bin/arm-none-eabi-gdb-py3
|
2022-08-28 16:33:45 +00:00
|
|
|
export PATH=$NIX_BUILD_TOP/bin:$PATH
|
2022-08-28 20:47:44 +00:00
|
|
|
export WORKFLOW_BRANCH_OR_TAG DIST_SUFFIX CUSTOM_FLIPPER_NAME
|
2022-08-28 16:33:45 +00:00
|
|
|
|
2022-10-22 19:17:54 +00:00
|
|
|
echo building icons
|
|
|
|
./fbt icons
|
|
|
|
echo building resources
|
|
|
|
./fbt -j$NIX_BUILD_CORES COMPACT=1 DEBUG=0 resources icons
|
|
|
|
echo building firmware
|
2022-08-28 16:33:45 +00:00
|
|
|
./fbt -j$NIX_BUILD_CORES --with-updater COMPACT=1 DEBUG=0 updater_package
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
2022-10-22 19:17:54 +00:00
|
|
|
cp -r dist $out
|
2022-08-28 16:33:45 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru.deps = deps;
|
2023-02-10 21:01:32 +00:00
|
|
|
passthru.upload = let
|
|
|
|
firmware = depot.nix.pkgs.flipperzero-firmware;
|
|
|
|
in pkgs.writeShellApplication {
|
|
|
|
name = "upload-f0";
|
2023-02-15 01:29:03 +00:00
|
|
|
runtimeInputs = [ pkgs.google-cloud-sdk pkgs.vault ];
|
2023-02-10 21:01:32 +00:00
|
|
|
text = ''
|
2023-02-15 01:29:03 +00:00
|
|
|
vault_path=unix:///run/tokend/sock
|
|
|
|
|
|
|
|
if [[ "$(groups)" =~ (.* |^)"users"($| .*) ]] || ! test -f /etc/NIXOS; then
|
|
|
|
vault_path=https://vault.int.lukegb.com
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Fetching token from Vault at $vault_path..."
|
|
|
|
token="$(vault read --field=token --address="$vault_path" gcp/roleset/lukegbcom-deployer/token)"
|
|
|
|
export CLOUDSDK_AUTH_ACCESS_TOKEN="$token"
|
|
|
|
|
2023-02-10 21:01:32 +00:00
|
|
|
echo "Uploading ${firmware.version}"
|
|
|
|
gcloud storage cp "${firmware}/f7-C/*-update-*.tgz" "gs://lukegb-flipperzero/${firmware.name}.tgz"
|
|
|
|
'';
|
|
|
|
};
|
2022-08-28 16:33:45 +00:00
|
|
|
}
|