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 =
{ pkgs
, lib
, ...
}: {
{
pkgs,
lib,
...
}:
{
checks = lib.optionalAttrs pkgs.stdenv.isLinux {
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 is useful for referencing modules or packages from your own flake
# as well as importing from other flakes.
node.specialArgs = { inherit self; };
node.specialArgs = {
inherit self;
};
imports = [ test ];
}).config.result

View File

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

View File

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

View File

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

View File

@ -19,8 +19,11 @@
sops-nix.inputs.nixpkgs-stable.follows = "";
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } ({ self, lib, ... }: {
outputs =
inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } (
{ self, lib, ... }:
{
systems = [
"aarch64-linux"
"x86_64-linux"
@ -35,15 +38,20 @@
./checks/flake-module.nix
./formatter.nix
];
perSystem = { self', system, ... }: {
perSystem =
{ self', system, ... }:
{
checks =
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;
devShells = lib.mapAttrs' (n: lib.nameValuePair "devShell-${n}") self'.devShells;
in
nixosMachines // packages // devShells;
};
});
}
);
}

View File

@ -17,7 +17,8 @@
"targets/nixos-wiki.nixos.org/secrets/*"
];
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.ruff.format = true;
programs.ruff.check = true;
@ -39,8 +40,7 @@
provider.override (prev: {
homepage = builtins.replaceStrings [ "registry.terraform.io/providers" ] [
"registry.opentofu.org"
]
prev.homepage;
] prev.homepage;
});
in
[
@ -57,8 +57,7 @@
))
];
};
}
// (import ./checks/linkcheck/pkgs { inherit pkgs; });
} // (import ./checks/linkcheck/pkgs { inherit pkgs; });
devShells.linkcheck = pkgs.mkShell {
packages = [
pkgs.lychee

View File

@ -1,4 +1,5 @@
{ inputs, ... }: {
{ inputs, ... }:
{
flake.nixosModules = {
hcloud.imports = [
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
'';
}

View File

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

View File

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }:
{
config,
pkgs,
lib,
...
}:
let
cfg = config.services.nixos-wiki;
in
@ -175,7 +180,9 @@ in
# https://www.mediawiki.org/wiki/Help:Extension:Translate/Installation
services.phpfpm.pools.mediawiki.phpOptions =
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";
in
''
@ -202,9 +209,10 @@ in
'';
systemd.services.mediawiki-init.serviceConfig.RemainAfterExit = true;
networking.firewall.allowedTCPPorts = [ 443 80 ];
networking.firewall.allowedTCPPorts = [
443
80
];
security.acme.acceptTerms = true;
services.nginx.virtualHosts.${config.services.mediawiki.nginx.hostName} = {
enableACME = lib.mkDefault true;

View File

@ -1,7 +1,23 @@
{ 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="; };
"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="; };
{ 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=";
};
"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;
in
{
flake.nixosConfigurations = lib.listToAttrs
(builtins.map
(name:
lib.nameValuePair
(builtins.replaceStrings [ "." ] [ "-" ] name)
(lib.nixosSystem {
flake.nixosConfigurations = lib.listToAttrs (
builtins.map (
name:
lib.nameValuePair (builtins.replaceStrings [ "." ] [ "-" ] name) (
lib.nixosSystem {
system = "x86_64-linux";
# Make flake available in modules
specialArgs = {
@ -20,6 +19,8 @@ in
};
modules = [ (./. + "/${name}/configuration.nix") ];
}))
configs);
}
)
) configs
);
}

View File

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