Compare commits

...

3 commits

4 changed files with 57 additions and 50 deletions

View file

@ -9,10 +9,9 @@ let
git-hooks
gitignore
;
inherit (import sources.flake-inputs) import-flake;
inputs = (import-flake { src = ./.; }).inputs;
inherit (pkgs) lib;
inherit (import sources.flake-inputs) import-flake;
inputs = (import-flake { src = ./.; }).inputs;
inherit ((import-flake { src = ./.; }).inputs) nixops4;
panel = import ./panel { inherit sources system; };
pre-commit-check =

View file

@ -1,7 +1,7 @@
let
inherit (import ../default.nix { }) pkgs inputs;
inherit (pkgs) lib;
inherit (lib) mkOption;
inherit (lib) mkOption types;
eval =
module:
(lib.evalModules {
@ -15,7 +15,7 @@ let
./data-model.nix
];
}).config;
nixops4Deployment = inputs.nixops4.modules.nixops4Deployment.default;
nixops4Deployment = import ./deployment.nix { inherit lib inputs; };
in
{
test-eval = {
@ -131,16 +131,16 @@ in
_class = "fediversity-environment";
resources.shell.login-shell.username = "operator";
implementation =
requests:
{ providers, ... }:
{ ... }:
# { providers, ... }:
{
_class = "nixops4Deployment";
providers = {
inherit (inputs.nixops4.modules.nixops4Provider) local;
};
# _class = "nixops4Deployment";
# providers = {
# inherit (inputs.nixops4.modules.nixops4Provider) local;
# };
resources.the-machine = {
_class = "nixops4Resource";
type = providers.local.exec;
# type = providers.local.exec;
imports = [
inputs.nixops4-nixos.modules.nixops4Resource.nixos
];
@ -149,7 +149,8 @@ in
{
_class = "nixos";
users.users = config.resources.shell.login-shell.apply (
lib.filterAttrs (_name: value: value ? login-shell) requests
# lib.filterAttrs (_name: value: value ? login-shell) requests
lib.filterAttrs (_name: value: value ? login-shell) { }
);
};
};
@ -166,14 +167,14 @@ in
applications.hello.enable = true;
};
};
example-deployment = mkOption {
type = types.submoduleWith {
class = "nixops4Deployment";
modules = [ nixops4Deployment ];
};
environments.single-nixos-vm = {
readOnly = true;
default = config.environments.single-nixos-vm.deployment config.example-configuration;
};
configurations.example = {
enable = true;
applications.hello.enable = true;
# default = config.environments.single-nixos-vm.deployment config.example-configuration;
};
}
);

View file

@ -25,6 +25,7 @@ let
);
};
};
nixops4Deployment = import ./deployment.nix { inherit lib inputs; };
in
{
_class = "fediversity-settings";
@ -107,26 +108,6 @@ in
];
});
};
configuration = mkOption {
description = "Configuration type declaring options to be set by operators";
type = optionType;
readOnly = true;
default = submodule {
options = {
enable = lib.mkEnableOption {
description = "your Fediversity configuration";
};
applications = lib.mapAttrs (
_name: application:
mkOption {
description = application.description;
type = submodule application.module;
default = { };
}
) config.applications;
};
};
};
environments = mkOption {
description = "Run-time environments for Fediversity applications to be deployed to";
type = attrsOf (submoduleWith {
@ -157,7 +138,7 @@ in
};
implementation = mkOption {
description = "Mapping of resources required by applications to available resources; the result can be deployed";
type = environment.config.resource-mapping.function-type;
# type = environment.config.resource-mapping.output-type;
};
resource-mapping = mkOption {
description = "Function type for the mapping from resources to a (NixOps4) deployment";
@ -178,15 +159,7 @@ in
modules = [ environment.config.resource-mapping.output-type ];
});
readOnly = true;
default =
cfg:
# TODO: check cfg.enable.true
let
required-resources = lib.mapAttrs (
name: application-settings: config.applications.${name}.resources application-settings
) cfg.applications;
in
(environment.config.implementation required-resources).output;
default = _cfg: environment.config.implementation;
};
};

34
deployment/deployment.nix Normal file
View file

@ -0,0 +1,34 @@
{
lib,
# inputs,
...
}:
# let
# nixops4 = inputs.nixops4.outPath;
# in
# inputs.nixops4.modules.nixops4Deployment.default
# import inputs.nixops4.modules.nixops4Deployment.default
# resources: import inputs.nixops4.modules.nixops4Deployment.default {
# inherit lib config resources;
# # config = {
# # type providers provider inputs outputsSkeleton resourceType
# # };
# }
# {
# imports = [
# "${nixops4}/nix/deployment/providers.nix"
# "${nixops4}/nix/deployment/resources.nix"
# ];
# };
# "${nixops4}/nix/deployment/resources.nix"
{
options.resources = lib.mkOption {
type = lib.types.attrs;
};
}