-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
153 lines (151 loc) · 4.88 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/release-21.11";
flake-utils.url = "github:numtide/flake-utils";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, fenix }:
flake-utils.lib.eachSystem [ "x86_64-linux" ]
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
fenixPkgs = fenix.packages.${system};
rustToolchain = with fenixPkgs; combine [
stable.cargo
stable.rustc
stable.rust-std
targets.x86_64-unknown-linux-musl.stable.rust-std
];
rustPlatform = pkgs.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
};
ownPkgs = self.packages.${pkgs.system};
deployPkgs = [
pkgs.kubectl
pkgs.coreutils
pkgs.nettools
pkgs.envsubst
pkgs.openssl
pkgs.gnused
pkgs.curl
pkgs.istioctl
pkgs.curl
pkgs.go
pkgs.go-langserver
pkgs.delve
pkgs.lsof
];
packageOverrides = pkgs.callPackage ./nix/python-packages.nix { };
python = pkgs.python3.override { inherit packageOverrides; };
pythonWithPackages = python.withPackages (ps: [ ps.logfmt ]);
in
{
packages = rec {
firecracker = pkgs.callPackage ./nix/pkgs/firecracker.nix {
inherit rustPlatform;
};
firecracker-kernel = pkgs.callPackage ./nix/pkgs/firecracker-kernel.nix {
inherit firecracker;
};
firecracker-containerd = pkgs.callPackage ./nix/pkgs/firecracker-containerd { };
firecracker-ctr = pkgs.callPackage ./nix/pkgs/firecracker-ctr.nix { };
firecracker-rootfs = pkgs.callPackage ./nix/pkgs/firecracker-rootfs {
inherit firecracker-containerd runc-static;
};
runc-static = pkgs.callPackage ./nix/pkgs/runc-static.nix { };
vhive = pkgs.callPackage ./nix/pkgs/vhive.nix { inherit pkgs; };
kn = pkgs.callPackage ./nix/pkgs/kn.nix { };
vhive-examples = pkgs.callPackage ./nix/pkgs/vhive-examples.nix {
inherit vhive kn;
};
deploy-knative = pkgs.writeShellScriptBin "deploy-knative" ''
export PATH=${pkgs.lib.makeBinPath deployPkgs}
# too expensive. Maybe we should remove deploy-knative entirely.
# exec ${pkgs.gnumake}/bin/make -C ${./knative} deploy
'';
};
devShell = pkgs.mkShell {
buildInputs = deployPkgs ++ [
pkgs.just
pkgs.jq
pkgs.libcgroup
pkgs.skopeo
pkgs.just
pkgs.istioctl
ownPkgs.kn
ownPkgs.vhive-examples
pythonWithPackages
];
shellHook = ''
if [ -n $KUBECONFIG ]; then
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
fi
'';
};
}) // {
nixosConfigurations = {
example-host = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
self.nixosModules.knative
self.nixosModules.vhive
{ boot.isContainer = true; }
];
};
};
nixosModules = {
firecracker-pkgs = { ... }: {
nixpkgs.config.packageOverrides = pkgs:
let
firecrackerPackages = self.packages.${pkgs.system};
in
{
inherit (firecrackerPackages)
firecracker-kernel
firecracker-containerd
firecracker-rootfs
firecracker-ctr
firecracker;
};
};
knative = { ... }: {
imports = [
{
nixpkgs.config.packageOverrides = pkgs: {
inherit (self.packages.${pkgs.system}) deploy-knative;
};
}
self.nixosModules.k3s
./nix/modules/knative.nix
];
};
k3s = { ... }: {
imports = [
self.nixosModules.firecracker-containerd
./nix/modules/k3s.nix
];
};
vhive = { ... }: {
imports = [
({ ... }: {
nixpkgs.config.packageOverrides = pkgs: {
inherit (self.packages.${pkgs.system}) vhive;
};
})
./nix/modules/vhive.nix
];
};
firecracker-containerd = { ... }: {
imports = [
self.nixosModules.firecracker-pkgs
./nix/modules/firecracker-containerd.nix
];
};
};
};
}