-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathflake.nix
85 lines (73 loc) · 3.02 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
{
inputs = {
# Main nixpkgs/NixOS package repository, containing most deps.
# Temporarily locked for https://github.com/NixOS/nixpkgs/pull/198938
nixpkgs.url = "github:nixos/nixpkgs/6739decba354";
# This is Ben Wolsieffer's repo, containing definitions for Gazebo,
# catkin-pkg, colcon, and numerous other low-level ROS dependencies.
nix-ros-overlay.url = "github:lopsided98/nix-ros-overlay";
# This utility repo supplies the eachSystem functio
flake-utils.url = "github:numtide/flake-utils";
# Command line wrapper for GPU access.
nixgl.url = "github:guibou/nixGL";
# Easy bundling of our Poetry-based generator and API client for Nix.
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, nix-ros-overlay, flake-utils, nixgl, poetry2nix }:
let
overlays = [
nix-ros-overlay.overlays.default
nixgl.overlay
(import ./lib)
(import ./flags)
(import ./pkgs)
(import ./overrides)
(import ./colcon)
];
defaultRosSystem = "x86_64-linux";
mkPoetryApplication = (import nixpkgs {
system = defaultRosSystem;
overlays = [ poetry2nix.overlay ];
}).poetry2nix.mkPoetryApplication;
in
{
# Pass through nixpkgs, so that it's this flake's lock controlling
# which version of it we are on for a given snapshot.
inherit nixpkgs;
# Wrap this helper function so that we can specify our supported systems
# here rather than in the generated flake. We must specify them exactly
# or else Hydra tries to build for aarch64 and so on, and we get errors
# for packages like CUDA that aren't available there.
eachRosSystem = flake-utils.lib.eachSystem [ defaultRosSystem ];
makeRosPackages = { system, base-overlays, extra-overlays ? [], top-level-metadata ? null }: (import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = base-overlays ++ overlays ++
[
# Super hacky here, we inject 'flake-metadata' in packages, such that our flake-overlay can consume it
# even though it is set from the flake.
(if top-level-metadata != null then (final: prev: rec {
flake-metadata = top-level-metadata;
}) else (final: prev: {}))
] ++ extra-overlays;
});
generate = (mkPoetryApplication {
projectDir = ./.;
}).overrideAttrs(_: {
# Setting this name equal to the executable allows `nix run` usage.
pname = "generate";
});
# These overlays must come after the generated ones from the snapshot
# flake, since this contains overrides which are applied on top.
overlays = overlays;
# Pass through the list of CI jobs we want so that we don't have
# to hard code that in the generator's template.
ciPackages = packages: [
{ name = "noetic"; path = packages.noetic.ros_base.ws.contents; }
{ name = "rolling"; path = packages.rolling.ros_base.ws.contents; }
];
};
}