flake.nix: Move vm out of nixosConfigurations
so that checks work #65
43
flake.nix
43
flake.nix
|
@ -31,35 +31,11 @@
|
||||||
##################
|
##################
|
||||||
# Configurations #
|
# Configurations #
|
||||||
##################
|
##################
|
||||||
nixosConfigurations = let
|
nixosConfigurations = {
|
||||||
# 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 {
|
|
||||||
# The actual system definition
|
# The actual system definition
|
||||||
tlaternet = nixpkgs.lib.nixosSystem {
|
tlaternet = self.lib.makeNixosSystem {
|
||||||
inherit system;
|
inherit system;
|
||||||
modules = [
|
extraModules = [(import ./configuration/hardware-specific/linode)];
|
||||||
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)
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,7 +65,10 @@
|
||||||
####################
|
####################
|
||||||
# Helper functions #
|
# Helper functions #
|
||||||
####################
|
####################
|
||||||
lib = import ./lib {lib = nixpkgs.lib;};
|
lib = import ./lib {
|
||||||
|
inherit nixpkgs sops-nix tlaternet-webserver;
|
||||||
|
lib = nixpkgs.lib;
|
||||||
|
};
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# VM launch script #
|
# VM launch script #
|
||||||
|
@ -98,7 +77,11 @@
|
||||||
inherit (nixpkgs.legacyPackages.${system}) writeShellScript;
|
inherit (nixpkgs.legacyPackages.${system}) writeShellScript;
|
||||||
in {
|
in {
|
||||||
default = let
|
default = let
|
||||||
inherit (self.nixosConfigurations.vm.config.system.build) vm;
|
vm = self.lib.makeNixosSystem {
|
||||||
|
inherit system;
|
||||||
|
extraModules = [(import ./configuration/hardware-specific/vm.nix)];
|
||||||
|
};
|
||||||
|
|
||||||
qemuNetOpts = self.lib.makeQemuNetOpts {
|
qemuNetOpts = self.lib.makeQemuNetOpts {
|
||||||
"2222" = "2222";
|
"2222" = "2222";
|
||||||
"3080" = "80";
|
"3080" = "80";
|
||||||
|
@ -110,7 +93,7 @@
|
||||||
program = builtins.toString (writeShellScript "run-vm" ''
|
program = builtins.toString (writeShellScript "run-vm" ''
|
||||||
export QEMU_OPTS="-m 3941 -smp 2 -display curses"
|
export QEMU_OPTS="-m 3941 -smp 2 -display curses"
|
||||||
export QEMU_NET_OPTS="${qemuNetOpts}"
|
export QEMU_NET_OPTS="${qemuNetOpts}"
|
||||||
"${vm}/bin/run-tlaternet-vm"
|
"${vm.config.system.build.vm}/bin/run-tlaternet-vm"
|
||||||
'');
|
'');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
{lib}: let
|
{
|
||||||
|
lib,
|
||||||
|
nixpkgs,
|
||||||
|
sops-nix,
|
||||||
|
tlaternet-webserver,
|
||||||
|
}: let
|
||||||
inherit (lib.attrsets) mapAttrsToList;
|
inherit (lib.attrsets) mapAttrsToList;
|
||||||
inherit (lib.strings) concatStringsSep;
|
inherit (lib.strings) concatStringsSep;
|
||||||
in {
|
in {
|
||||||
|
@ -7,4 +12,19 @@ in {
|
||||||
(mapAttrsToList
|
(mapAttrsToList
|
||||||
(host: vm: "hostfwd=::${host}-:${vm}")
|
(host: vm: "hostfwd=::${host}-:${vm}")
|
||||||
portMapping);
|
portMapping);
|
||||||
|
|
||||||
|
makeNixosSystem = {
|
||||||
|
system,
|
||||||
|
extraModules,
|
||||||
|
}:
|
||||||
|
nixpkgs.lib.nixosSystem {
|
||||||
|
inherit system;
|
||||||
|
modules =
|
||||||
|
[
|
||||||
|
sops-nix.nixosModules.sops
|
||||||
|
tlaternet-webserver.nixosModules.default
|
||||||
|
(import ../configuration)
|
||||||
|
]
|
||||||
|
++ extraModules;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue