-
-
Notifications
You must be signed in to change notification settings - Fork 938
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Introduce Flake for development and builds
This PR introduces a Nix flake, allowing for InfiniTime to be built as a Flake, including a FHS development environment. It's derived from #1850 and icewind1991/infinitime-builder@c57c57f. We also introduce `flake-compat`, allowing for non-Flake Nix mahcines to use the project as-is, both for building (`default.nix`), and development (`shell.nix`). Additionally, we introduce `.envrc`, meaning that with `direnv`, the Nix Flake is activated automatically. Fixes #1850. Signed-off-by: Dom Rodriguez <[email protected]>
- Loading branch information
Showing
5 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(import | ||
( | ||
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in | ||
fetchTarball { | ||
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; | ||
sha256 = lock.nodes.flake-compat.locked.narHash; | ||
} | ||
) | ||
{ src = ./.; } | ||
).defaultNix |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
{ | ||
description = "A very basic flake"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; | ||
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"; | ||
}; | ||
|
||
outputs = { self, ... }@inputs: | ||
let | ||
forAllSystems = function: | ||
inputs.nixpkgs.lib.genAttrs [ | ||
"x86_64-linux" | ||
"aarch64-linux" | ||
] | ||
(system: function (import inputs.nixpkgs { | ||
inherit system; | ||
config.allowUnfree = true; | ||
})); | ||
in | ||
{ | ||
packages = forAllSystems (pkgs: | ||
let | ||
infinitime-nrf5-sdk = pkgs.nrf5-sdk.overrideAttrs (old: { | ||
version = "15.3.0"; | ||
src = pkgs.fetchzip { | ||
url = "https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/sdks/nrf5/binaries/nrf5sdk153059ac345.zip"; | ||
sha256 = "sha256-pfmhbpgVv5x2ju489XcivguwpnofHbgVA7bFUJRTj08="; | ||
}; | ||
}); | ||
in | ||
with pkgs; { | ||
default = stdenv.mkDerivation rec { | ||
name = "infinitime"; | ||
version = "1.14.1"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "InfiniTimeOrg"; | ||
repo = "InfiniTime"; | ||
rev = "refs/tags/${version}"; | ||
hash = "sha256-IrsN+9LgEjgfoRR6H7FhsdLMK+GLxc41IBnSbdpwv/E="; | ||
fetchSubmodules = true; | ||
}; | ||
|
||
nativeBuildInputs = [ | ||
adafruit-nrfutil | ||
cmake | ||
nodePackages.lv_font_conv | ||
patch | ||
python3 | ||
python3.pkgs.cbor | ||
python3.pkgs.click | ||
python3.pkgs.cryptography | ||
python3.pkgs.intelhex | ||
python3.pkgs.pillow | ||
]; | ||
|
||
fixupPhase = '' | ||
# /usr/bin/env is not available in the build sandbox | ||
patchShebangs src/displayapp/fonts/generate.py tools/mcuboot/imgtool.py | ||
''; | ||
|
||
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 | ||
''; | ||
}; | ||
}); | ||
|
||
devShells = forAllSystems (pkgs: | ||
let | ||
infinitime-nrf5-sdk = pkgs.nrf5-sdk.overrideAttrs (old: { | ||
version = "15.3.0"; | ||
src = pkgs.fetchzip { | ||
url = "https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/sdks/nrf5/binaries/nrf5sdk153059ac345.zip"; | ||
sha256 = "sha256-pfmhbpgVv5x2ju489XcivguwpnofHbgVA7bFUJRTj08="; | ||
}; | ||
}); | ||
in | ||
with pkgs; { | ||
default = | ||
mmkShell { | ||
packages = [ | ||
(writeShellScriptBin "cmake_infinitime" '' | ||
${cmake}/bin/cmake -DARM_NONE_EABI_TOOLCHAIN_PATH="${gcc-arm-embedded-10}" \ | ||
-DNRF5_SDK_PATH="${infinitime-nrf5-sdk}/share/nRF5_SDK" \ | ||
"$@" | ||
'') | ||
ninja | ||
] ++ self.packages.${pkgs.system}.default.nativeBuildInputs; | ||
}; | ||
}); | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(import | ||
( | ||
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in | ||
fetchTarball { | ||
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; | ||
sha256 = lock.nodes.flake-compat.locked.narHash; | ||
} | ||
) | ||
{ src = ./.; } | ||
).shellNix |