run nixpkgs-fmt

This commit is contained in:
Jörg Thalheim 2022-08-14 16:49:30 +02:00
parent 75415763e1
commit 3c90c4e16b
22 changed files with 137 additions and 109 deletions

View file

@ -1,22 +1,22 @@
let let
pkgs = import /var/cache/nixpkgs-update/updatescript/nixpkgs {}; pkgs = import /var/cache/nixpkgs-update/updatescript/nixpkgs { };
in in
# code in the following let block was copied from nixos/nixpkgs under # code in the following let block was copied from nixos/nixpkgs under
# the MIT License # the MIT License
let let
inherit (pkgs) lib; inherit (pkgs) lib;
/* Remove duplicate elements from the list based on some extracted value. O(n^2) complexity. /* Remove duplicate elements from the list based on some extracted value. O(n^2) complexity.
*/ */
nubOn = f: list: nubOn = f: list:
if list == [] then if list == [ ] then
[] [ ]
else else
let let
x = lib.head list; x = lib.head list;
xs = lib.filter (p: f x != f p) (lib.drop 1 list); xs = lib.filter (p: f x != f p) (lib.drop 1 list);
in in
[x] ++ nubOn f xs; [ x ] ++ nubOn f xs;
/* Recursively find all packages (derivations) in `pkgs` matching `cond` predicate. /* Recursively find all packages (derivations) in `pkgs` matching `cond` predicate.
@ -44,16 +44,16 @@ let
else if lib.isAttrs evaluatedPathContent then else if lib.isAttrs evaluatedPathContent then
# If user explicitly points to an attrSet or it is marked for recursion, we recur. # If user explicitly points to an attrSet or it is marked for recursion, we recur.
if path == rootPath || evaluatedPathContent.recurseForDerivations or false || evaluatedPathContent.recurseForRelease or false then if path == rootPath || evaluatedPathContent.recurseForDerivations or false || evaluatedPathContent.recurseForRelease or false then
dedupResults (lib.mapAttrsToList (name: elem: packagesWithPathInner (path ++ [name]) elem) evaluatedPathContent) dedupResults (lib.mapAttrsToList (name: elem: packagesWithPathInner (path ++ [ name ]) elem) evaluatedPathContent)
else [] else [ ]
else [] else [ ]
else []; else [ ];
in in
packagesWithPathInner rootPath pkgs; packagesWithPathInner rootPath pkgs;
/* Recursively find all packages (derivations) in `pkgs` matching `cond` predicate. /* Recursively find all packages (derivations) in `pkgs` matching `cond` predicate.
*/ */
packagesWith = packagesWithPath []; packagesWith = packagesWithPath [ ];
/* Recursively find all packages in `pkgs` with updateScript matching given predicate. /* Recursively find all packages in `pkgs` with updateScript matching given predicate.
*/ */

View file

@ -17,6 +17,7 @@
../roles/hetzner-network.nix ../roles/hetzner-network.nix
../roles/nginx.nix ../roles/nginx.nix
../roles/raid.nix ../roles/raid.nix
../roles/aarch64-builder.nix
../services/hound ../services/hound
../services/matterbridge.nix ../services/matterbridge.nix

View file

@ -34,14 +34,14 @@
# after loading kexec, be patient. The kexec image can take up to 5 minutes to boot # after loading kexec, be patient. The kexec image can take up to 5 minutes to boot
# partition guide # partition guide
/* /*
sgdisk -n 1:0:+800M -N 2 -t 1:ef00 -t 2:8304 /dev/sda sgdisk -n 1:0:+800M -N 2 -t 1:ef00 -t 2:8304 /dev/sda
mkfs.vfat -b32 /dev/sda1 mkfs.vfat -b32 /dev/sda1
zpool create zroot -O acltype=posixacl -O xattr=sa -O compression=lz4 /dev/sda2 zpool create zroot -O acltype=posixacl -O xattr=sa -O compression=lz4 /dev/sda2
zfs create -o mountpoint=none zroot/root zfs create -o mountpoint=none zroot/root
zfs create -o mountpoint=legacy zroot/root/nixos zfs create -o mountpoint=legacy zroot/root/nixos
zfs create -o mountpoint=legacy zroot/root/home zfs create -o mountpoint=legacy zroot/root/home
mount -t zfs zroot/root/nixos /mnt mount -t zfs zroot/root/nixos /mnt
mkdir /mnt/{home,boot} mkdir /mnt/{home,boot}
mount -t zfs zroot/root/home /mnt/home mount -t zfs zroot/root/home /mnt/home
mount /dev/sda1 /mnt/boot mount /dev/sda1 /mnt/boot
*/ */

View file

@ -5,7 +5,8 @@
{ {
imports = imports =
[ (modulesPath + "/profiles/qemu-guest.nix") [
(modulesPath + "/profiles/qemu-guest.nix")
]; ];
boot.initrd.availableKernelModules = [ "xhci_pci" "virtio_pci" ]; boot.initrd.availableKernelModules = [ "xhci_pci" "virtio_pci" ];
@ -14,17 +15,20 @@
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems."/" = fileSystems."/" =
{ device = "zroot/root/nixos"; {
device = "zroot/root/nixos";
fsType = "zfs"; fsType = "zfs";
}; };
fileSystems."/home" = fileSystems."/home" =
{ device = "zroot/root/home"; {
device = "zroot/root/home";
fsType = "zfs"; fsType = "zfs";
}; };
fileSystems."/boot" = fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/E6D6-572B"; {
device = "/dev/disk/by-uuid/E6D6-572B";
fsType = "vfat"; fsType = "vfat";
}; };

View file

@ -3,10 +3,10 @@
nix.distributedBuilds = true; nix.distributedBuilds = true;
nix.buildMachines = [ nix.buildMachines = [
{ {
hostName = "aarch64.nixos.community"; hostName = "build04.nixos-community.org";
maxJobs = 4; maxJobs = 4;
sshKey = config.sops.secrets.id_buildfarm.path; sshKey = config.sops.secrets.id_buildfarm.path;
sshUser = "ssh-ng://nix"; sshUser = "nix";
system = "aarch64-linux"; system = "aarch64-linux";
supportedFeatures = [ supportedFeatures = [
"big-parallel" "big-parallel"
@ -15,5 +15,5 @@
]; ];
} }
]; ];
sops.secrets.id_buildfarm = {}; sops.secrets.id_buildfarm = { };
} }

View file

@ -8,6 +8,6 @@
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEmdo1x1QkRepZf7nSe+OdEWX+wOjkBLF70vX9F+xf68 builder" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEmdo1x1QkRepZf7nSe+OdEWX+wOjkBLF70vX9F+xf68 builder"
]; ];
}; };
users.groups.nix = {}; users.groups.nix = { };
nix.settings.trusted-users = ["nix"]; nix.settings.trusted-users = [ "nix" ];
} }

View file

@ -35,8 +35,8 @@ let
then result then result
else default; else default;
maybeTrusted = ifAttr "trusted" [] [ "trusted" ]; maybeTrusted = ifAttr "trusted" [ ] [ "trusted" ];
maybeWheel = ifAttr "sudo" [] [ "wheel" ]; maybeWheel = ifAttr "sudo" [ ] [ "wheel" ];
userGroups = opts: userGroups = opts:
(maybeTrusted opts) ++ (maybeTrusted opts) ++
@ -53,7 +53,8 @@ let
opts.keys opts.keys
]; ];
}; };
in { in
{
users = { users = {
mutableUsers = false; mutableUsers = false;
users = lib.mapAttrs descToUser users; users = lib.mapAttrs descToUser users;

View file

@ -5,7 +5,8 @@ let
sopsFile = ./secrets.yaml; sopsFile = ./secrets.yaml;
}; };
secrets = config.sops.secrets; secrets = config.sops.secrets;
in { in
{
sops.secrets."binary-caches.json" = herculesSecret; sops.secrets."binary-caches.json" = herculesSecret;
sops.secrets."cluster-join-token.key" = herculesSecret; sops.secrets."cluster-join-token.key" = herculesSecret;
sops.secrets."hercules-secrets" = herculesSecret; sops.secrets."hercules-secrets" = herculesSecret;

View file

@ -2,7 +2,8 @@
with lib; with lib;
let let
cfg = config.networking.nix-community; cfg = config.networking.nix-community;
in { in
{
options = { options = {
networking.nix-community.ipv6.address = mkOption { networking.nix-community.ipv6.address = mkOption {
type = types.str; type = types.str;

View file

@ -42,5 +42,5 @@ in
Restart = "on-failure"; Restart = "on-failure";
}; };
users.groups.trusted = {}; users.groups.trusted = { };
} }

View file

@ -1,5 +1,5 @@
{ {
# for mdraid 1.1 # for mdraid 1.1
boot.loader.grub.extraConfig = "insmod mdraid1x"; boot.loader.grub.extraConfig = "insmod mdraid1x";
services.telegraf.extraConfig.inputs.mdstat = {}; services.telegraf.extraConfig.inputs.mdstat = { };
} }

View file

@ -26,19 +26,19 @@
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl"; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl";
}; };
build01 = { build01 = {
hostNames = ["build01.nix-community.org"]; hostNames = [ "build01.nix-community.org" ];
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIElIQ54qAy7Dh63rBudYKdbzJHrrbrrMXLYl7Pkmk88H"; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIElIQ54qAy7Dh63rBudYKdbzJHrrbrrMXLYl7Pkmk88H";
}; };
build02 = { build02 = {
hostNames = ["build02.nix-community.org"]; hostNames = [ "build02.nix-community.org" ];
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMm3/o1HguyRL1z/nZxLBY9j/YUNXeNuDoiBLZAyt88Z"; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMm3/o1HguyRL1z/nZxLBY9j/YUNXeNuDoiBLZAyt88Z";
}; };
build03 = { build03 = {
hostNames = ["build03.nix-community.org"]; hostNames = [ "build03.nix-community.org" ];
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFiozp1A1+SUfJQPa5DZUQcVc6CZK2ZxL6FJtNdh+2TP"; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFiozp1A1+SUfJQPa5DZUQcVc6CZK2ZxL6FJtNdh+2TP";
}; };
build04 = { build04 = {
hostNames = ["build04.nix-community.org"]; hostNames = [ "build04.nix-community.org" ];
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPU/gbREwVuI1p3ag1iG72jxl2/92yGl38c+TPOfFMH8"; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPU/gbREwVuI1p3ag1iG72jxl2/92yGl38c+TPOfFMH8";
}; };
}; };

View file

@ -25,7 +25,7 @@ in
exec /run/wrappers/bin/sudo ${pkgs.smartmontools}/bin/smartctl "$@" exec /run/wrappers/bin/sudo ${pkgs.smartmontools}/bin/smartctl "$@"
''; '';
}; };
mdstat = {}; mdstat = { };
system = { }; system = { };
mem = { }; mem = { };
file = [{ file = [{
@ -52,21 +52,27 @@ in
} }
} }
'') '')
) ++ (let ) ++ (
let
collectHosts = shares: fs: collectHosts = shares: fs:
if builtins.elem fs.fsType ["nfs" "nfs3" "nfs4"] then if builtins.elem fs.fsType [ "nfs" "nfs3" "nfs4" ] then
shares // (let shares // (
let
# also match ipv6 addresses # also match ipv6 addresses
group = builtins.match "\\[?([^\]]+)]?:([^:]+)$" fs.device; group = builtins.match "\\[?([^\]]+)]?:([^:]+)$" fs.device;
host = builtins.head group; host = builtins.head group;
path = builtins.elemAt group 1; path = builtins.elemAt group 1;
in { in
${host} = (shares.${host} or []) ++ [ path ]; {
}) ${host} = (shares.${host} or [ ]) ++ [ path ];
}
)
else else
shares; shares;
nfsHosts = lib.foldl collectHosts {} (builtins.attrValues config.fileSystems); nfsHosts = lib.foldl collectHosts { } (builtins.attrValues config.fileSystems);
in lib.mapAttrsToList (host: args: in
lib.mapAttrsToList
(host: args:
(pkgs.writeScript "zpool-health" '' (pkgs.writeScript "zpool-health" ''
#!${pkgs.gawk}/bin/awk -f #!${pkgs.gawk}/bin/awk -f
BEGIN { BEGIN {
@ -85,7 +91,8 @@ in
} }
} }
'') + " ${host} ${builtins.concatStringsSep " " args}" '') + " ${host} ${builtins.concatStringsSep " " args}"
) nfsHosts )
nfsHosts
); );
data_format = "influx"; data_format = "influx";
}]; }];

View file

@ -1,4 +1,4 @@
{...}: { { ... }: {
services.zfs = { services.zfs = {
autoSnapshot.enable = true; autoSnapshot.enable = true;
# defaults to 12, which is a bit much given how much data is written # defaults to 12, which is a bit much given how much data is written

View file

@ -1,8 +1,9 @@
{ hydra }: { hydra }: { lib
{ lib, pkgs, config, ... }: , pkgs
, config
with lib; , ...
let }:
with lib; let
cfg = config; cfg = config;
hydraPort = 3000; hydraPort = 3000;
@ -53,7 +54,8 @@ in
unfreeRedistributable unfreeRedistributable
issl issl
]; ];
allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ allowUnfreePredicate = pkg:
builtins.elem (lib.getName pkg) [
"cudnn_cudatoolkit" "cudnn_cudatoolkit"
"cudatoolkit" "cudatoolkit"
]; ];
@ -62,7 +64,7 @@ in
services.hydra.package = hydra.defaultPackage.${pkgs.system}; services.hydra.package = hydra.defaultPackage.${pkgs.system};
sops.secrets.nix-community-cachix.sopsFile = ../../roles/nix-community-cache.yaml; sops.secrets.nix-community-cachix.sopsFile = ../../roles/nix-community-cache.yaml;
sops.secrets.id_buildfarm = {}; sops.secrets.id_buildfarm = { };
services.hydra = { services.hydra = {
enable = true; enable = true;
@ -71,19 +73,24 @@ in
port = hydraPort; port = hydraPort;
useSubstitutes = true; useSubstitutes = true;
adminPasswordFile = config.sops.secrets.hydra-admin-password.path; adminPasswordFile = config.sops.secrets.hydra-admin-password.path;
buildMachinesFiles = [
(pkgs.writeText "builders" ''
localhost x86_64-linux,builtin - 8 1 nixos-test,big-parallel,kvm -
ssh://nix@build04.nix-community.org aarch64-linux ${config.sops.secrets.id_buildfarm.path} 4 1 nixos-test,big-parallel,kvm -
'')
];
usersFile = config.sops.secrets.hydra-users.path; usersFile = config.sops.secrets.hydra-users.path;
extraConfig = '' extraConfig = ''
max_output_size = ${builtins.toString (8 * 1024 * 1024 * 1024)} max_output_size = ${builtins.toString (8 * 1024 * 1024 * 1024)}
''; '';
}; };
nix = {
distributedBuilds = true;
buildMachines = [
{
hostName = "localhost";
systems = [ "x86_64-linux" "builtin" ];
maxJobs = 8;
supportedFeatures = [ "nixos-test" "big-parallel" "kvm" ];
}
];
};
services.postgresql = { services.postgresql = {
enable = true; enable = true;
settings = { settings = {

View file

@ -12,7 +12,8 @@ in
useDefaultShell = true; useDefaultShell = true;
isNormalUser = true; isNormalUser = true;
extraGroups = [ extraGroups = [
"wheel" "trusted" "wheel"
"trusted"
]; ];
uid = userLib.mkUid "adis"; uid = userLib.mkUid "adis";
}; };

View file

@ -11,7 +11,8 @@ in
useDefaultShell = true; useDefaultShell = true;
isNormalUser = true; isNormalUser = true;
extraGroups = [ extraGroups = [
"wheel" "trusted" "wheel"
"trusted"
]; ];
uid = userLib.mkUid "flok"; uid = userLib.mkUid "flok";
}; };

View file

@ -11,7 +11,8 @@ in
useDefaultShell = true; useDefaultShell = true;
isNormalUser = true; isNormalUser = true;
extraGroups = [ extraGroups = [
"wheel" "trusted" "wheel"
"trusted"
]; ];
uid = userLib.mkUid "lewo"; uid = userLib.mkUid "lewo";
}; };

View file

@ -11,7 +11,8 @@ in
useDefaultShell = true; useDefaultShell = true;
isNormalUser = true; isNormalUser = true;
extraGroups = [ extraGroups = [
"wheel" "trusted" "wheel"
"trusted"
]; ];
uid = userLib.mkUid "micc"; uid = userLib.mkUid "micc";
}; };

View file

@ -12,7 +12,8 @@ in
useDefaultShell = true; useDefaultShell = true;
isNormalUser = true; isNormalUser = true;
extraGroups = [ extraGroups = [
"wheel" "trusted" "wheel"
"trusted"
]; ];
uid = userLib.mkUid "rytm"; uid = userLib.mkUid "rytm";
}; };

View file

@ -13,7 +13,8 @@ in
useDefaultShell = true; useDefaultShell = true;
isNormalUser = true; isNormalUser = true;
extraGroups = [ extraGroups = [
"wheel" "trusted" "wheel"
"trusted"
]; ];
uid = userLib.mkUid "zimb"; uid = userLib.mkUid "zimb";
}; };