1{2 description = "NixOS cluster configuration management";34 inputs = {5 nixpkgs.url = "github:nixos/nixpkgs/release-26.05";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 nocargo = {16 url = "gitlab:deltaex/nocargo";17 inputs.nixpkgs.follows = "nixpkgs";18 inputs.registry-crates-io.follows = "registry-crates-io";19 };20 registry-crates-io = {21 url = "github:rust-lang/crates.io-index";22 flake = false;23 };24 shelly.url = "github:CertainLach/shelly";25 fleet-tf = {26 url = "github:CertainLach/fleet-tf";27 inputs.nixpkgs.follows = "nixpkgs";28 inputs.shelly.follows = "shelly";29 inputs.flake-parts.follows = "flake-parts";30 };31 treefmt-nix = {32 url = "github:numtide/treefmt-nix";33 inputs.nixpkgs.follows = "nixpkgs";34 };35 36 37 nix = {38 url = "github:deltarocks/nix/fleet";39 inputs.nixpkgs.follows = "nixpkgs";40 inputs.flake-parts.follows = "flake-parts";41 };42 };43 outputs =44 inputs:45 inputs.flake-parts.lib.mkFlake46 {47 inherit inputs;48 }49 {50 imports = [ inputs.shelly.flakeModule ];51 flake = rec {52 lib =53 (import ./lib {54 inherit (inputs.nixpkgs) lib;55 })56 // {57 fleetConfiguration = throw "function-based interface is deprecated, use flake-parts syntax instead";58 };59 flakeModules.default = import ./lib/flakePart.nix {60 inherit (inputs) crane;61 };62 flakeModule = flakeModules.default;6364 flakeModules.fleet-tf = ./modules/extras/tf.nix;6566 67 testData = {68 testObj = {69 v = "Hello";70 };71 testString = "hello";72 testPrimop = op: "PREFIX_" + (op "body" "_SUFFIX");73 };7475 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 };101 102 systems = [103 "x86_64-linux"104 "aarch64-linux"105 "armv7l-linux"106 "armv6l-linux"107 ];108 perSystem =109 {110 config,111 system,112 pkgs,113 self,114 inputs',115 ...116 }:117 let118 inherit (lib.attrsets) mapAttrs';119 inherit (lib.lists) elem;120 121 122 123 124 deployerSystems = [125 "aarch64-linux"126 "x86_64-linux"127 ];128 deployerSystem = elem system deployerSystems;129 lib = pkgs.lib;130 rust = (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml).override {131 enableLibsecret = false;132 };133 craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rust;134 treefmt = (inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix).config.build;135 in136 {137 _module.args.pkgs = import inputs.nixpkgs {138 inherit system;139 overlays = [140 inputs.rust-overlay.overlays.default141 ];142 };143 144 packages = lib.mkIf deployerSystem (145 let146 packages = pkgs.callPackages ./pkgs {147 inherit craneLib inputs;148 rustToolchain = rust;149 };150 in151 packages // { default = packages.fleet; }152 );153 154 155 checks =156 let157 nixpkgsCraneLib = inputs.crane.mkLib pkgs;158 packages = pkgs.callPackages ./pkgs {159 craneLib = nixpkgsCraneLib;160 inherit inputs;161 };162 prefixAttrs =163 prefix: attrs:164 mapAttrs' (name: value: {165 name = "${prefix}${name}";166 value = value.overrideAttrs (prev: {167 pname = "${prefix}${prev.pname}";168 });169 }) attrs;170 in171 172 173 (prefixAttrs "nixpkgs-" {174 inherit (packages) fleet-install-secrets;175 })176 // {177 formatting = treefmt.check self;178 };179 180 181 shelly.shells.default = lib.mkIf deployerSystem {182 factory = craneLib.devShell;183 packages = with pkgs; [184 rust185186 pkg-config187 openssl188 udev189 rustPlatform.bindgenHook190 inputs'.nix.packages.nix-expr-c191 inputs'.nix.packages.nix-flake-c192 inputs'.nix.packages.nix-fetchers-c193 inputs'.nix.packages.nix-store-c194 inputs'.nix.packages.nix195196 (rage.overrideAttrs { cargoFeatures = [ "plugin" ]; })197 ];198 environment.PROTOC = "${pkgs.protobuf}/bin/protoc";199 };200 formatter = treefmt.wrapper;201 };202 };203}