You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.7 KiB
Nix
91 lines
2.7 KiB
Nix
{
|
|
description = "Zentralwerk network";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/release-22.11";
|
|
openwrt = {
|
|
url = "git+https://git.openwrt.org/openwrt/openwrt.git?ref=openwrt-22.03";
|
|
flake = false;
|
|
};
|
|
openwrt-imagebuilder = {
|
|
url = "github:astro/nix-openwrt-imagebuilder";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
outputs = inputs@{ self, nixpkgs, openwrt, openwrt-imagebuilder }:
|
|
let
|
|
system = "x86_64-linux";
|
|
systems = [ system ];
|
|
forAllSystems = nixpkgs.lib.genAttrs systems;
|
|
|
|
nixosConfig = name:
|
|
self.lib.nixosSystem {
|
|
inherit system;
|
|
modules = [ self.nixosModule ];
|
|
specialArgs = {
|
|
hostName = name;
|
|
inherit (self) lib;
|
|
inherit inputs self;
|
|
};
|
|
};
|
|
in {
|
|
# Config, and utilities
|
|
lib = nixpkgs.lib.extend (_final: _prev:
|
|
import ./nix/lib {
|
|
inherit self;
|
|
inherit openwrt;
|
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
|
});
|
|
|
|
# Everything that can be built locally outside of NixOS
|
|
packages = forAllSystems (system:
|
|
import ./nix/pkgs { inherit self nixpkgs system openwrt-imagebuilder; }
|
|
);
|
|
|
|
# Configuration for nixosConfigurations
|
|
# (see nix/nixos-module/default.nix)
|
|
nixosModule = import ./nix/nixos-module;
|
|
|
|
# NixOS host systems (servers, and containers)
|
|
nixosConfigurations =
|
|
builtins.mapAttrs (hostName: _: nixosConfig hostName) (
|
|
nixpkgs.lib.filterAttrs (_: { role, ... }:
|
|
builtins.elem role [ "server" "container" ]
|
|
) self.lib.config.site.hosts
|
|
);
|
|
|
|
# For `nix flake check`, and Hydra
|
|
checks = self.packages;
|
|
|
|
hydraJobs =
|
|
with self.lib;
|
|
let
|
|
exportFileWrapper = pkg:
|
|
hydraJob (
|
|
nixpkgs.legacyPackages.${system}.runCommand "${pkg.name}-exported" {
|
|
src = pkg;
|
|
} ''
|
|
NAME="${pkg.name}"
|
|
mkdir -p $out/nix-support
|
|
ln -s ${pkg} $out/$NAME
|
|
echo file source-dist $out/$NAME >> $out/nix-support/hydra-build-products
|
|
''
|
|
);
|
|
wrappers = {
|
|
"all-device-scripts" = hydraJob;
|
|
"export-config" = exportFileWrapper;
|
|
"switch-.*" = exportFileWrapper;
|
|
"ap.*-image" = exportFileWrapper;
|
|
};
|
|
in
|
|
builtins.mapAttrs (name: pkg:
|
|
builtins.foldl' (result: wrapperName:
|
|
if builtins.match wrapperName name != null
|
|
then wrappers.${wrapperName} pkg
|
|
else result
|
|
) pkg (builtins.attrNames wrappers)
|
|
) self.packages.${system};
|
|
};
|
|
}
|