1{2 description = "NixOS configuration management";34 inputs = {5 nixpkgs.url = "github:nixos/nixpkgs/master";6 rust-overlay = {7 url = "github:oxalica/rust-overlay";8 inputs = {9 nixpkgs.follows = "nixpkgs";10 };11 };12 flake-parts.url = "github:hercules-ci/flake-parts";13 crane = {14 url = "github:ipetkov/crane";15 inputs.nixpkgs.follows = "nixpkgs";16 };17 };18 outputs = inputs @ {19 self,20 flake-parts,21 crane,22 ...23 }:24 flake-parts.lib.mkFlake {25 inherit inputs;26 } {27 flake = rec {28 lib =29 (import ./lib {30 inherit (inputs.nixpkgs) lib;31 })32 // {33 fleetConfiguration = throw "function-based interface is deprecated, use flake-parts syntax instead";34 };35 flakeModules.default = import ./lib/flakePart.nix {36 inherit crane;37 };38 flakeModule = flakeModules.default;3940 fleetModules.tf = ./modules/extras/tf.nix;4142 43 schemas = let44 inherit (inputs.nixpkgs.lib) mapAttrs;45 in {46 fleetConfigurations = {47 version = 1;48 doc = ''49 The `fleetConfigurations` flake output defines fleet cluster configurations.50 '';51 inventory = output: {52 children =53 mapAttrs (configName: cluster: {54 what = "fleet cluster configuration";5556 children =57 mapAttrs (hostName: host: {58 what = "host [${host.system}]";59 })60 cluster.config.hosts;61 62 63 64 })65 output;66 };67 };68 };69 };70 71 systems = ["x86_64-linux" "aarch64-linux" "armv7l-linux" "armv6l-linux"];72 perSystem = {73 config,74 system,75 pkgs,76 ...77 }: let78 inherit (lib.attrsets) mapAttrs';79 inherit (lib.lists) elem;80 81 82 83 84 deployerSystems = ["aarch64-linux" "x86_64-linux"];85 deployerSystem = elem system deployerSystems;86 lib = pkgs.lib;87 rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;88 craneLib = (crane.mkLib pkgs).overrideToolchain rust;89 in {90 _module.args.pkgs = import inputs.nixpkgs {91 inherit system;92 overlays = [(inputs.rust-overlay.overlays.default)];93 };94 95 packages = lib.mkIf deployerSystem (let96 packages = pkgs.callPackages ./pkgs {97 inherit craneLib;98 };99 in100 packages // {default = packages.fleet;});101 102 103 checks = let104 packages = pkgs.callPackages ./pkgs {105 inherit craneLib;106 };107 prefixAttrs = prefix: attrs:108 mapAttrs' (name: value: {109 name = "${prefix}${name}";110 value = value.overrideAttrs (prev: {111 pname = "${prefix}${prev.pname}";112 });113 })114 attrs;115 in116 117 (prefixAttrs "nixpkgs-" (removeAttrs packages ["fleet"]));118 119 120 devShells = lib.mkIf deployerSystem {121 default = craneLib.devShell {122 packages = with pkgs; [123 rust124 alejandra125 cargo-edit126 cargo-udeps127 cargo-fuzz128 cargo-watch129 cargo-outdated130131 pkg-config132 openssl133 bacon134 nil135 ];136 env.PROTOC = "${pkgs.protobuf}/bin/protoc";137 };138 };139 formatter = pkgs.alejandra;140 };141 };142}