-
Notifications
You must be signed in to change notification settings - Fork 42
/
default.nix
91 lines (78 loc) · 4.47 KB
/
default.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
/*
* Copyright (c) 2015 Ambroz Bizjak
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
{ pkgs ? (import <nixpkgs> {}) }:
with pkgs;
rec {
# This is where the APrinter source is taken from.
aprinterSource = stdenv.lib.cleanSource ./.;
# GNU toolchains.
toolchain-avr = pkgs.callPackage nix/gnu-toolchain-avr.nix {};
toolchain-arm = pkgs.callPackage nix/gnu-toolchain.nix { target = "arm-none-eabi"; };
toolchain-arm-optsize = toolchain-arm.override { optimizeForSize = true; };
toolchain-microblaze = pkgs.callPackage nix/gnu-toolchain.nix {
target = "microblaze-xilinx-elf"; optimizeForSize = true; };
# Clang compilers.
clang-arm = pkgs.callPackage nix/clang-arm.nix { gnu-toolchain = toolchain-arm; };
clang-arm-optsize = clang-arm.override { gnu-toolchain = toolchain-arm-optsize; };
clangNative = pkgs.llvmPackages_7.clang;
# GDB (for manual use).
gdb-arm = pkgs.callPackage nix/gdb.nix { target = "arm-none-eabi"; };
gdb-microblaze = pkgs.callPackage nix/gdb.nix { target = "microblaze-xilinx-elf"; };
# Microcontroller support packages.
asf = pkgs.callPackage nix/asf.nix {};
stm32cubef4 = pkgs.callPackage nix/stm32cubef4.nix {};
teensyCores = pkgs.callPackage nix/teensy_cores.nix {};
# Builds APrinter for a specific configuration file (JSON as generated by the
# configuration web interface).
aprinterBuild = { aprinterConfigFile, aprinterConfigName ? null }:
pkgs.callPackage nix/aprinter.nix {
inherit aprinterSource toolchain-avr toolchain-arm toolchain-arm-optsize
toolchain-microblaze clang-arm clang-arm-optsize clangNative asf
stm32cubef4 teensyCores aprinterConfigFile aprinterConfigName;
};
# We need a specific version of NCD for the service.
ncd = pkgs.callPackage nix/ncd.nix {};
# The configuration/compilation web service.
# aprinterService is for local use, while aprinterServiceExprs provided access to
# specific components to be used for deployment via nixops. If you want to deploy
# the service, use service-deployment.nix.
aprinterServiceExprs = pkgs.callPackage nix/service.nix { inherit aprinterSource ncd; };
aprinterService = aprinterServiceExprs.service;
# TypeScript compiler.
typescript = pkgs.callPackage nix/typescript.nix {};
# Builds the web interface.
aprinterWebif = pkgs.callPackage nix/webif.nix { inherit aprinterSource typescript; };
# Hosts the web interface locally while proxying API requests to a device.
aprinterWebifTest = pkgs.callPackage nix/webif-test.nix { inherit aprinterWebif ncd; };
# Various build dependencies split into groups for easy building.
buildDepsAvr = [ toolchain-avr ];
buildDepsArmCommon = [ toolchain-arm asf ];
buildDepsArmOther = [ toolchain-arm-optsize /*clang-arm*/
/*clang-arm-optsize*/ stm32cubef4 teensyCores ];
buildDepsLinux = [ clangNative ];
# Build dependencies above joined. This can be used from service deployment
# to ensure that they are already in the Nix store and will not need to be
# build at the time a build needs them.
buildDeps = buildDepsAvr ++ buildDepsArmCommon ++ buildDepsArmOther ++ buildDepsLinux;
}