-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
91 lines (81 loc) · 2.77 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
{
description = "A NixOS IPAM implentation hoping to integrate with netbox";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-compat.url = "github:edolstra/flake-compat";
flake-compat.flake = false;
flake-utils.url = "github:numtide/flake-utils";
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, flake-compat, flake-utils, crane }:
(flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
craneLib = crane.lib.${system};
# Common derivation arguments used for all builds
cliCommonArgs = {
src = craneLib.cleanCargoSource (craneLib.path ./cli);
strictDeps = true;
# Needed to get openssl-sys to use pkg-config.
OPENSSL_NO_VENDOR = 1;
buildInputs = with pkgs; [
openssl
];
nativeBuildInputs = with pkgs; [
pkg-config
];
};
cliCargoArtifacts = craneLib.buildDepsOnly (cliCommonArgs // {
pname = "nixbox-cli-deps";
});
cliClippy = craneLib.cargoClippy (cliCommonArgs // {
cargoArtifacts = cliCargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
cliCrate = craneLib.buildPackage (cliCommonArgs // {
cargoArtifacts = cliCargoArtifacts;
});
cliCoverage = craneLib.cargoTarpaulin (cliCommonArgs // {
cargoArtifacts = cliCargoArtifacts;
});
in
{
packages =
{
default = cliCrate;
cli = cliCrate;
dataSourceDemo = (import ./utils/builder.nix { inherit (nixpkgs) lib; pkgs = nixpkgs.legacyPackages.${system}; }).dataSource { };
};
formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt
;
devShells = {
default = craneLib.devShell {
checks = self.checks.${system};
inputsFrom = [
cliCrate
];
packages = with pkgs; [
nixpkgs-fmt
nix-unit
nixdoc
statix
];
};
};
checks = {
inherit
cliCrate
cliClippy
# cliCoverage // not yet used
;
};
})) // {
tests = nixpkgs.lib.mapAttrs (name: v: import "${./utils}/tests/${name}.nix" { inherit self; inherit (nixpkgs) lib; inherit (self) utils; }) (builtins.removeAttrs self.utils [ "__unfix__" "extend" "generate" ]);
utils = import ./utils { inherit (nixpkgs) lib; };
nixosModules = rec {
nixbox = import ./modules/nixbox.nix { inherit (self) utils; };
default = nixbox;
};
};
}