switch to nixfmt

This commit is contained in:
Jörg Thalheim 2024-09-28 16:15:00 +02:00 committed by mergify[bot]
parent d7c7acb065
commit ada004ff16
14 changed files with 188 additions and 130 deletions

View File

@ -1,9 +1,12 @@
{ self, ... }: { { self, ... }:
{
perSystem = perSystem =
{ pkgs {
, lib pkgs,
, ... lib,
}: { ...
}:
{
checks = lib.optionalAttrs pkgs.stdenv.isLinux { checks = lib.optionalAttrs pkgs.stdenv.isLinux {
test = import ./test.nix { inherit self pkgs; }; test = import ./test.nix { inherit self pkgs; };
}; };

View File

@ -15,6 +15,8 @@ in
# This makes `self` available in the NixOS configuration of our virtual machines. # This makes `self` available in the NixOS configuration of our virtual machines.
# This is useful for referencing modules or packages from your own flake # This is useful for referencing modules or packages from your own flake
# as well as importing from other flakes. # as well as importing from other flakes.
node.specialArgs = { inherit self; }; node.specialArgs = {
inherit self;
};
imports = [ test ]; imports = [ test ];
}).config.result }).config.result

View File

@ -1,4 +1,6 @@
{ pkgs ? import <nixpkgs> { } }: {
pkgs ? import <nixpkgs> { },
}:
{ {
wikiextractor = pkgs.callPackage ./wikiextractor.nix { }; wikiextractor = pkgs.callPackage ./wikiextractor.nix { };
} }

View File

@ -1,8 +1,8 @@
{ lib {
, python3 lib,
, fetchpatch python3,
, fetchFromGitHub fetchpatch,
, fetchFromGitHub,
}: }:
python3.pkgs.buildPythonApplication rec { python3.pkgs.buildPythonApplication rec {

View File

@ -2,7 +2,14 @@
name = "nixos-wiki"; name = "nixos-wiki";
nodes = { nodes = {
# `self` here is set by using specialArgs in `lib.nix` # `self` here is set by using specialArgs in `lib.nix`
wiki = { self, pkgs, config, ... }: { wiki =
{
self,
pkgs,
config,
...
}:
{
imports = [ imports = [
self.nixosModules.nixos-wiki self.nixosModules.nixos-wiki
]; ];

View File

@ -19,8 +19,11 @@
sops-nix.inputs.nixpkgs-stable.follows = ""; sops-nix.inputs.nixpkgs-stable.follows = "";
}; };
outputs = inputs@{ flake-parts, ... }: outputs =
flake-parts.lib.mkFlake { inherit inputs; } ({ self, lib, ... }: { inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } (
{ self, lib, ... }:
{
systems = [ systems = [
"aarch64-linux" "aarch64-linux"
"x86_64-linux" "x86_64-linux"
@ -35,15 +38,20 @@
./checks/flake-module.nix ./checks/flake-module.nix
./formatter.nix ./formatter.nix
]; ];
perSystem = { self', system, ... }: { perSystem =
{ self', system, ... }:
{
checks = checks =
let let
nixosMachines = lib.mapAttrs' (name: config: lib.nameValuePair "nixos-${name}" config.config.system.build.toplevel) ((lib.filterAttrs (_: config: config.pkgs.system == system)) self.nixosConfigurations); nixosMachines = lib.mapAttrs' (
name: config: lib.nameValuePair "nixos-${name}" config.config.system.build.toplevel
) ((lib.filterAttrs (_: config: config.pkgs.system == system)) self.nixosConfigurations);
packages = lib.mapAttrs' (n: lib.nameValuePair "package-${n}") self'.packages; packages = lib.mapAttrs' (n: lib.nameValuePair "package-${n}") self'.packages;
devShells = lib.mapAttrs' (n: lib.nameValuePair "devShell-${n}") self'.devShells; devShells = lib.mapAttrs' (n: lib.nameValuePair "devShell-${n}") self'.devShells;
in in
nixosMachines // packages // devShells; nixosMachines // packages // devShells;
}; };
}); }
);
} }

View File

@ -17,7 +17,8 @@
"targets/nixos-wiki.nixos.org/secrets/*" "targets/nixos-wiki.nixos.org/secrets/*"
]; ];
programs.hclfmt.enable = true; programs.hclfmt.enable = true;
programs.nixpkgs-fmt.enable = true; programs.nixfmt.enable = true;
programs.nixfmt.package = pkgs.nixfmt-rfc-style;
programs.deadnix.enable = true; programs.deadnix.enable = true;
programs.ruff.format = true; programs.ruff.format = true;
programs.ruff.check = true; programs.ruff.check = true;
@ -39,8 +40,7 @@
provider.override (prev: { provider.override (prev: {
homepage = builtins.replaceStrings [ "registry.terraform.io/providers" ] [ homepage = builtins.replaceStrings [ "registry.terraform.io/providers" ] [
"registry.opentofu.org" "registry.opentofu.org"
] ] prev.homepage;
prev.homepage;
}); });
in in
[ [
@ -57,8 +57,7 @@
)) ))
]; ];
}; };
} } // (import ./checks/linkcheck/pkgs { inherit pkgs; });
// (import ./checks/linkcheck/pkgs { inherit pkgs; });
devShells.linkcheck = pkgs.mkShell { devShells.linkcheck = pkgs.mkShell {
packages = [ packages = [
pkgs.lychee pkgs.lychee

View File

@ -1,4 +1,5 @@
{ inputs, ... }: { { inputs, ... }:
{
flake.nixosModules = { flake.nixosModules = {
hcloud.imports = [ hcloud.imports = [
inputs.srvos.nixosModules.server inputs.srvos.nixosModules.server

View File

@ -7,4 +7,3 @@
ip6tables -D nixos-fw -p tcp --source 2a03:4000:62:fdb::/128 --dport 9273 -j nixos-fw-accept || true ip6tables -D nixos-fw -p tcp --source 2a03:4000:62:fdb::/128 --dport 9273 -j nixos-fw-accept || true
''; '';
} }

View File

@ -2,19 +2,20 @@
let let
wikiDump = "/var/lib/mediawiki/backup/wikidump.xml.zst"; wikiDump = "/var/lib/mediawiki/backup/wikidump.xml.zst";
mediawiki-maintenance = pkgs.runCommand "mediawiki-maintenance" mediawiki-maintenance =
pkgs.runCommand "mediawiki-maintenance"
{ {
nativeBuildInputs = [ pkgs.makeWrapper ]; nativeBuildInputs = [ pkgs.makeWrapper ];
preferLocalBuild = true; preferLocalBuild = true;
} '' }
''
mkdir -p $out/bin mkdir -p $out/bin
makeWrapper ${config.services.phpfpm.pools.mediawiki.phpPackage}/bin/php $out/bin/mediawiki-maintenance \ makeWrapper ${config.services.phpfpm.pools.mediawiki.phpPackage}/bin/php $out/bin/mediawiki-maintenance \
--set MEDIAWIKI_CONFIG ${config.services.phpfpm.pools.mediawiki.phpEnv.MEDIAWIKI_CONFIG} \ --set MEDIAWIKI_CONFIG ${config.services.phpfpm.pools.mediawiki.phpEnv.MEDIAWIKI_CONFIG} \
--add-flags ${config.services.mediawiki.finalPackage}/share/mediawiki/maintenance/run.php --add-flags ${config.services.mediawiki.finalPackage}/share/mediawiki/maintenance/run.php
''; '';
wiki-backup = pkgs.writeShellApplication wiki-backup = pkgs.writeShellApplication {
{
name = "wiki-backup"; name = "wiki-backup";
runtimeInputs = [ runtimeInputs = [
config.services.postgresql.package config.services.postgresql.package
@ -30,10 +31,12 @@ let
# to restore: # to restore:
# $ runuser -u postgres -- pg_restore --format=custom -d mediawiki < /tmp/db # $ runuser -u postgres -- pg_restore --format=custom -d mediawiki < /tmp/db
wiki-dump = pkgs.writeShellApplication wiki-dump = pkgs.writeShellApplication {
{
name = "wiki-dump"; name = "wiki-dump";
runtimeInputs = [ pkgs.util-linux pkgs.coreutils ]; runtimeInputs = [
pkgs.util-linux
pkgs.coreutils
];
text = '' text = ''
mkdir -p /var/lib/mediawiki/backup/ mkdir -p /var/lib/mediawiki/backup/
runuser -u mediawiki -- ${mediawiki-maintenance}/bin/mediawiki-maintenance dumpBackup.php \ runuser -u mediawiki -- ${mediawiki-maintenance}/bin/mediawiki-maintenance dumpBackup.php \
@ -74,7 +77,8 @@ in
}; };
}; };
services.nginx.virtualHosts.${config.services.mediawiki.nginx.hostName}.locations."=/wikidump.xml.zst".alias = wikiDump; services.nginx.virtualHosts.${config.services.mediawiki.nginx.hostName}.locations."=/wikidump.xml.zst".alias =
wikiDump;
sops.secrets.storagebox-ssh-key = { sops.secrets.storagebox-ssh-key = {
sopsFile = ../../targets/nixos-wiki.nixos.org/secrets/backup_share_ssh_key; sopsFile = ../../targets/nixos-wiki.nixos.org/secrets/backup_share_ssh_key;
@ -113,7 +117,10 @@ in
monthly = 3; monthly = 3;
}; };
paths = [ "/var/lib/mediawiki-uploads" "/var/lib/mediawiki/backup" ]; paths = [
"/var/lib/mediawiki-uploads"
"/var/lib/mediawiki/backup"
];
# Where to backup it to # Where to backup it to
repo = "u391032-sub1@u391032.your-storagebox.de:wiki.nixos.org/repo"; repo = "u391032-sub1@u391032.your-storagebox.de:wiki.nixos.org/repo";

View File

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.services.nixos-wiki; cfg = config.services.nixos-wiki;
in in
@ -175,7 +180,9 @@ in
# https://www.mediawiki.org/wiki/Help:Extension:Translate/Installation # https://www.mediawiki.org/wiki/Help:Extension:Translate/Installation
services.phpfpm.pools.mediawiki.phpOptions = services.phpfpm.pools.mediawiki.phpOptions =
let let
phpVersion = builtins.replaceStrings [ "." ] [ "" ] (lib.versions.majorMinor config.services.phpfpm.pools.mediawiki.phpPackage.version); phpVersion = builtins.replaceStrings [ "." ] [ "" ] (
lib.versions.majorMinor config.services.phpfpm.pools.mediawiki.phpPackage.version
);
extensions = pkgs."php${phpVersion}Extensions"; extensions = pkgs."php${phpVersion}Extensions";
in in
'' ''
@ -202,9 +209,10 @@ in
''; '';
systemd.services.mediawiki-init.serviceConfig.RemainAfterExit = true; systemd.services.mediawiki-init.serviceConfig.RemainAfterExit = true;
networking.firewall.allowedTCPPorts = [
443
networking.firewall.allowedTCPPorts = [ 443 80 ]; 80
];
security.acme.acceptTerms = true; security.acme.acceptTerms = true;
services.nginx.virtualHosts.${config.services.mediawiki.nginx.hostName} = { services.nginx.virtualHosts.${config.services.mediawiki.nginx.hostName} = {
enableACME = lib.mkDefault true; enableACME = lib.mkDefault true;

View File

@ -1,7 +1,23 @@
{ fetchzip }: { { fetchzip }:
"MobileFrontend" = fetchzip { url = "https://github.com/NixOS/nixos-wiki-infra/releases/download/MobileFrontend-REL1_42-db1bbe7.tar.gz/MobileFrontend-REL1_42-db1bbe7.tar.gz"; hash = "sha256-jHeG1pr/YEdIsrCUPKLJ6DXdOW52sYjCXex3Ns9pi4A="; }; {
"DarkMode" = fetchzip { url = "https://github.com/NixOS/nixos-wiki-infra/releases/download/DarkMode-REL1_42-66aad97.tar.gz/DarkMode-REL1_42-66aad97.tar.gz"; hash = "sha256-xt7+yiD2oDsK0q7tsqAtYdiKcLqWr8DiWl+zAmoqQpg="; }; "MobileFrontend" = fetchzip {
"QuickInstantCommons" = fetchzip { url = "https://github.com/NixOS/nixos-wiki-infra/releases/download/QuickInstantCommons-REL1_42-3e6a069.tar.gz/QuickInstantCommons-REL1_42-3e6a069.tar.gz"; hash = "sha256-U7mNjhr0kI46gWForiUBKXQEYSuvME8+YVwMOVpuhm0="; }; url = "https://github.com/NixOS/nixos-wiki-infra/releases/download/MobileFrontend-REL1_42-db1bbe7.tar.gz/MobileFrontend-REL1_42-db1bbe7.tar.gz";
"Translate" = fetchzip { url = "https://github.com/NixOS/nixos-wiki-infra/releases/download/Translate-REL1_42-3531d86.tar.gz/Translate-REL1_42-3531d86.tar.gz"; hash = "sha256-t1fBccarl0wQTlrCM4UDJyGw8M9eCyUk7Wbk8AxRG7w="; }; hash = "sha256-jHeG1pr/YEdIsrCUPKLJ6DXdOW52sYjCXex3Ns9pi4A=";
"UniversalLanguageSelector" = fetchzip { url = "https://github.com/NixOS/nixos-wiki-infra/releases/download/UniversalLanguageSelector-REL1_42-17bbc88.tar.gz/UniversalLanguageSelector-REL1_42-17bbc88.tar.gz"; hash = "sha256-XujlyG3K07XAzW+Vat8NZypKIpHwGCZt6bxmxH57e0M="; }; };
"DarkMode" = fetchzip {
url = "https://github.com/NixOS/nixos-wiki-infra/releases/download/DarkMode-REL1_42-66aad97.tar.gz/DarkMode-REL1_42-66aad97.tar.gz";
hash = "sha256-xt7+yiD2oDsK0q7tsqAtYdiKcLqWr8DiWl+zAmoqQpg=";
};
"QuickInstantCommons" = fetchzip {
url = "https://github.com/NixOS/nixos-wiki-infra/releases/download/QuickInstantCommons-REL1_42-3e6a069.tar.gz/QuickInstantCommons-REL1_42-3e6a069.tar.gz";
hash = "sha256-U7mNjhr0kI46gWForiUBKXQEYSuvME8+YVwMOVpuhm0=";
};
"Translate" = fetchzip {
url = "https://github.com/NixOS/nixos-wiki-infra/releases/download/Translate-REL1_42-3531d86.tar.gz/Translate-REL1_42-3531d86.tar.gz";
hash = "sha256-t1fBccarl0wQTlrCM4UDJyGw8M9eCyUk7Wbk8AxRG7w=";
};
"UniversalLanguageSelector" = fetchzip {
url = "https://github.com/NixOS/nixos-wiki-infra/releases/download/UniversalLanguageSelector-REL1_42-17bbc88.tar.gz/UniversalLanguageSelector-REL1_42-17bbc88.tar.gz";
hash = "sha256-XujlyG3K07XAzW+Vat8NZypKIpHwGCZt6bxmxH57e0M=";
};
} }

View File

@ -4,12 +4,11 @@ let
configs = builtins.filter (dir: builtins.pathExists (./. + "/${dir}/configuration.nix")) entries; configs = builtins.filter (dir: builtins.pathExists (./. + "/${dir}/configuration.nix")) entries;
in in
{ {
flake.nixosConfigurations = lib.listToAttrs flake.nixosConfigurations = lib.listToAttrs (
(builtins.map builtins.map (
(name: name:
lib.nameValuePair lib.nameValuePair (builtins.replaceStrings [ "." ] [ "-" ] name) (
(builtins.replaceStrings [ "." ] [ "-" ] name) lib.nixosSystem {
(lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
# Make flake available in modules # Make flake available in modules
specialArgs = { specialArgs = {
@ -20,6 +19,8 @@ in
}; };
modules = [ (./. + "/${name}/configuration.nix") ]; modules = [ (./. + "/${name}/configuration.nix") ];
})) }
configs); )
) configs
);
} }

View File

@ -1,4 +1,9 @@
{ self, lib, config, ... }: {
self,
lib,
config,
...
}:
let let
nixosVars = builtins.fromJSON (builtins.readFile ./nixos-vars.json); nixosVars = builtins.fromJSON (builtins.readFile ./nixos-vars.json);
in in