1{2 description = "NixOS configuration management";34 inputs = {5 nixpkgs.url = "github:nixos/nixpkgs/release-24.11";6 rust-overlay = {7 url = "github:oxalica/rust-overlay";8 inputs.nixpkgs.follows = "nixpkgs";9 };10 flake-parts = {11 url = "github:hercules-ci/flake-parts";12 inputs.nixpkgs-lib.follows = "nixpkgs";13 };14 crane.url = "github:ipetkov/crane";15 shelly.url = "github:CertainLach/shelly";16 };17 outputs =18 inputs:19 inputs.flake-parts.lib.mkFlake20 {21 inherit inputs;22 }23 {24 imports = [ inputs.shelly.flakeModule ];25 flake = rec {26 lib =27 (import ./lib {28 inherit (inputs.nixpkgs) lib;29 })30 // {31 fleetConfiguration = throw "function-based interface is deprecated, use flake-parts syntax instead";32 };33 flakeModules.default = import ./lib/flakePart.nix {34 inherit (inputs) crane;35 };36 flakeModule = flakeModules.default;3738 fleetModules.tf = ./modules/extras/tf.nix;3940 41 schemas =42 let43 inherit (inputs.nixpkgs.lib) mapAttrs;44 in45 {46 fleetConfigurations = {47 version = 1;48 doc = ''49 The `fleetConfigurations` flake output defines fleet cluster configurations.50 '';51 inventory = output: {52 children = mapAttrs (configName: cluster: {53 what = "fleet cluster configuration";5455 children = mapAttrs (hostName: host: {56 what = "host [${host.system}]";57 }) cluster.config.hosts;58 59 60 61 }) output;62 };63 };64 };65 };66 67 systems = [68 "x86_64-linux"69 "aarch64-linux"70 "armv7l-linux"71 "armv6l-linux"72 ];73 perSystem =74 {75 config,76 system,77 pkgs,78 ...79 }:80 let81 inherit (lib.attrsets) mapAttrs';82 inherit (lib.lists) elem;83 84 85 86 87 deployerSystems = [88 "aarch64-linux"89 "x86_64-linux"90 ];91 deployerSystem = elem system deployerSystems;92 lib = pkgs.lib;93 rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;94 craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rust;95 in96 {97 _module.args.pkgs = import inputs.nixpkgs {98 inherit system;99 overlays = [ (inputs.rust-overlay.overlays.default) ];100 };101 102 packages = lib.mkIf deployerSystem (103 let104 packages = pkgs.callPackages ./pkgs {105 inherit craneLib;106 };107 in108 packages // { default = packages.fleet; }109 );110 111 112 checks =113 let114 nixpkgsCraneLib = inputs.crane.mkLib pkgs;115 packages = pkgs.callPackages ./pkgs {116 craneLib = nixpkgsCraneLib;117 };118 prefixAttrs =119 prefix: attrs:120 mapAttrs' (name: value: {121 name = "${prefix}${name}";122 value = value.overrideAttrs (prev: {123 pname = "${prefix}${prev.pname}";124 });125 }) attrs;126 in127 128 129 (prefixAttrs "nixpkgs-" {130 inherit (packages) fleet-install-secrets;131 });132 133 134 shelly.shells.default = lib.mkIf deployerSystem {135 factory = craneLib.devShell;136 packages = with pkgs; [137 rust138 alejandra139 cargo-edit140 cargo-udeps141 cargo-fuzz142 cargo-watch143 cargo-outdated144145 pkg-config146 openssl147 bacon148 nil149 rustPlatform.bindgenHook150 nixVersions.nix_2_22151 ];152 environment.PROTOC = "${pkgs.protobuf}/bin/protoc";153 };154 formatter = pkgs.alejandra;155 };156 };157}