difftreelog
doc: flake example
in: trunk
1 file changed
README.adocdiffbeforeafterboth12- Secrets can be securely stored in Git (No one except target hosts can decrypt them), automatically regenerated, reencrypted, etc.12- Secrets can be securely stored in Git (No one except target hosts can decrypt them), automatically regenerated, reencrypted, etc.13- Automatic rollback on deployment failure, which will work, as long as system is passing initrd stage (So still be carefull with root filesystem mount)13- Automatic rollback on deployment failure, which will work, as long as system is passing initrd stage (So still be carefull with root filesystem mount)141415== Flake example1617{18 description = "My cluster configuration";19 inputs = {20 nixpkgs.url = "github:nixos/nixpkgs";21 fleet = {22 url = "github:CertainLach/fleet";23 inputs.nixpkgs.follows = "nixpkgs";24 };25 lanzaboote = {26 url = "github:nix-community/lanzaboote/v0.3.0";27 inputs.nixpkgs.follows = "nixpkgs";28 };29 };30 outputs = {31 nixpkgs,32 fleet,33 lanzaboote,34 ...35 }: {36 # TODO: This section of documentation needs to use flake-utils.37 formatter.x86_64-linux = let38 pkgs = import nixpkgs {system = "x86_64-linux";};39 in40 pkgs.alejandra;4142 devShell.x86_64-linux = let43 pkgs = import nixpkgs {44 system = "x86_64-linux";45 };46 in47 pkgs.mkShell {48 buildInputs = with pkgs; [49 fleet.packages.x86_64-linux.fleet50 ];51 };5253 # Single flake may contain multiple fleet configurations, default one is called... `default`54 fleetConfigurations.default = fleet.lib.fleetConfiguration {55 # nixpkgs used to build the systems56 inherit nixpkgs;57 # fleet wants to pass some data, like secrets, to do that - fleet writes all the encrypted secrets to fleet.nix58 # treat the contents of this file as implementation detail59 data = import ./fleet.nix;60 61 # globalModules section of fleet config declares modules, which are used for all configured nixos hosts.62 globalModules = [63 lanzaboote.nixosModules.lanzaboote64 ({65 config,66 lib,67 ...68 }: {69 # Make `nix shell nixpkgs#thing` use the same nixpkgs, as used to build the system.70 nix.registry.nixpkgs = {71 from = { id = "nixpkgs"; type = "indirect"; };72 flake = nixpkgs;73 exact = false;74 };75 })76 ];7778 # Those modules are used to configure all the machines in cluster at the same time, good example of global modules79 # Is I.e wiring up the mesh VPN, or deploying kubernetes, or other things.80 #81 # Modules use the same semantics as standard nixos module system, they are just configuring all the hosts at once.82 modules = [83 ./wireguard84 # Multi-instancible modules example85 (import ./kubernetes {hosts = ["a" "b"];})86 (import ./kubernetes {hosts = ["c" "d"];})87 ];8889 # Hosts attribute (may also be defined/extended using modules attribute) configures hosts...90 hosts.controlplane-1 = {91 # Every host has some system, for which the system configuration needs to be built92 system = "x86_64-linux";93 # And nixos modules94 modules = [95 ./controlplane-1/hardware-configuration.nix96 ./controlplane-1/configuration.nix97 # Configuration may also be specified inline, as in any nixos config.98 ({...}: {99 services.ray = {100 gpus = 4;101 cpus = 128;102 };103 })104 ];105 };106 };107 };108}10915== Secret generator example110== Secret generator example16111