forked from tiiuae/ghaf-givc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
84 lines (76 loc) · 2.53 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
# Copyright 2024 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
{
description = "Go modules for inter-vm communication with gRPC.";
# Inputs
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
treefmt-nix.url = "github:numtide/treefmt-nix";
devshell.url = "github:numtide/devshell";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
flake-utils,
devshell,
nixpkgs,
treefmt-nix,
crane,
}: let
# Supported systems
systems = with flake-utils.lib.system; [
x86_64-linux
aarch64-linux
];
# Small tool to iterate over each system
eachSystem = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
# Eval the treefmt modules from ./treefmt.nix
treefmtEval = eachSystem (pkgs: treefmt-nix.lib.evalModule pkgs ./treefmt.nix);
in
flake-utils.lib.eachSystem systems (system: {
# Packages
packages = let
pkgs = nixpkgs.legacyPackages.${system};
in {
givc-app = pkgs.callPackage ./nixos/packages/givc-app.nix {};
givc-agent = pkgs.callPackage ./nixos/packages/givc-agent.nix {};
givc-admin = pkgs.callPackage ./nixos/packages/givc-admin.nix {};
givc-admin-rs = pkgs.callPackage ./nixos/packages/givc-admin-rs.nix {
inherit crane;
src = ./.;
};
};
# DevShells
devShells = let
pkgs = nixpkgs.legacyPackages.${system}.extend devshell.overlays.default;
in {
default = pkgs.devshell.mkShell {
imports = [(pkgs.devshell.importTOML ./devshell.toml)];
};
};
})
// {
# NixOS Modules
nixosModules = {
admin-go = import ./nixos/modules/admin-go.nix {inherit self;};
admin = import ./nixos/modules/admin.nix {inherit self;};
host = import ./nixos/modules/host.nix {inherit self;};
sysvm = import ./nixos/modules/sysvm.nix {inherit self;};
appvm = import ./nixos/modules/appvm.nix {inherit self;};
};
# Overlays
overlays.default = _final: prev: {
givc-app = prev.callPackage ./nixos/packages/givc-app.nix {pkgs = prev;};
};
# Formatter (`nix fmt`)
formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
# Checks (`nix flake check`)
checks = eachSystem (pkgs: {
formatting = treefmtEval.${pkgs.system}.config.build.check self;
});
};
}