network/flake.nix

58 lines
1.7 KiB
Nix
Raw Normal View History

2021-03-05 20:05:50 +01:00
{
description = "Zentralwerk network";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
2021-04-10 14:52:13 +02:00
# `nix flake update --override-flake zentralwerk-network-key git+file:///...`
# to provide the GPG secret key
2021-03-19 23:25:31 +01:00
zentralwerk-network-key.url = "git+https://gitea.c3d2.de/zentralwerk/network.git?dir=nix/key&ref=nix";
2021-03-05 20:05:50 +01:00
};
outputs = inputs@{ self, nixpkgs, zentralwerk-network-key }:
2021-03-05 20:05:50 +01:00
let
system = "x86_64-linux";
systems = [ system ];
forAllSystems = nixpkgs.lib.genAttrs systems;
nixosConfig = name:
2021-03-22 22:38:59 +01:00
self.lib.nixosSystem {
inherit system;
modules = [ self.nixosModule ];
specialArgs.hostName = name;
2021-03-22 22:38:59 +01:00
specialArgs.lib = self.lib;
2021-03-22 23:37:25 +01:00
specialArgs.self = self;
specialArgs.inputs = inputs;
};
in {
2021-04-10 14:52:13 +02:00
# Config, and utilities
2021-03-22 20:25:50 +01:00
lib = nixpkgs.lib.extend (final: prev:
2021-03-19 23:25:31 +01:00
import ./nix/lib {
2021-03-22 20:25:50 +01:00
inherit self;
2021-03-19 23:25:31 +01:00
inherit (zentralwerk-network-key.lib) gpgKey;
2021-03-22 20:25:50 +01:00
pkgs = nixpkgs.legacyPackages.x86_64-linux;
});
2021-03-05 20:05:50 +01:00
2021-04-10 14:52:13 +02:00
# Everything that can be built locally outside of NixOS
packages = forAllSystems (system:
import ./nix/pkgs { inherit self nixpkgs system; }
);
2021-03-05 20:05:50 +01:00
2021-04-10 14:52:13 +02:00
# Configuration for nixosConfigurations
# (see nix/nixos-module/default.nix)
2021-03-05 20:05:50 +01:00
nixosModule = { ... }: {
2021-03-19 22:55:48 +01:00
imports = [ ./nix/nixos-module ];
2021-03-05 20:05:50 +01:00
};
2021-04-10 14:52:13 +02:00
# NixOS host systems (servers, and containers)
nixosConfigurations =
builtins.mapAttrs (hostName: _: nixosConfig hostName) (
nixpkgs.lib.filterAttrs (_: { role, ... }:
builtins.elem role [ "server" "container" ]
2021-03-22 20:25:50 +01:00
) self.lib.config.site.hosts
);
2021-04-02 03:09:06 +02:00
2021-04-10 14:52:13 +02:00
# For `nix flake check`, and Hydra
2021-04-02 03:09:06 +02:00
checks = self.packages;
2021-03-05 20:05:50 +01:00
};
}