flake.nix: Move vm out of nixosConfigurations so that checks work

This commit is contained in:
Tristan Daniël Maat 2022-10-17 14:22:08 +01:00
parent 61d3008bc3
commit 47101bad5c
Signed by: tlater
GPG key ID: 49670FD774E43268
2 changed files with 38 additions and 30 deletions

View file

@ -31,35 +31,11 @@
##################
# Configurations #
##################
nixosConfigurations = let
# Modules that should be generic to all systems
genericModule = {...}: {
imports = [
# Inject flake dependencies
sops-nix.nixosModules.sops
tlaternet-webserver.nixosModules.default
# Import actual configuration
(import ./configuration)
];
};
in {
nixosConfigurations = {
# The actual system definition
tlaternet = nixpkgs.lib.nixosSystem {
tlaternet = self.lib.makeNixosSystem {
inherit system;
modules = [
genericModule
(import ./configuration/hardware-specific/linode)
];
};
# A qemu VM to test the above with
vm = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
genericModule
(import ./configuration/hardware-specific/vm.nix)
];
extraModules = [(import ./configuration/hardware-specific/linode)];
};
};
@ -89,7 +65,10 @@
####################
# Helper functions #
####################
lib = import ./lib {lib = nixpkgs.lib;};
lib = import ./lib {
inherit nixpkgs sops-nix tlaternet-webserver;
lib = nixpkgs.lib;
};
####################
# VM launch script #
@ -98,7 +77,16 @@
inherit (nixpkgs.legacyPackages.${system}) writeShellScript;
in {
default = let
inherit (self.nixosConfigurations.vm.config.system.build) vm;
vm =
(self.lib.makeNixosSystem {
inherit system;
extraModules = [(import ./configuration/hardware-specific/vm.nix)];
})
.config
.system
.build
.vm;
qemuNetOpts = self.lib.makeQemuNetOpts {
"2222" = "2222";
"3080" = "80";

View file

@ -1,4 +1,9 @@
{lib}: let
{
lib,
nixpkgs,
sops-nix,
tlaternet-webserver,
}: let
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.strings) concatStringsSep;
in {
@ -7,4 +12,19 @@ in {
(mapAttrsToList
(host: vm: "hostfwd=::${host}-:${vm}")
portMapping);
makeNixosSystem = {
system,
extraModules,
}:
nixpkgs.lib.nixosSystem {
inherit system;
modules =
[
sops-nix.nixosModules.sops
tlaternet-webserver.nixosModules.default
(import ../configuration)
]
++ extraModules;
};
}