switch to nixpkgs-fmt

This commit is contained in:
Tim Schubert 2022-08-04 21:13:54 +02:00
parent 8cd6ed1502
commit c43341a8b2
Signed by: dadada
GPG key ID: EEB8D1CE62C4DFEA
69 changed files with 664 additions and 665 deletions

View file

@ -1,12 +1,11 @@
{
config,
pkgs,
lib,
...
{ config
, pkgs
, lib
, ...
}:
with lib; let
cfg = config.dadada.admin;
extraGroups = ["wheel" "libvirtd"];
extraGroups = [ "wheel" "libvirtd" ];
shells = {
"bash" = pkgs.bashInteractive;
@ -16,40 +15,41 @@ with lib; let
shellNames = builtins.attrNames shells;
adminOpts = {
name,
config,
...
}: {
options = {
keys = mkOption {
type = types.listOf types.str;
default = [];
apply = x: assert (builtins.length x > 0 || abort "Please specify at least one key to be able to log in"); x;
description = ''
The keys that should be able to access the account.
'';
};
shell = mkOption {
type = types.nullOr types.str;
apply = x: assert (builtins.elem x shellNames || abort "Please specify one of ${builtins.toString shellNames}"); x;
default = "zsh";
defaultText = literalExpression "zsh";
example = literalExpression "bash";
description = ''
One of ${builtins.toString shellNames}
'';
adminOpts =
{ name
, config
, ...
}: {
options = {
keys = mkOption {
type = types.listOf types.str;
default = [ ];
apply = x: assert (builtins.length x > 0 || abort "Please specify at least one key to be able to log in"); x;
description = ''
The keys that should be able to access the account.
'';
};
shell = mkOption {
type = types.nullOr types.str;
apply = x: assert (builtins.elem x shellNames || abort "Please specify one of ${builtins.toString shellNames}"); x;
default = "zsh";
defaultText = literalExpression "zsh";
example = literalExpression "bash";
description = ''
One of ${builtins.toString shellNames}
'';
};
};
};
};
in {
in
{
options = {
dadada.admin = {
enable = mkEnableOption "Enable admin access";
users = mkOption {
type = with types; attrsOf (submodule adminOpts);
default = {};
default = { };
description = ''
Admin users with root access machine.
'';
@ -76,13 +76,13 @@ in {
users.users =
mapAttrs
(user: keys: {
shell = shells."${keys.shell}";
extraGroups = extraGroups;
isNormalUser = true;
openssh.authorizedKeys.keys = keys.keys;
})
cfg.users;
(user: keys: {
shell = shells."${keys.shell}";
extraGroups = extraGroups;
isNormalUser = true;
openssh.authorizedKeys.keys = keys.keys;
})
cfg.users;
nix.trustedUsers = builtins.attrNames cfg.users;
@ -96,7 +96,7 @@ in {
services.tor.relay.onionServices = {
"rat" = mkIf cfg.rat.enable {
name = "rat";
map = [{port = 22;}];
map = [{ port = 22; }];
};
};
};

View file

@ -1,8 +1,7 @@
{
config,
pkgs,
lib,
...
{ config
, pkgs
, lib
, ...
}:
with lib; let
backupExcludes = [
@ -24,7 +23,8 @@ with lib; let
"/var/tmp"
];
cfg = config.dadada.backupClient;
in {
in
{
options = {
dadada.backupClient = {
gs = {
@ -62,7 +62,7 @@ in {
"/backup" = {
device = "/dev/disk/by-uuid/0fdab735-cc3e-493a-b4ec-cbf6a77d48d5";
fsType = "ext4";
options = ["x-systemd.automount" "noauto" "x-systemd.idle-timeout=600"];
options = [ "x-systemd.automount" "noauto" "x-systemd.idle-timeout=600" ];
};
};

View file

@ -1,41 +1,41 @@
{
config,
pkgs,
lib,
...
{ config
, pkgs
, lib
, ...
}:
with lib; let
cfg = config.dadada.ddns;
ddnsConfig = hostNames: {
systemd.timers = listToAttrs (forEach hostNames (hostname:
nameValuePair "ddns-${hostname}"
{
wantedBy = ["timers.target"];
partOf = ["ddns-${hostname}.service"];
timerConfig.OnCalendar = "hourly";
}));
{
wantedBy = [ "timers.target" ];
partOf = [ "ddns-${hostname}.service" ];
timerConfig.OnCalendar = "hourly";
}));
systemd.services = listToAttrs (forEach hostNames (hostname:
nameValuePair "ddns-${hostname}"
{
serviceConfig.Type = "oneshot";
script = ''
function url() {
echo "https://svc.joker.com/nic/update?username=$1&password=$2&hostname=$3"
}
{
serviceConfig.Type = "oneshot";
script = ''
function url() {
echo "https://svc.joker.com/nic/update?username=$1&password=$2&hostname=$3"
}
IFS=':'
read -r user password < /var/lib/ddns/credentials
unset IFS
IFS=':'
read -r user password < /var/lib/ddns/credentials
unset IFS
curl_url=$(url "$user" "$password" ${hostname})
curl_url=$(url "$user" "$password" ${hostname})
${pkgs.curl}/bin/curl -4 "$curl_url"
${pkgs.curl}/bin/curl -6 "$curl_url"
'';
}));
${pkgs.curl}/bin/curl -4 "$curl_url"
${pkgs.curl}/bin/curl -6 "$curl_url"
'';
}));
};
in {
in
{
options = {
dadada.ddns.domains = mkOption {
type = types.listOf types.str;
@ -45,7 +45,7 @@ in {
example = ''
[ "example.com" ]
'';
default = [];
default = [ ];
};
};

View file

@ -1,4 +1,4 @@
{...} @ inputs: {
{ ... } @ inputs: {
admin = import ./admin.nix;
backup = import ./backup.nix;
ddns = import ./ddns.nix;

View file

@ -1,11 +1,12 @@
{
config,
pkgs,
lib,
...
}: let
{ config
, pkgs
, lib
, ...
}:
let
cfg = config.dadada.element;
in {
in
{
options.dadada.element = {
enable = lib.mkEnableOption "Enable element webapp";
};

View file

@ -1,13 +1,13 @@
{
config,
pkgs,
lib,
...
{ config
, pkgs
, lib
, ...
}:
with lib; let
luks = config.dadada.luks;
fido2 = config.dadada.fido2;
in {
in
{
options = {
dadada.luks = {
uuid = mkOption {

View file

@ -1,14 +1,14 @@
{
config,
lib,
...
{ config
, lib
, ...
}:
with lib; let
cfg = config.dadada.fileShare;
sharePath = "/mnt/storage/share";
ipv6 = "fd42:dead:beef::/48";
ipv4 = "192.168.42.0/24";
in {
in
{
options.dadada.fileShare = {
enable = mkEnableOption "Enable file share server";
};

View file

@ -1,12 +1,13 @@
{
config,
pkgs,
lib,
...
}: let
{ config
, pkgs
, lib
, ...
}:
let
redisSocket = "127.0.0.1:6379";
cfg = config.dadada.gitea;
in {
in
{
options.dadada.gitea = {
enable = lib.mkEnableOption "Enable gitea";
};

View file

@ -1,12 +1,12 @@
{
config,
pkgs,
lib,
...
{ config
, pkgs
, lib
, ...
}:
with lib; let
cfg = config.dadada.headphones;
in {
in
{
options = {
dadada.headphones = {
enable = mkEnableOption "Enable bluetooth headphones with more audio codecs.";
@ -17,7 +17,7 @@ in {
bluetooth.enable = true;
pulseaudio = {
enable = true;
extraModules = [pkgs.pulseaudio-modules-bt];
extraModules = [ pkgs.pulseaudio-modules-bt ];
extraConfig = ''
set-source-volume 1 10000
'';

View file

@ -1,22 +1,22 @@
{
config,
pkgs,
lib,
...
}: let
{ config
, pkgs
, lib
, ...
}:
let
cfg = config.dadada.homePage;
in
with lib; {
options.dadada.homePage = {
enable = mkEnableOption "Enable home page";
};
config = mkIf cfg.enable {
services.nginx.enable = true;
with lib; {
options.dadada.homePage = {
enable = mkEnableOption "Enable home page";
};
config = mkIf cfg.enable {
services.nginx.enable = true;
services.nginx.virtualHosts."dadada.li" = {
enableACME = true;
forceSSL = true;
root = "${pkgs.homePage}";
};
services.nginx.virtualHosts."dadada.li" = {
enableACME = true;
forceSSL = true;
root = "${pkgs.homePage}";
};
}
};
}

View file

@ -1,12 +1,13 @@
# Source https://github.com/NixOS/nixpkgs/issues/113384
{
config,
lib,
pkgs,
...
}: let
{ config
, lib
, pkgs
, ...
}:
let
cfg = config.dadada.kanboard;
in {
in
{
options = {
dadada.kanboard.enable = lib.mkEnableOption "Enable Kanboard";
};
@ -23,7 +24,7 @@ in {
};
users.users.kanboard.isSystemUser = true;
users.users.kanboard.group = "kanboard";
users.groups.kanboard.members = ["kanboard"];
users.groups.kanboard.members = [ "kanboard" ];
systemd.tmpfiles.rules = [
"d /var/lib/kanboard/data 0750 kanboard nginx - -"
@ -35,7 +36,7 @@ in {
root = pkgs.buildEnv {
name = "kanboard-configured";
paths = [
(pkgs.runCommand "kanboard-over" {meta.priority = 0;} ''
(pkgs.runCommand "kanboard-over" { meta.priority = 0; } ''
mkdir -p $out
for f in index.php jsonrpc.php ; do
echo "<?php require('$out/config.php');" > $out/$f

View file

@ -1,13 +1,13 @@
{
config,
pkgs,
lib,
...
{ config
, pkgs
, lib
, ...
}:
with lib; let
cfg = config.dadada.networking;
vpnPubKey = "x/y6I59buVzv9Lfzl+b17mGWbzxU+3Ke9mQNa1DLsDI=";
in {
in
{
options = {
dadada.networking = {
localResolver = {
@ -18,7 +18,7 @@ in {
wanInterfaces = mkOption {
type = with types; listOf str;
description = "WAN network interfaces";
default = [];
default = [ ];
};
vpnExtension = mkOption {
type = with types; nullOr str;
@ -122,7 +122,7 @@ in {
networking.wireguard.interfaces = mkIf (cfg.vpnExtension != null) {
dadada = {
ips = ["fd42:9c3b:f96d:201::${cfg.vpnExtension}/64"];
ips = [ "fd42:9c3b:f96d:201::${cfg.vpnExtension}/64" ];
listenPort = 51234;
privateKeyFile = "/var/lib/wireguard/privkey";
@ -130,7 +130,7 @@ in {
peers = [
{
publicKey = vpnPubKey;
allowedIPs = ["fd42:9c3b:f96d::/48"];
allowedIPs = [ "fd42:9c3b:f96d::/48" ];
endpoint = "vpn.dadada.li:51234";
persistentKeepalive = 25;
}
@ -140,8 +140,8 @@ in {
# https://lists.zx2c4.com/pipermail/wireguard/2017-November/002028.html
systemd.timers.wg-reresolve-dns = mkIf (cfg.vpnExtension != null) {
wantedBy = ["timers.target"];
partOf = ["wg-reresolve-dns.service"];
wantedBy = [ "timers.target" ];
partOf = [ "wg-reresolve-dns.service" ];
timerConfig.OnCalendar = "hourly";
};
systemd.services.wg-reresolve-dns = mkIf (cfg.vpnExtension != null) {

View file

@ -1,14 +1,12 @@
{
self,
home-manager,
nixpkgs,
...
}: {
config,
pkgs,
lib,
...
}:
{ self
, home-manager
, nixpkgs
, ...
}: { config
, pkgs
, lib
, ...
}:
# Global settings for nix daemon
{
nix.nixPath = [

View file

@ -1,8 +1,7 @@
{
config,
pkgs,
lib,
...
{ config
, pkgs
, lib
, ...
}:
with lib; {
networking.domain = mkDefault "dadada.li";
@ -29,7 +28,7 @@ with lib; {
vteIntegration = true;
syntaxHighlighting = {
enable = true;
highlighters = ["main" "brackets" "pattern" "root" "line"];
highlighters = [ "main" "brackets" "pattern" "root" "line" ];
};
};

View file

@ -1,8 +1,7 @@
{
config,
pkgs,
lib,
...
{ config
, pkgs
, lib
, ...
}:
with lib; {
networking.domain = mkDefault "dadada.li";

View file

@ -1,12 +1,12 @@
{
config,
pkgs,
lib,
...
{ config
, pkgs
, lib
, ...
}:
with lib; let
cfg = config.dadada.share;
in {
in
{
options.dadada.share = {
enable = mkEnableOption "Enable file share";
};

View file

@ -1,12 +1,12 @@
{
config,
pkgs,
lib,
...
{ config
, pkgs
, lib
, ...
}:
with lib; let
cfg = config.dadada.steam;
in {
in
{
options = {
dadada.steam = {
enable = mkEnableOption "Enable Steam config";
@ -18,7 +18,7 @@ in {
hardware.opengl = {
enable = true;
driSupport32Bit = true;
extraPackages32 = with pkgs.pkgsi686Linux; [libva];
extraPackages32 = with pkgs.pkgsi686Linux; [ libva ];
};
hardware.pulseaudio.support32Bit = true;

View file

@ -1,12 +1,12 @@
{
config,
pkgs,
lib,
...
{ config
, pkgs
, lib
, ...
}:
with lib; let
cfg = config.dadada.autoUpgrade;
in {
in
{
options.dadada.autoUpgrade = {
enable = mkEnableOption "Enable automatic upgrades";
};

View file

@ -1,12 +1,11 @@
{
config,
pkgs,
lib,
...
{ config
, pkgs
, lib
, ...
}:
with lib; let
cfg = config.dadada.vpnServer;
wgPeer = {name, ...}: {
wgPeer = { name, ... }: {
options = {
name = mkOption {
internal = true;
@ -24,13 +23,14 @@ with lib; let
};
};
};
in {
in
{
options.dadada.vpnServer = {
enable = mkEnableOption "Enable wireguard gateway";
peers = mkOption {
description = "Set of extensions and public keys of peers";
type = with types; attrsOf (submodule wgPeer);
default = {};
default = { };
};
};
config = mkIf cfg.enable {
@ -39,15 +39,15 @@ in {
interfaces."wg0" = {
allowedIPsAsRoutes = true;
privateKeyFile = "/var/lib/wireguard/wg0-key";
ips = ["fd42:9c3b:f96d:0201::0/64"];
ips = [ "fd42:9c3b:f96d:0201::0/64" ];
listenPort = 51234;
peers =
map
(peer: {
allowedIPs = ["fd42:9c3b:f96d:0201::${peer.id}/128"];
publicKey = peer.key;
})
(attrValues cfg.peers);
(peer: {
allowedIPs = [ "fd42:9c3b:f96d:0201::${peer.id}/128" ];
publicKey = peer.key;
})
(attrValues cfg.peers);
postSetup = ''
wg set wg0 fwmark 51234
ip -6 route add table 2468 fd42:9c3b:f96d::/48 dev ens3

View file

@ -1,12 +1,12 @@
{
config,
pkgs,
lib,
...
{ config
, pkgs
, lib
, ...
}:
with lib; let
cfg = config.dadada.weechat;
in {
in
{
options.dadada.weechat = {
enable = mkEnableOption "Enable weechat relay";
};

View file

@ -1,8 +1,7 @@
{
config,
pkgs,
lib,
...
{ config
, pkgs
, lib
, ...
}: {
programs.zsh = {
enable = true;
@ -12,7 +11,7 @@
vteIntegration = true;
syntaxHighlighting = {
enable = true;
highlighters = ["main" "brackets" "pattern" "root" "line"];
highlighters = [ "main" "brackets" "pattern" "root" "line" ];
};
};
}