1{2 description = "NixOS configuration management";34 inputs = {5 nixpkgs.url = "github:nixos/nixpkgs/master";6 nixpkgs-stable-for-tests.url = "github:nixos/nixpkgs/nixos-24.05";7 rust-overlay = {8 url = "github:oxalica/rust-overlay";9 inputs = {10 nixpkgs.follows = "nixpkgs";11 };12 };13 flake-parts.url = "github:hercules-ci/flake-parts";14 crane = {15 url = "github:ipetkov/crane";16 inputs.nixpkgs.follows = "nixpkgs";17 };18 };19 outputs = inputs @ {20 self,21 flake-parts,22 crane,23 ...24 }:25 flake-parts.lib.mkFlake {26 inherit inputs;27 } {28 flake = rec {29 lib =30 (import ./lib {31 inherit (inputs.nixpkgs) lib;32 })33 // {34 fleetConfiguration = throw "function-based interface is deprecated, use flake-parts syntax instead";35 };36 flakeModules.default = (import ./lib/flakePart.nix {37 inherit crane;38 });39 flakeModule = flakeModules.default;4041 42 schemas = let43 inherit (inputs.nixpkgs.lib) mapAttrs;44 in {45 fleetConfigurations = {46 version = 1;47 doc = ''48 The `fleetConfigurations` flake output defines fleet cluster configurations.49 '';50 inventory = output: {51 children =52 mapAttrs (configName: cluster: {53 what = "fleet cluster configuration";5455 children =56 mapAttrs (hostName: host: {57 what = "host [${host.system}]";58 })59 cluster.config.hosts;60 61 62 63 })64 output;65 };66 };67 };68 };69 70 systems = ["x86_64-linux" "aarch64-linux" "armv7l-linux" "armv6l-linux"];71 perSystem = {72 config,73 system,74 pkgs,75 ...76 }: let77 inherit (lib.attrSets) mapAttrs';78 inherit (lib.lists) elem;79 80 81 82 83 deployerSystems = ["aarch64-linux" "x86_64-linux"];84 deployerSystem = elem system deployerSystems;85 lib = pkgs.lib;86 rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;87 craneLib = (crane.mkLib pkgs).overrideToolchain rust;88 in {89 _module.args.pkgs = import inputs.nixpkgs {90 inherit system;91 overlays = [(inputs.rust-overlay.overlays.default)];92 };93 94 packages = lib.mkIf deployerSystem (let95 packages = import ./pkgs {96 inherit (pkgs) callPackage;97 inherit craneLib;98 };99 in100 packages // {default = packages.fleet;});101 102 103 devShells = lib.mkIf deployerSystem {104 default = craneLib.devShell {105 packages = with pkgs; [106 rust107 alejandra108 cargo-edit109 cargo-udeps110 cargo-fuzz111 cargo-watch112 cargo-outdated113114 pkg-config115 openssl116 bacon117 nil118 ];119 };120 };121 122 123 checks = let124 packages = import ./pkgs {125 inherit (pkgs) callPackage;126 craneLib = crane.mkLib pkgs;127 };128 packages-with-nixpkgs-stable = import ./pkgs {129 inherit (pkgs) callPackage;130 craneLib = crane.mkLib (import inputs.nixpkgs-stable-for-tests {inherit system;});131 };132 prefixAttrs = prefix: attrs:133 mapAttrs' (name: value: {134 name = "${prefix}${name}";135 value = value.overrideAttrs (prev: {136 pname = "${prefix}${prev.pname}";137 });138 })139 attrs;140 in141 142 (prefixAttrs "nixpkgs-" (removeAttrs packages ["fleet"]))143 // (prefixAttrs "nixpkgs-stable-" (removeAttrs packages-with-nixpkgs-stable ["fleet"]));144 formatter = pkgs.alejandra;145 };146 };147}