mirror of
https://github.com/divnix/digga.git
synced 2024-12-23 08:02:21 +03:00
feat: add function to filter hosts from an attrset by system
This commit is contained in:
parent
4438b0f111
commit
698551e084
@ -127,6 +127,7 @@
|
|||||||
inherit (generators) mkDeployNodes mkHomeConfigurations ;
|
inherit (generators) mkDeployNodes mkHomeConfigurations ;
|
||||||
inherit (collectors)
|
inherit (collectors)
|
||||||
collectHosts
|
collectHosts
|
||||||
|
collectHostsOnSystem
|
||||||
;
|
;
|
||||||
|
|
||||||
# DEPRECATED - will be removed soon
|
# DEPRECATED - will be removed soon
|
||||||
|
@ -1,19 +1,34 @@
|
|||||||
{ lib }:
|
{ lib }:
|
||||||
let
|
let
|
||||||
collectHosts = nixosHosts: darwinHosts:
|
collectHosts = nixosConfigurations: darwinConfigurations:
|
||||||
/**
|
/**
|
||||||
Synopsis: hostsOnSystem _hostOutputs_ _system_
|
Synopsis: collectHosts _nixosConfigurations_ _darwinConfigurations_
|
||||||
|
|
||||||
|
Collect all hosts across NixOS and Darwin configurations, validating for
|
||||||
|
unique hostnames to prevent collisions.
|
||||||
**/
|
**/
|
||||||
(nixosHosts // lib.mapAttrs (name: value:
|
(nixosConfigurations // lib.mapAttrs
|
||||||
if builtins.hasAttr name nixosHosts
|
(name: value:
|
||||||
then throw ''
|
if builtins.hasAttr name nixosConfigurations
|
||||||
Hostnames must be unique across all platforms! Found a duplicate host config for '${name}'.
|
then
|
||||||
''
|
throw ''
|
||||||
|
Hostnames must be unique across all platforms! Found a duplicate host config for '${name}'.
|
||||||
|
''
|
||||||
else value
|
else value
|
||||||
)
|
)
|
||||||
darwinHosts);
|
darwinConfigurations);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit collectHosts;
|
inherit collectHosts;
|
||||||
|
|
||||||
|
collectHostsOnSystem = hostConfigurations: system:
|
||||||
|
/**
|
||||||
|
Synopsis: collectHostsOnSystem _hostConfigurations_ _system_
|
||||||
|
|
||||||
|
Filter a set of host configurations to those matching a given system.
|
||||||
|
**/
|
||||||
|
let
|
||||||
|
systemSieve = _: host: host.config.nixpkgs.system == system;
|
||||||
|
in
|
||||||
|
lib.filterAttrs systemSieve hostConfigurations;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# constructor dependencies
|
# constructor dependencies
|
||||||
{ lib, self, inputs, deploy, devshell, home-manager, flake-utils-plus, tests, ... }:
|
{ lib, self, inputs, collectors, deploy, devshell, home-manager, flake-utils-plus, tests, ... }:
|
||||||
config: channels:
|
config: channels:
|
||||||
let
|
let
|
||||||
|
|
||||||
@ -109,8 +109,7 @@ in
|
|||||||
(self.nixosConfigurations != { })
|
(self.nixosConfigurations != { })
|
||||||
) then
|
) then
|
||||||
let
|
let
|
||||||
systemSieve = _: host: host.config.nixpkgs.system == system;
|
hostConfigsOnThisSystem = collectors.collectHostsOnSystem self.nixosConfigurations system;
|
||||||
hostConfigsOnThisSystem = lib.filterAttrs systemSieve self.nixosConfigurations;
|
|
||||||
|
|
||||||
createCustomTestOp = n: host: test:
|
createCustomTestOp = n: host: test:
|
||||||
lib.warnIf (!(test ? name)) ''
|
lib.warnIf (!(test ? name)) ''
|
||||||
@ -145,8 +144,7 @@ in
|
|||||||
(self.darwinConfigurations != { })
|
(self.darwinConfigurations != { })
|
||||||
) then
|
) then
|
||||||
let
|
let
|
||||||
systemSieve = _: host: host.config.nixpkgs.system == system;
|
hostConfigsOnThisSystem = collectors.collectHostsOnSystem self.darwinConfigurations system;
|
||||||
hostConfigsOnThisSystem = lib.filterAttrs systemSieve self.darwinConfigurations;
|
|
||||||
|
|
||||||
createCustomTestOp = n: host: test:
|
createCustomTestOp = n: host: test:
|
||||||
lib.warnIf (!(test ? name)) ''
|
lib.warnIf (!(test ? name)) ''
|
||||||
|
Loading…
Reference in New Issue
Block a user