forked from zentralwerk/network
pkgs/device-templates.nix: update
This commit is contained in:
parent
7b7745e376
commit
f15bb721d2
|
@ -12,8 +12,8 @@
|
||||||
forAllSystems = nixpkgs.lib.genAttrs systems;
|
forAllSystems = nixpkgs.lib.genAttrs systems;
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
lib = forAllSystems (system:
|
lib =
|
||||||
import ./nix/lib { inherit nixpkgs system; }
|
import ./nix/lib { inherit nixpkgs; }
|
||||||
);
|
);
|
||||||
|
|
||||||
packages = forAllSystems (system: {
|
packages = forAllSystems (system: {
|
||||||
|
@ -25,9 +25,7 @@
|
||||||
ln -s $src/init $out/
|
ln -s $src/init $out/
|
||||||
ln -s $src/etc $out/etc/static
|
ln -s $src/etc $out/etc/static
|
||||||
'';
|
'';
|
||||||
});
|
} // (import ./nix/pkgs/device-templates.nix { inherit self nixpkgs system; }));
|
||||||
|
|
||||||
#defaultPackage.x86_64-linux = self.packages.x86_64-linux.hello;
|
|
||||||
|
|
||||||
nixosModule = { ... }: {
|
nixosModule = { ... }: {
|
||||||
imports = nixpkgs.lib.filesystem.listFilesRecursive ./nix/nixos-modules;
|
imports = nixpkgs.lib.filesystem.listFilesRecursive ./nix/nixos-modules;
|
||||||
|
|
|
@ -6,7 +6,6 @@ let
|
||||||
modules = [
|
modules = [
|
||||||
./options.nix
|
./options.nix
|
||||||
./legacy.nix
|
./legacy.nix
|
||||||
./device-templates.nix
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
|
@ -6,4 +6,4 @@ let
|
||||||
in
|
in
|
||||||
builtins.foldl' (result: filename:
|
builtins.foldl' (result: filename:
|
||||||
recursiveUpdate result (loadYaml filename)
|
recursiveUpdate result (loadYaml filename)
|
||||||
) {} (filesystem.listFilesRecursive ../../salt-pillar)
|
) {} (filesystem.listFilesRecursive ../../../../salt-pillar)
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ self, nixpkgs, system }:
|
||||||
with lib;
|
with nixpkgs.lib;
|
||||||
let
|
let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
config = self.lib.${system}.config;
|
||||||
|
|
||||||
templates = role: {
|
templates = role: {
|
||||||
ap = _: ../salt/cpe/ap.sh;
|
ap = _: ../salt/cpe/ap.sh;
|
||||||
switch = model: ../salt/switches + "/${model}.expect";
|
switch = model: ../salt/switches + "/${model}.expect";
|
||||||
|
@ -15,16 +18,8 @@ let
|
||||||
import ./salt-support/expand-template.nix {
|
import ./salt-support/expand-template.nix {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
} name (replaceNetmasks template) data;
|
} name (replaceNetmasks template) data;
|
||||||
in
|
|
||||||
{
|
|
||||||
options.site.device-scripts = mkOption {
|
|
||||||
type = with types; attrsOf path;
|
|
||||||
};
|
|
||||||
options.site.all-device-scripts = mkOption {
|
|
||||||
type = types.path;
|
|
||||||
};
|
|
||||||
|
|
||||||
config.site.device-scripts =
|
device-scripts =
|
||||||
builtins.mapAttrs (hostname: { role, model, ... }:
|
builtins.mapAttrs (hostname: { role, model, ... }:
|
||||||
expandTemplate "${hostname}.sh" (templates role model) ({
|
expandTemplate "${hostname}.sh" (templates role model) ({
|
||||||
inherit hostname;
|
inherit hostname;
|
||||||
|
@ -40,7 +35,7 @@ in
|
||||||
role == "ap" || role == "switch"
|
role == "ap" || role == "switch"
|
||||||
) config.site.hosts);
|
) config.site.hosts);
|
||||||
|
|
||||||
config.site.all-device-scripts =
|
all-device-scripts =
|
||||||
pkgs.runCommandLocal "all-device-scripts" {} (
|
pkgs.runCommandLocal "all-device-scripts" {} (
|
||||||
''
|
''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
|
@ -51,4 +46,7 @@ in
|
||||||
) (builtins.attrNames config.site.device-scripts)
|
) (builtins.attrNames config.site.device-scripts)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
in
|
||||||
|
{
|
||||||
|
inherit all-device-scripts;
|
||||||
|
} // device-scripts
|
||||||
|
|
Loading…
Reference in New Issue