Initial firmware infra

This commit is contained in:
Jack O'Sullivan 2024-08-31 16:07:55 +01:00
parent 97cb513fd5
commit 8c9e57f97b
6 changed files with 62 additions and 0 deletions

1
firmware/.envrc Normal file
View File

@ -0,0 +1 @@
use flake ..#firmware --override-input rootdir "file+file://"<(printf %s "$PWD")

1
firmware/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/result

19
firmware/base.nix Normal file
View File

@ -0,0 +1,19 @@
{ lib, ... }:
let
inherit (lib) mkOption;
in
{
options.my.build = {
image = mkOption {
description = "Final output image for distribution.";
type = lib.types.unspecified;
};
};
config = {
system = {
stateVersion = "24.11";
};
};
}

32
firmware/default.nix Normal file
View File

@ -0,0 +1,32 @@
{ inputs, ... }:
let
mkSystem = target: inputs.nixpkgs.lib.nixosSystem {
modules = [
./base.nix
target
];
};
in
{
flake.nixosConfigurations = {
qclk-rpi3 = mkSystem target/rpi3.nix;
};
perSystem = { libMy, pkgs, ... }: {
devenv.shells.firmware = libMy.withRootdir {
packages = with pkgs; [
nixos-rebuild
nixVersions.latest
];
scripts = {
build.exec = ''
nix build "..#nixosConfigurations.qclk-$1.config.system.build.toplevel"
'';
build-image.exec = ''
nix build "..#nixosConfigurations.qclk-$1.config.my.build.image"
'';
};
};
};
}

8
firmware/target/rpi3.nix Normal file
View File

@ -0,0 +1,8 @@
{ pkgs, modulesPath, config, ... }: {
imports = [
"${modulesPath}/installer/sd-card/sd-image-aarch64.nix"
];
nixpkgs.system = "aarch64-linux";
my.build.image = config.system.build.sdImage;
}

View File

@ -16,6 +16,7 @@
devenv.flakeModule
./mcu
./firmware
];
systems = [ "x86_64-linux" ];