-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
127 lines (122 loc) · 4.47 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
{
description = "things";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
parts.url = "github:hercules-ci/flake-parts";
parts.inputs.nixpkgs-lib.follows = "nixpkgs";
};
outputs =
inputs@{ self
, nixpkgs
, crane
, fenix
, parts
, ...
}:
parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [
];
perSystem = { config, pkgs, system, lib, ... }:
let
# avr-toolchain = fenix.packages.${system}.fromToolchainFile {
# file = ./rust-toolchain.toml;
# sha256 = "";
# };
# native-toolchain = fenix.packages.${system}.complete.withComponents [
# "cargo"
# "clippy"
# "rust-src"
# "rustc"
# "rustfmt"
# ];
# toolchain = fenix.packages.${system}.combine [ avr-toolchain native-toolchain ];
# craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
# package = { target ? avr-toolchain.target, args ? "", profile ? "release" }: craneLib.buildPackage {
# cargoExtraArgs = "--target ${target} ${args}";
# CARGO_PROFILE = profile;
# src = craneLib.cleanCargoSource (craneLib.path ./.);
# doCheck = false;
# buildInputs = [
# # Add additional build inputs here
# ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
# # Additional darwin specific inputs can be set here
# pkgs.libiconv
# ];
# };
avrlibc = pkgs.pkgsCross.avr.libcCross;
dfp = pkgs.fetchzip {
url = "http://packs.download.atmel.com/Atmel.ATtiny_DFP.2.0.368.atpack";
stripRoot = false;
extension = "zip";
sha256 = "sha256-T+HZFUZ8QrCFybIkbUGfoITNgJ5vUcb+t4SlvPstPOE=";
};
avr_incflags = [
"-isystem ${avrlibc}/avr/include"
"-isystem ${dfp}/include/avr/iotn1616.h"
"-B${avrlibc}/avr/lib/avr5"
"-L${avrlibc}/avr/lib/avr5"
"-B${avrlibc}/avr/lib/avr35"
"-L${avrlibc}/avr/lib/avr35"
"-B${avrlibc}/avr/lib/avr51"
"-L${avrlibc}/avr/lib/avr51"
"-L${avrlibc}/avr/lib/avrxmega3"
"-L${dfp}/gcc/dev/attiny1616/avrxmega3/"
];
avrgcc-wrapper = pkgs.stdenv.mkDerivation rec {
name = "avrgcc-wrapper-${version}";
version = lib.strings.getVersion pkgs.pkgsCross.avr.buildPackages.gcc-unwrapped;
nativeBuildInputs = [ pkgs.makeWrapper ];
buildCommand = ''
mkdir -p $out/bin
for exe in gcc g++; do
makeWrapper "${pkgs.pkgsCross.avr.buildPackages.gcc-unwrapped}/bin/avr-$exe" "$out/bin/avr-$exe" --add-flags "-B${avrlibc}/avr/lib -isystem ${avrlibc}/avr/include -isystem ${dfp}/include/avr -B${dfp}/gcc/dev/attiny1616/avrxmega3 -L${dfp}/gcc/dev/attiny1616/avrxmega3"
done
ln -s ${pkgs.pkgsCross.avr.buildPackages.gcc-unwrapped}/lib $out
'';
};
in
# rec
{
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
pkgsCross.avr.libcCross
pkgsCross.avr.buildPackages.binutils
#pkgsCross.avr.buildPackages.gcc-unwrapped
avrgcc-wrapper
#avrlibc
avrdude
cargo-binutils
];
#CFLAGS = "";
NIX_CFLAGS_COMPILE = avr_incflags;
AVR_CFLAGS = avr_incflags;
AVR_ASFLAGS = avr_incflags;
AVR_LDFLAGS = avr_incflags;
ATTINY_DFP = dfp;
};
# devShells.default = pkgs.pkgsCross.avr.mkShell {
#
# # inputsFrom = [ (package { profile = "dev"; }) ];
# nativeBuildInputs = with pkgs; [
# # fenix.packages.${system}.rust-analyzer
# cargo-binutils
# probe-rs
# # ravedude
# # pkgsCross.avr.libcCross
# # pkgsCross.avr.buildPackages.binutils
# # pkgsCross.avr.buildPackages.gcc
# ];
# };
# packages.default = package { profile = "dev"; };
};
};
}