refactor(nix): config
-> configuration
Avoid shadowin `flake-parts`' `config`
This commit is contained in:
parent
75ab40c7ca
commit
70d949e7e0
3 changed files with 53 additions and 53 deletions
|
@ -142,14 +142,14 @@ let
|
||||||
(builtins.mapAttrs
|
(builtins.mapAttrs
|
||||||
(system: hosts:
|
(system: hosts:
|
||||||
lib.concatMapAttrs
|
lib.concatMapAttrs
|
||||||
(host: config:
|
(host: configuration:
|
||||||
lib.optionalAttrs
|
lib.optionalAttrs
|
||||||
(and [
|
(and [
|
||||||
(host != "__template__")
|
(host != "__template__")
|
||||||
(pred system host config)
|
(pred system host configuration)
|
||||||
])
|
])
|
||||||
{
|
{
|
||||||
${host} = mkHost system host config;
|
${host} = mkHost system host configuration;
|
||||||
})
|
})
|
||||||
hosts)
|
hosts)
|
||||||
machines));
|
machines));
|
||||||
|
@ -160,36 +160,36 @@ in
|
||||||
# Configurations
|
# Configurations
|
||||||
nixosConfigurations =
|
nixosConfigurations =
|
||||||
createConfigurations
|
createConfigurations
|
||||||
(system: host: config:
|
(system: host: configuration:
|
||||||
and
|
and
|
||||||
[
|
[
|
||||||
(hasFiles
|
(hasFiles
|
||||||
[ "configuration.nix" ]
|
[ "configuration.nix" ]
|
||||||
config)
|
configuration)
|
||||||
# (hasDirectories
|
# (hasDirectories
|
||||||
# [ "home" ]
|
# [ "home" ]
|
||||||
# config)
|
# config)
|
||||||
])
|
])
|
||||||
(system: host: config:
|
(system: host: configuration:
|
||||||
mkNixosHost
|
mkNixosHost
|
||||||
../machines/nixos/${system}/${host}
|
../machines/nixos/${system}/${host}
|
||||||
system
|
system
|
||||||
host
|
host
|
||||||
(builtins.map
|
(builtins.map
|
||||||
(lib.strings.removeSuffix ".nix")
|
(lib.strings.removeSuffix ".nix")
|
||||||
(builtins.attrNames (config."home" or { }))))
|
(builtins.attrNames (configuration."home" or { }))))
|
||||||
config.flake.nixosMachines;
|
config.flake.nixosMachines;
|
||||||
|
|
||||||
nixOnDroidConfigurations =
|
nixOnDroidConfigurations =
|
||||||
createConfigurations
|
createConfigurations
|
||||||
(system: host: config:
|
(system: host: configuration:
|
||||||
and
|
and
|
||||||
[
|
[
|
||||||
(hasFiles
|
(hasFiles
|
||||||
[ "configuration.nix" "home.nix" ]
|
[ "configuration.nix" "home.nix" ]
|
||||||
config)
|
configuration)
|
||||||
])
|
])
|
||||||
(system: host: config:
|
(system: host: configuration:
|
||||||
mkNixOnDroidHost
|
mkNixOnDroidHost
|
||||||
../machines/nix-on-droid/${system}/${host}
|
../machines/nix-on-droid/${system}/${host}
|
||||||
system
|
system
|
||||||
|
@ -198,36 +198,36 @@ in
|
||||||
|
|
||||||
darwinConfigurations =
|
darwinConfigurations =
|
||||||
createConfigurations
|
createConfigurations
|
||||||
(system: host: config:
|
(system: host: configuration:
|
||||||
and
|
and
|
||||||
[
|
[
|
||||||
(hasFiles
|
(hasFiles
|
||||||
[ "configuration.nix" ]
|
[ "configuration.nix" ]
|
||||||
config)
|
configuration)
|
||||||
(hasDirectories
|
(hasDirectories
|
||||||
[ "home" ]
|
[ "home" ]
|
||||||
config)
|
configuration)
|
||||||
])
|
])
|
||||||
(system: host: config:
|
(system: host: configuration:
|
||||||
mkNixDarwinHost
|
mkNixDarwinHost
|
||||||
../machines/nix-darwin/${system}/${host}
|
../machines/nix-darwin/${system}/${host}
|
||||||
system
|
system
|
||||||
host
|
host
|
||||||
(builtins.map
|
(builtins.map
|
||||||
(lib.strings.removeSuffix ".nix")
|
(lib.strings.removeSuffix ".nix")
|
||||||
(builtins.attrNames (config."home" or { }))))
|
(builtins.attrNames (configuration."home" or { }))))
|
||||||
config.flake.nixDarwinMachines;
|
config.flake.nixDarwinMachines;
|
||||||
|
|
||||||
homeConfigurations =
|
homeConfigurations =
|
||||||
createConfigurations
|
createConfigurations
|
||||||
(system: host: config:
|
(system: host: configuration:
|
||||||
and
|
and
|
||||||
[
|
[
|
||||||
(hasFiles
|
(hasFiles
|
||||||
[ "home.nix" ]
|
[ "home.nix" ]
|
||||||
config)
|
configuration)
|
||||||
])
|
])
|
||||||
(system: host: config:
|
(system: host: configuration:
|
||||||
mkHomeManagerHost
|
mkHomeManagerHost
|
||||||
../machines/home-manager/${system}/${host}
|
../machines/home-manager/${system}/${host}
|
||||||
system
|
system
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
let
|
let
|
||||||
inherit (import ./utils.nix { inherit lib self; })
|
inherit (import ./utils.nix { inherit lib self; })
|
||||||
accumulateMachines
|
accumulateMachines
|
||||||
config-type-to-deploy-type;
|
configuration-type-to-deploy-type;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
flake = {
|
flake = {
|
||||||
|
@ -11,10 +11,10 @@ in
|
||||||
accumulateMachines
|
accumulateMachines
|
||||||
# TODO: nix-on-droid
|
# TODO: nix-on-droid
|
||||||
["nixos" "nix-darwin"]
|
["nixos" "nix-darwin"]
|
||||||
({ host, system, config-type, config }:
|
({ host, system, configuration-type, configuration }:
|
||||||
let
|
let
|
||||||
deploy-config-path =
|
deploy-config-path =
|
||||||
../machines/${config-type}/${system}/${host}/deploy.nix;
|
../machines/${configuration-type}/${system}/${host}/deploy.nix;
|
||||||
deploy-config =
|
deploy-config =
|
||||||
import deploy-config-path;
|
import deploy-config-path;
|
||||||
in
|
in
|
||||||
|
@ -27,9 +27,9 @@ in
|
||||||
profiles.system = deploy-config // {
|
profiles.system = deploy-config // {
|
||||||
path =
|
path =
|
||||||
let
|
let
|
||||||
deploy-type = config-type-to-deploy-type config-type;
|
deploy-type = configuration-type-to-deploy-type configuration-type;
|
||||||
in
|
in
|
||||||
inputs.deploy-rs.lib.${system}.activate.${deploy-type} config;
|
inputs.deploy-rs.lib.${system}.activate.${deploy-type} configuration;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,83 +30,83 @@ rec {
|
||||||
# NOTE: Implying last argument is the output of `recurseDir`
|
# NOTE: Implying last argument is the output of `recurseDir`
|
||||||
hasDirectories = allSatisfy lib.isAttrs;
|
hasDirectories = allSatisfy lib.isAttrs;
|
||||||
|
|
||||||
gen-config-type-to = mappings: mkError: config-type:
|
gen-configuration-type-to = mappings: mkError: configuration-type:
|
||||||
mappings.${config-type} or
|
mappings.${configuration-type} or
|
||||||
(builtins.throw
|
(builtins.throw
|
||||||
(mkError config-type));
|
(mkError configuration-type));
|
||||||
|
|
||||||
config-type-to-outputs-machines =
|
configuration-type-to-outputs-machines =
|
||||||
gen-config-type-to
|
gen-configuration-type-to
|
||||||
{
|
{
|
||||||
nixos = "nixosMachines";
|
nixos = "nixosMachines";
|
||||||
nix-on-droid = "nixOnDroidMachines";
|
nix-on-droid = "nixOnDroidMachines";
|
||||||
nix-darwin = "nixDarwinMachines";
|
nix-darwin = "nixDarwinMachines";
|
||||||
home-manager = "homeMachines";
|
home-manager = "homeMachines";
|
||||||
}
|
}
|
||||||
(config-type:
|
(configuration-type:
|
||||||
builtins.throw
|
builtins.throw
|
||||||
"Invaild config-type \"${config-type}\" for flake outputs' machines");
|
"Invaild configuration-type \"${configuration-type}\" for flake outputs' machines");
|
||||||
|
|
||||||
config-type-to-outputs-configurations =
|
configuration-type-to-outputs-configurations =
|
||||||
gen-config-type-to
|
gen-configuration-type-to
|
||||||
{
|
{
|
||||||
nixos = "nixosConfigurations";
|
nixos = "nixosConfigurations";
|
||||||
nix-on-droid = "nixOnDroidConfigurations";
|
nix-on-droid = "nixOnDroidConfigurations";
|
||||||
nix-darwin = "darwinConfigurations";
|
nix-darwin = "darwinConfigurations";
|
||||||
home-manager = "homeConfigurations";
|
home-manager = "homeConfigurations";
|
||||||
}
|
}
|
||||||
(config-type:
|
(configuration-type:
|
||||||
builtins.throw
|
builtins.throw
|
||||||
"Invaild config-type \"${config-type}\" for flake outputs' configurations");
|
"Invaild configuration-type \"${configuration-type}\" for flake outputs' configurations");
|
||||||
|
|
||||||
config-type-to-deploy-type =
|
configuration-type-to-deploy-type =
|
||||||
gen-config-type-to
|
gen-configuration-type-to
|
||||||
{
|
{
|
||||||
nixos = "nixos";
|
nixos = "nixos";
|
||||||
nix-darwin = "darwin";
|
nix-darwin = "darwin";
|
||||||
}
|
}
|
||||||
(config-type:
|
(configuration-type:
|
||||||
builtins.throw
|
builtins.throw
|
||||||
"Invaild config-type \"${config-type}\" for deploy-rs deployment");
|
"Invaild configuration-type \"${configuration-type}\" for deploy-rs deployment");
|
||||||
|
|
||||||
accumulateMachines = config-types: host-system-config-type-config-fn:
|
accumulateMachines = configuration-types: host-system-configuration-type-configuration-fn:
|
||||||
lib.flip lib.concatMapAttrs
|
lib.flip lib.concatMapAttrs
|
||||||
(lib.genAttrs
|
(lib.genAttrs
|
||||||
config-types
|
configuration-types
|
||||||
(config-type:
|
(configuration-type:
|
||||||
let
|
let
|
||||||
machines = config-type-to-outputs-machines config-type;
|
machines = configuration-type-to-outputs-machines configuration-type;
|
||||||
in
|
in
|
||||||
self.${machines}))
|
self.${machines}))
|
||||||
(config-type: machines:
|
(configuration-type: machines:
|
||||||
lib.pipe
|
lib.pipe
|
||||||
machines
|
machines
|
||||||
[
|
[
|
||||||
# Filter out nondirectories
|
# Filter out nondirectories
|
||||||
(lib.filterAttrs
|
(lib.filterAttrs
|
||||||
(system: configs:
|
(system: configurations:
|
||||||
builtins.isAttrs configs))
|
builtins.isAttrs configurations))
|
||||||
# Convert non-template configs into `system-and-config` pairs
|
# Convert non-template configs into `system-and-config` pairs
|
||||||
(lib.concatMapAttrs
|
(lib.concatMapAttrs
|
||||||
(system: configs:
|
(system: configurations:
|
||||||
(lib.concatMapAttrs
|
(lib.concatMapAttrs
|
||||||
(host: config:
|
(host: configuration:
|
||||||
lib.optionalAttrs
|
lib.optionalAttrs
|
||||||
(host != "__template__")
|
(host != "__template__")
|
||||||
{
|
{
|
||||||
${host} = {
|
${host} = {
|
||||||
inherit system;
|
inherit system;
|
||||||
config =
|
configuration =
|
||||||
let
|
let
|
||||||
configurations = config-type-to-outputs-configurations config-type;
|
configurations = configuration-type-to-outputs-configurations configuration-type;
|
||||||
in
|
in
|
||||||
self.${configurations}.${host};
|
self.${configurations}.${host};
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
configs)))
|
configurations)))
|
||||||
# Convert each `system-and-config` pair into a deploy-rs node
|
# Convert each `system-and-config` pair into a *whatever*
|
||||||
(lib.concatMapAttrs
|
(lib.concatMapAttrs
|
||||||
(host: { system, config }:
|
(host: { system, configuration }:
|
||||||
host-system-config-type-config-fn { inherit host system config-type config; }))
|
host-system-configuration-type-configuration-fn { inherit host system configuration-type configuration; }))
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue