feat: initial version of the full setup
This commit is contained in:
36
lxc/default.nix
Normal file
36
lxc/default.nix
Normal file
@@ -0,0 +1,36 @@
|
||||
{ pkgs, containersMapping, ... }:
|
||||
let
|
||||
lib = pkgs.lib;
|
||||
|
||||
containerBuild = import ../lib/containers.nix;
|
||||
|
||||
containersFiles = builtins.readDir ./.;
|
||||
|
||||
containers = lib.filterAttrs (_: v: v != null) (
|
||||
lib.mapAttrs (
|
||||
name: type:
|
||||
if type == "regular" && name != "default.nix" && lib.hasSuffix ".nix" name then
|
||||
import ./${name} { inherit containersMapping pkgs; }
|
||||
else
|
||||
null
|
||||
) containersFiles
|
||||
);
|
||||
|
||||
cleanedName = lib.listToAttrs (lib.mapAttrsToList (name: def: mkContainer name def) containers);
|
||||
|
||||
mkContainer =
|
||||
name: raw_def:
|
||||
let
|
||||
hostname = lib.removeSuffix ".nix" name;
|
||||
def = raw_def // {
|
||||
hostname = hostname;
|
||||
container_id = containersMapping.${hostname};
|
||||
};
|
||||
result = containerBuild { inherit def; };
|
||||
in
|
||||
{
|
||||
name = hostname;
|
||||
value = result;
|
||||
};
|
||||
in
|
||||
cleanedName
|
||||
Reference in New Issue
Block a user