avr/flake.nix

71 lines
2.0 KiB
Nix
Raw Normal View History

2022-04-17 04:43:50 +00:00
{
description = "Wearables";
inputs = {
nixpkgs.url = "nixpkgs/nixos-21.11";
};
outputs = { self, nixpkgs }:
let
version = builtins.string 0 8 self.lastModifiedDate;
supportedSystems = [ "x86_64-linux" "avr-none" ];
in
{
/*
packages.base."x86_64-linux" =
let pkgs = import nixpkgs { system = "x86_64-linux"; };
in pkgs.stdenv.mkDerivation rec {
name = "wearables-base";
src = "./base";
installPhase = ''
mkdir -p $out/include
cp include/base.h $out/include
'';
};
*/
defaultPackage."x86_64-linux" =
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
avr = pkgs.pkgsCross.avr.buildPackages;
in pkgs.stdenv.mkDerivation rec {
name = "pwm";
2022-04-17 04:43:50 +00:00
src = ./.;
buildInputs = [ pkgs.simavr ];
2022-04-17 04:43:50 +00:00
MCU = "attiny85";
CHIP_SELECT = "AVR_ATtiny85";
F_CPU = "8000000";
CFLAGS = ''-O -finline-functions -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -DF_CPU=${F_CPU} -std=gnu99 -D__${CHIP_SELECT}__=1 -mmcu=${MCU}'';
buildPhase = ''
${avr.gcc}/bin/avr-gcc ${CFLAGS} -I${src}/base/include/ -E -o main.post-cc ${src}/pwm/src/main.c
${avr.gcc}/bin/avr-gcc ${CFLAGS} -I${src}/base/include/ -o main.elf ${src}/pwm/src/main.c
2022-04-17 04:43:50 +00:00
$OBJCOPY -O ihex main.elf main.hex
'';
installPhase = ''
mkdir $out
cp main.post-cc $out
2022-04-17 04:43:50 +00:00
cp main.elf main.hex $out
'';
};
devShell."x86_64-linux" =
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
avr = with pkgs.pkgsCross.avr.buildPackages; [
binutils
gcc
avrdude
simavr
2022-04-17 04:43:50 +00:00
];
in
pkgs.mkShell {
name = "Wearables-shell";
buildInputs = avr;
};
};
}