-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
114 lines (100 loc) · 3.17 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
utils = {
url = "github:numtide/flake-utils";
};
fenix = {
url = "github:nix-community/fenix";
};
};
outputs = inputs@{ self, nixpkgs, utils, naersk, fenix }:
utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
toolchain = with fenix.packages.${system}; combine [
latest.cargo
latest.rustc
];
package = pkgs.callPackage ./derivation.nix {
buildPackage = (naersk.lib.${system}.override {
cargo = toolchain;
rustc = toolchain;
}).buildPackage;
};
test-vm-pkg = self.nixosConfigurations.lizard-mctest.config.system.build.vm;
in
rec {
checks = packages;
packages = {
lizard = package;
test-vm = test-vm-pkg;
test-vm-wrapper = pkgs.writeScript "trekkie-test-vm-wrapper"
''
set -e
echo Trekkie-McTest: enterprise-grade, free-range, grass fed testing vm
echo
echo "ALL RELEVANT SERVICES WILL BE EXPOSED TO THE HOST:"
echo -e "Service\t\tPort"
echo -e "SSH:\t\t2222\troot:lol"
echo -e "lizard:\t8060"
echo -e "redis:\t\t8061"
echo
set -x
export QEMU_NET_OPTS="hostfwd=tcp::2222-:22,hostfwd=tcp::8060-:8060,hostfwd=tcp::8061-:6379"
echo "running the vm now..."
${self.packages.${system}.test-vm}/bin/run-nixos-vm
'';
default = package;
docs = (pkgs.nixosOptionsDoc {
options = (nixpkgs.lib.nixosSystem {
inherit system;
modules = [ self.nixosModules.default ];
}).options.TLMS;
}).optionsCommonMark;
};
# to get yourself a virtualized testing playground:
# nix run .\#mctest
apps = {
mctest = {
type = "app";
program = "${self.packages.${system}.test-vm-wrapper}";
};
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = (with packages.lizard; nativeBuildInputs ++ buildInputs);
};
apps = {
lizard = utils.lib.mkApp { drv = packages.lizard; };
default = apps.lizard;
};
}) // {
nixosModules = rec {
default = lizard;
lizard = import ./nixos-module;
};
overlays.default = final: prev: {
inherit (self.packages.${prev.system})
lizard;
};
# qemu vm for testing
nixosConfigurations.lizard-mctest = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs; };
modules = [
self.nixosModules.default
./tests/vm
{
nixpkgs.overlays = [
self.overlays.default
];
}
];
};
};
}