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 41 schemas = let42 inherit (inputs.nixpkgs.lib) mapAttrs;43 in {44 fleetConfigurations = {45 version = 1;46 doc = ''47 The `fleetConfigurations` flake output defines fleet cluster configurations.48 '';49 inventory = output: {50 children =51 mapAttrs (configName: cluster: {52 what = "fleet cluster configuration";5354 children =55 mapAttrs (hostName: host: {56 what = "host [${host.system}]";57 })58 cluster.config.hosts;59 60 61 62 })63 output;64 };65 };66 };67 };68 69 systems = ["x86_64-linux" "aarch64-linux" "armv7l-linux" "armv6l-linux"];70 perSystem = {71 config,72 system,73 pkgs,74 ...75 }: let76 inherit (lib.attrSets) mapAttrs';77 inherit (lib.lists) elem;78 79 80 81 82 deployerSystems = ["aarch64-linux" "x86_64-linux"];83 deployerSystem = elem system deployerSystems;84 lib = pkgs.lib;85 rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;86 craneLib = (crane.mkLib pkgs).overrideToolchain rust;87 in {88 _module.args.pkgs = import inputs.nixpkgs {89 inherit system;90 overlays = [(inputs.rust-overlay.overlays.default)];91 };92 93 packages = lib.mkIf deployerSystem (let94 packages = pkgs.callPackages ./pkgs {95 inherit craneLib;96 };97 in98 packages // {default = packages.fleet;});99 100 101 devShells = lib.mkIf deployerSystem {102 default = craneLib.devShell {103 packages = with pkgs; [104 rust105 alejandra106 cargo-edit107 cargo-udeps108 cargo-fuzz109 cargo-watch110 cargo-outdated111112 pkg-config113 openssl114 bacon115 nil116 ];117 };118 };119 120 121 checks = let122 packages = pkgs.callPackages ./pkgs {};123 prefixAttrs = prefix: attrs:124 mapAttrs' (name: value: {125 name = "${prefix}${name}";126 value = value.overrideAttrs (prev: {127 pname = "${prefix}${prev.pname}";128 });129 })130 attrs;131 in132 133 (prefixAttrs "nixpkgs-" (removeAttrs packages ["fleet"]));134 formatter = pkgs.alejandra;135 };136 };137}