build: tangara flake!

Signed-off-by: Christina Sørensen <ces@fem.gg>
This commit is contained in:
Christina Sørensen 2025-01-15 21:07:44 +01:00
parent dfb4ea5458
commit 342621aac2
Signed by: cafkafk
GPG key ID: F67767BE4545A600
5 changed files with 246 additions and 2 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

3
.gitignore vendored
View file

@ -22,3 +22,6 @@ sdkconfig.bak
*.ignore
/sdkconfig.local
.direnv
result

130
flake.lock generated Normal file
View file

@ -0,0 +1,130 @@
{
"nodes": {
"esp-dev": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1733302387,
"narHash": "sha256-KViLmZH2fFtSWA3hCdeK2ZqHGSLCCmVdHNBejWWXLw0=",
"owner": "quentinmit",
"repo": "nixpkgs-esp-dev",
"rev": "4e791fca5ae53623bba45157dae5d43e9cb0b335",
"type": "github"
},
"original": {
"owner": "quentinmit",
"ref": "tools",
"repo": "nixpkgs-esp-dev",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1726560853,
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"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": 1729501122,
"narHash": "sha256-tScdcYQ37kMqlyqb5yizNDTKXZASLB4zHitlHwOg+/o=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "56c7c4a3f5fdbef5bf81c7d9c28fbb45dc626611",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixpkgs-unstable",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1736848588,
"narHash": "sha256-9B6fQqphF3j9lpcxQnKyIUgp3NyGi7ikb9CjCYqixcY=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "357cd3dfdb8993af11268d755d53357720675e66",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"esp-dev": "esp-dev",
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"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
}

110
flake.nix Normal file
View file

@ -0,0 +1,110 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
#esp-dev.url = "github:mirrexagon/nixpkgs-esp-dev";
esp-dev.url = "github:quentinmit/nixpkgs-esp-dev/tools";
};
outputs =
{
self,
flake-utils,
nixpkgs,
esp-dev,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [ esp-dev.overlays.default ];
pkgs = (import nixpkgs) {
inherit system overlays;
};
in
{
devShells = {
default = pkgs.mkShell {
name = "devShell";
PROJ_PATH = ".";
IDF_PATH = self.packages.${system}.esp-idf-full;
nativeBuildInputs = [
self.packages.${system}.esp-idf-full
pkgs.cmake
pkgs.pkg-config
pkgs.libopus
pkgs.opusfile
pkgs.ninja
];
};
esp-full = esp-dev.devShells.${system}.esp-idf-full;
};
packages = rec {
default = tangara-fw;
esp-idf-full =
# pkgs.esp-idf-full;
(
(pkgs.esp-idf-full.override {
toolsToInclude = [
"xtensa-esp-elf-gdb"
"riscv32-esp-elf-gdb"
"xtensa-esp-elf"
"esp-clang"
"riscv32-esp-elf"
"esp32ulp-elf"
"openocd-esp32"
"esp-rom-elfs"
];
})
// {
postInstall = ''
# make esp-idf cmake git version detection happy
cd $out
git init .
git config user.email "nixbld@localhost"
git config user.name "nixbld"
git commit --date="1970-01-01 00:00:00" --allow-empty -m "make idf happy"
'';
}
);
tangara-fw = pkgs.stdenv.mkDerivation (final: {
name = "tangara";
pname = final.name;
version = "uhh";
src = ./.;
PROJ_PATH = ./.;
IDF_COMPONENT_MANAGER = 0;
nativeBuildInputs = [
pkgs.cmake
pkgs.pkg-config
pkgs.libopus
pkgs.opusfile
pkgs.ninja
esp-idf-full
];
configurePhase = "mkdir $out;"; # " cp -r ${final.src} $out";
buildPhase = ''
cp -r ${final.src}/* ${final.src}/.* .
cp -r ${esp-idf-full} esp
export IDF_PATH=esp
. "$IDF_PATH/export.sh" || echo failure is okay
idf.py build
'';
installPhase = ''
cp -r . $out
'';
});
};
}
);
}

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# SPDX-FileCopyrightText: 2023 jacqueline <me@jacqueline.id.au>
#
@ -19,4 +19,4 @@ echo "'sdkconfig.common' is newer than 'sdkconfig'! You may be building with"
echo "an out of date configuration. Delete your 'sdkconfig' to refresh your"
echo "build configuration, or 'touch sdkconfig' to silence this warning."
echo -e "$RED########################################################################$NOCOLOUR"
exit 1
exit 1