network/flake.nix

58 lines
1.7 KiB
Nix

{
description = "Zentralwerk network";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
# `nix flake update --override-flake zentralwerk-network-key git+file:///...`
# to provide the GPG secret key
zentralwerk-network-key.url = "git+https://gitea.c3d2.de/zentralwerk/network.git?dir=nix/key&ref=nix";
};
outputs = inputs@{ self, nixpkgs, zentralwerk-network-key }:
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;
specialArgs.lib = self.lib;
specialArgs.self = self;
specialArgs.inputs = inputs;
};
in {
# Config, and utilities
lib = nixpkgs.lib.extend (final: prev:
import ./nix/lib {
inherit self;
inherit (zentralwerk-network-key.lib) gpgKey;
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; }
);
# Configuration for nixosConfigurations
# (see nix/nixos-module/default.nix)
nixosModule = { ... }: {
imports = [ ./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;
};
}