Add formatter

This commit is contained in:
Nicolas Jeannerod 2024-11-08 16:15:39 +01:00
parent aef97d36ad
commit 69336c2624
Signed by untrusted user: Niols
GPG key ID: 35DB9EC8886E1CB8
2 changed files with 100 additions and 52 deletions

129
flake.nix
View file

@ -10,84 +10,117 @@
nixops4-nixos.url = "github:nixops4/nixops4/eval"; 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; } { flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ imports = [ inputs.nixops4-nixos.modules.flake.default ];
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 = flake.nixosConfigurations.provisioning =
let let
inherit (builtins) map listToAttrs; inherit (builtins) map listToAttrs;
makeProvisioningConfiguration = vmid: nixpkgs.lib.nixosSystem { makeProvisioningConfiguration =
modules = [ vmid:
{ procolix.vmid = vmid; } nixpkgs.lib.nixosSystem {
./procolixVm.nix modules = [
inputs.disko.nixosModules.default { procolix.vmid = vmid; }
]; ./procolixVm.nix
}; inputs.disko.nixosModules.default
];
};
in in
listToAttrs listToAttrs (
(map map (vmid: {
(vmid: { name = "fedi${vmid}";
name = "fedi${vmid}"; value = makeProvisioningConfiguration vmid;
value = makeProvisioningConfiguration vmid; }) }) self.allVmIds
self.allVmIds); );
flake.isoInstallers.provisioning = flake.isoInstallers.provisioning =
let inherit (builtins) mapAttrs; in let
mapAttrs inherit (builtins) mapAttrs;
(_: snf.mkInstaller nixpkgs) in
self.nixosConfigurations.provisioning; mapAttrs (_: snf.mkInstaller nixpkgs) self.nixosConfigurations.provisioning;
nixops4Deployments.default = { providers, ... }: nixops4Deployments.default =
{ providers, ... }:
let let
makeProcolixVmResource = vmid: vmconfig: { makeProcolixVmResource = vmid: vmconfig: {
type = providers.local.exec; type = providers.local.exec;
imports = [ imports = [ inputs.nixops4-nixos.modules.nixops4Resource.nixos ];
inputs.nixops4-nixos.modules.nixops4Resource.nixos
];
ssh.opts = ""; ssh.opts = "";
ssh.host = "95.215.187.${vmid}"; ssh.host = "95.215.187.${vmid}";
ssh.hostPublicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOW+f+PUuOBVP4IongWpryzYiOwt19smufZksSwnSPyo"; ssh.hostPublicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOW+f+PUuOBVP4IongWpryzYiOwt19smufZksSwnSPyo";
nixpkgs = inputs.nixpkgs; nixpkgs = inputs.nixpkgs;
nixos.module = { pkgs, modulesPath, ... }: { nixos.module =
imports = [ { pkgs, modulesPath, ... }:
vmconfig {
{ procolix.vmid = vmid; } imports = [
./procolixVm.nix vmconfig
inputs.snf.nixosModules.fediversity { procolix.vmid = vmid; }
inputs.disko.nixosModules.default ./procolixVm.nix
]; inputs.snf.nixosModules.fediversity
}; inputs.disko.nixosModules.default
];
};
}; };
in in
{ {
providers.local = inputs.nixops4-nixos.modules.nixops4Provider.local; providers.local = inputs.nixops4-nixos.modules.nixops4Provider.local;
resources = { resources = {
fedi101 = makeProcolixVmResource "101" { fedi101 = makeProcolixVmResource "101" {
fediversity = { fediversity = {
enable = true; enable = true;
domain = "fediversity.niols.fr"; domain = "fediversity.niols.fr";
pixelfed.enable = true; pixelfed.enable = true;
};
}; };
}; };
}; };
};
}; };
} }

View file

@ -1,4 +1,9 @@
{ lib, config, modulesPath, ... }: {
lib,
config,
modulesPath,
...
}:
let let
inherit (lib) mkOption; inherit (lib) mkOption;
@ -6,7 +11,7 @@ let
in in
{ {
imports = [ (modulesPath + "/profiles/qemu-guest.nix")]; imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
options = { options = {
procolix = { procolix = {
@ -60,7 +65,10 @@ in
interface = "eth0"; 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; efi.canTouchEfiVariables = true;
}; };
initrd = { 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" ]; kernelModules = [ "dm-snapshot" ];
}; };
}; };