diff --git a/checks/default.nix b/checks/default.nix new file mode 100644 index 0000000..a816263 --- /dev/null +++ b/checks/default.nix @@ -0,0 +1,5 @@ +{ self, pkgs }: + +{ + bird = import ./bird.nix { inherit self pkgs; }; +} diff --git a/flake.lock b/flake.lock index 0452ae9..53ef4af 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,23 @@ { "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1730963269, @@ -18,8 +36,24 @@ }, "root": { "inputs": { + "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 8b2673b..91b257c 100644 --- a/flake.nix +++ b/flake.nix @@ -1,32 +1,24 @@ { inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; + flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, ... }: - let - systems = [ - "x86_64-linux" - # "aarch64-linux" - ]; - - in - { + outputs = { self, nixpkgs, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = (import nixpkgs) { + inherit system; + }; + in + { + checks = import ./checks { inherit self pkgs; }; + } + ) // { nixosModules = rec { bird = ./modules; default = bird; }; - - checks = builtins.listToAttrs (map - (system: { - name = system; - value = { - bird = import ./checks/bird.nix { - inherit self; - pkgs = nixpkgs.legacyPackages.${system}; - }; - }; - }) - systems); }; } diff --git a/modules/default.nix b/modules/default.nix index abec0c3..14ceee2 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -10,23 +10,27 @@ in }; protocols = lib.mkOption { - type = with lib.types; attrsOf str; + type = with lib.types; attrsOf lines; }; }; config = lib.mkIf cfg.enable { services.bird2 = { - config = '' - router id ${cfg.routerId}; - - ${builtins.concatStringsSep "\n" (builtins.attrValues - (builtins.mapAttrs + config = + let + protocols = lib.mapAttrsToList (name: conf: '' protocol ${name} { ${conf} } - '') cfg.protocols))} - ''; + '') + cfg.protocols; + in + '' + router id ${cfg.routerId}; + + ${builtins.concatStringsSep "\n" protocols} + ''; }; }; }