forked from Fediversity/Fediversity
closes #93. note that this includes classes: - `nixos` - `nixosTest` - `nixops4Resource` - `nixops4Deployment` .. and my (made-up, as per the [docs](https://ryantm.github.io/nixpkgs/module-system/module-system/#module-system-lib-evalModules-param-class)): - `nix-unit` - `package` .. while i did not manage to cover: - service tests, given `pkgs.nixosTest` seemed to not actually like `_class = "nixosTest"` (?!) ... nor #93's mentioned destructured arguments for that matter, as per Fediversity/Fediversity#93 (comment) - let me know if that is still desired as well. Reviewed-on: Fediversity/Fediversity#398 Reviewed-by: Valentin Gagarin <valentin.gagarin@tweag.io> Co-authored-by: Kiara Grouwstra <kiara@procolix.eu> Co-committed-by: Kiara Grouwstra <kiara@procolix.eu>
107 lines
3 KiB
Nix
107 lines
3 KiB
Nix
{
|
|
inputs,
|
|
lib,
|
|
pkgs,
|
|
config,
|
|
...
|
|
}:
|
|
|
|
let
|
|
inherit (lib)
|
|
mkOption
|
|
mkForce
|
|
concatLists
|
|
types
|
|
;
|
|
|
|
sources = import ../../../npins;
|
|
|
|
in
|
|
{
|
|
_class = "nixos";
|
|
|
|
imports = [ ./sharedOptions.nix ];
|
|
|
|
options.system.extraDependenciesFromModule = mkOption {
|
|
type = types.deferredModule;
|
|
description = ''
|
|
Grab the derivations needed to build the given module and dump them in
|
|
system.extraDependencies. You want to put in this module a superset of
|
|
all the things that you will need on your target machines.
|
|
|
|
NOTE: This will work as long as the union of all these configurations do
|
|
not have conflicts that would prevent evaluation.
|
|
'';
|
|
default = { };
|
|
};
|
|
|
|
config = {
|
|
virtualisation = {
|
|
## NOTE: The deployer machines needs more RAM and default than the
|
|
## default. These values have been trimmed down to the gigabyte.
|
|
## Memory use is expected to be dominated by the NixOS evaluation,
|
|
## which happens on the deployer.
|
|
memorySize = 4 * 1024;
|
|
diskSize = 4 * 1024;
|
|
cores = 2;
|
|
};
|
|
|
|
nix.settings = {
|
|
substituters = mkForce [ ];
|
|
hashed-mirrors = null;
|
|
connect-timeout = 1;
|
|
extra-experimental-features = "flakes";
|
|
};
|
|
|
|
system.extraDependencies =
|
|
[
|
|
"${inputs.flake-parts}"
|
|
"${inputs.flake-parts.inputs.nixpkgs-lib}"
|
|
"${inputs.nixops4}"
|
|
"${inputs.nixops4-nixos}"
|
|
"${inputs.nixpkgs}"
|
|
|
|
"${sources.flake-inputs}"
|
|
|
|
pkgs.stdenv
|
|
pkgs.stdenvNoCC
|
|
]
|
|
++ (
|
|
let
|
|
## We build a whole NixOS system that contains the module
|
|
## `system.extraDependenciesFromModule`, only to grab its
|
|
## configuration and the store paths needed to build it and
|
|
## dump them in `system.extraDependencies`.
|
|
machine =
|
|
(pkgs.nixos [
|
|
./targetNode.nix
|
|
config.system.extraDependenciesFromModule
|
|
{
|
|
nixpkgs.hostPlatform = "x86_64-linux";
|
|
_module.args.inputs = inputs;
|
|
enableAcme = config.enableAcme;
|
|
acmeNodeIP = config.acmeNodeIP;
|
|
}
|
|
]).config;
|
|
|
|
in
|
|
[
|
|
machine.system.build.toplevel.inputDerivation
|
|
machine.system.build.etc.inputDerivation
|
|
machine.system.build.etcBasedir.inputDerivation
|
|
machine.system.build.etcMetadataImage.inputDerivation
|
|
machine.system.build.extraUtils.inputDerivation
|
|
machine.system.path.inputDerivation
|
|
machine.system.build.setEnvironment.inputDerivation
|
|
machine.system.build.vm.inputDerivation
|
|
machine.system.build.bootStage1.inputDerivation
|
|
machine.system.build.bootStage2.inputDerivation
|
|
]
|
|
++ concatLists (
|
|
lib.mapAttrsToList (
|
|
_k: v: if v ? source.inputDerivation then [ v.source.inputDerivation ] else [ ]
|
|
) machine.environment.etc
|
|
)
|
|
);
|
|
};
|
|
}
|