From 69336c26248e5db351d362001b9a07e297ccd467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=E2=80=9CNiols=E2=80=9D=20Jeannerod?= Date: Fri, 8 Nov 2024 16:15:39 +0100 Subject: [PATCH] Add formatter --- flake.nix | 129 +++++++++++++++++++++++++++++++------------------ procolixVm.nix | 23 +++++++-- 2 files changed, 100 insertions(+), 52 deletions(-) diff --git a/flake.nix b/flake.nix index 5429ac4b..900d5b0b 100644 --- a/flake.nix +++ b/flake.nix @@ -10,84 +10,117 @@ nixops4-nixos.url = "github:nixops4/nixops4/eval"; }; - outputs = inputs@{ self, flake-parts, nixpkgs, snf, ... }: + outputs = + inputs@{ + self, + flake-parts, + nixpkgs, + snf, + ... + }: flake-parts.lib.mkFlake { inherit inputs; } { - imports = [ - inputs.nixops4-nixos.modules.flake.default + imports = [ inputs.nixops4-nixos.modules.flake.default ]; + + systems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + "x86_64-darwin" ]; - systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ]; + perSystem = + { + config, + self', + inputs', + pkgs, + system, + ... + }: + { + formatter = pkgs.nixfmt-rfc-style; - perSystem = { config, self', inputs', pkgs, system, ... }: { - devShells.default = pkgs.mkShell { - packages = [ inputs'.nixops4.packages.default ]; + devShells.default = pkgs.mkShell { packages = [ inputs'.nixops4.packages.default ]; }; }; - }; - flake.allVmIds = ["101" "102" "103" "104" "105" "106" "107" "108" "109" "110"]; + flake.allVmIds = [ + "101" + "102" + "103" + "104" + "105" + "106" + "107" + "108" + "109" + "110" + ]; flake.nixosConfigurations.provisioning = let inherit (builtins) map listToAttrs; - makeProvisioningConfiguration = vmid: nixpkgs.lib.nixosSystem { - modules = [ - { procolix.vmid = vmid; } - ./procolixVm.nix - inputs.disko.nixosModules.default - ]; - }; + makeProvisioningConfiguration = + vmid: + nixpkgs.lib.nixosSystem { + modules = [ + { procolix.vmid = vmid; } + ./procolixVm.nix + inputs.disko.nixosModules.default + ]; + }; in - listToAttrs - (map - (vmid: { - name = "fedi${vmid}"; - value = makeProvisioningConfiguration vmid; }) - self.allVmIds); + listToAttrs ( + map (vmid: { + name = "fedi${vmid}"; + value = makeProvisioningConfiguration vmid; + }) self.allVmIds + ); flake.isoInstallers.provisioning = - let inherit (builtins) mapAttrs; in - mapAttrs - (_: snf.mkInstaller nixpkgs) - self.nixosConfigurations.provisioning; + let + inherit (builtins) mapAttrs; + in + mapAttrs (_: snf.mkInstaller nixpkgs) self.nixosConfigurations.provisioning; - nixops4Deployments.default = { providers, ... }: + nixops4Deployments.default = + { providers, ... }: let makeProcolixVmResource = vmid: vmconfig: { type = providers.local.exec; - imports = [ - inputs.nixops4-nixos.modules.nixops4Resource.nixos - ]; + imports = [ inputs.nixops4-nixos.modules.nixops4Resource.nixos ]; ssh.opts = ""; ssh.host = "95.215.187.${vmid}"; ssh.hostPublicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOW+f+PUuOBVP4IongWpryzYiOwt19smufZksSwnSPyo"; nixpkgs = inputs.nixpkgs; - nixos.module = { pkgs, modulesPath, ... }: { - imports = [ - vmconfig - { procolix.vmid = vmid; } - ./procolixVm.nix - inputs.snf.nixosModules.fediversity - inputs.disko.nixosModules.default - ]; - }; + nixos.module = + { pkgs, modulesPath, ... }: + { + imports = [ + vmconfig + { procolix.vmid = vmid; } + ./procolixVm.nix + inputs.snf.nixosModules.fediversity + inputs.disko.nixosModules.default + ]; + }; }; in - { - providers.local = inputs.nixops4-nixos.modules.nixops4Provider.local; + { + providers.local = inputs.nixops4-nixos.modules.nixops4Provider.local; - resources = { - fedi101 = makeProcolixVmResource "101" { - fediversity = { - enable = true; - domain = "fediversity.niols.fr"; - pixelfed.enable = true; - }; + resources = { + fedi101 = makeProcolixVmResource "101" { + fediversity = { + enable = true; + domain = "fediversity.niols.fr"; + pixelfed.enable = true; }; }; }; + }; }; } diff --git a/procolixVm.nix b/procolixVm.nix index 99a61c2c..38ebc7a9 100644 --- a/procolixVm.nix +++ b/procolixVm.nix @@ -1,4 +1,9 @@ -{ lib, config, modulesPath, ... }: +{ + lib, + config, + modulesPath, + ... +}: let inherit (lib) mkOption; @@ -6,7 +11,7 @@ let in { - imports = [ (modulesPath + "/profiles/qemu-guest.nix")]; + imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; options = { procolix = { @@ -60,7 +65,10 @@ in interface = "eth0"; }; - nameservers = [ "95.215.185.6" "95.215.185.7" ]; + nameservers = [ + "95.215.185.6" + "95.215.185.7" + ]; }; ######################################################################## @@ -72,7 +80,14 @@ in efi.canTouchEfiVariables = true; }; initrd = { - availableKernelModules = [ "ata_piix" "uhci_hcd" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ]; + availableKernelModules = [ + "ata_piix" + "uhci_hcd" + "virtio_pci" + "virtio_scsi" + "sd_mod" + "sr_mod" + ]; kernelModules = [ "dm-snapshot" ]; }; };