style: format with nixfmt

This commit is contained in:
Price Hiller 2024-03-14 03:51:03 -05:00
parent 3b890fc629
commit a6cdb184ab
Signed by: Price
GPG Key ID: C3FADDE7A8534BEB
34 changed files with 186 additions and 255 deletions

View File

@ -1,5 +1,4 @@
{ config, lib, nixpkgs, ... }: { config, lib, nixpkgs, ... }: {
{
imports = (lib.recurseFilesInDirs [ ./os ./modules ] ".nix"); imports = (lib.recurseFilesInDirs [ ./os ./modules ] ".nix");
system.stateVersion = "24.05"; system.stateVersion = "24.05";
} }

View File

@ -1,9 +1,5 @@
{ pkgs, ... }: { pkgs, ... }: {
{ environment.systemPackages = with pkgs; [ docker docker-compose ];
environment.systemPackages = with pkgs; [
docker
docker-compose
];
virtualisation = { virtualisation = {
oci-containers.backend = "docker"; oci-containers.backend = "docker";

View File

@ -20,9 +20,9 @@ let
"2620:fe::9#dns.quad9.net" "2620:fe::9#dns.quad9.net"
"2001:4860:4860::8888#dns.google" "2001:4860:4860::8888#dns.google"
]; ];
resolved_fallback_nameservers = [ "1.1.1.1#one.one.one.one" "1.0.0.1#one.one.one.one" ]; resolved_fallback_nameservers =
in [ "1.1.1.1#one.one.one.one" "1.0.0.1#one.one.one.one" ];
{ in {
systemd.network = { systemd.network = {
enable = true; enable = true;
# HACK: Disable wait-online, check in on https://github.com/NixOS/nixpkgs/pull/258680 & # HACK: Disable wait-online, check in on https://github.com/NixOS/nixpkgs/pull/258680 &
@ -89,11 +89,7 @@ in
nftables.enable = true; nftables.enable = true;
firewall = { firewall = {
enable = true; enable = true;
allowedTCPPorts = [ allowedTCPPorts = [ 80 443 2200 ];
80
443
2200
];
}; };
hostName = "${hostname}"; hostName = "${hostname}";
}; };

View File

@ -1,5 +1,4 @@
{ ... }: { ... }: {
{
services.fail2ban = { services.fail2ban = {
enable = true; enable = true;
maxretry = 10; maxretry = 10;

View File

@ -59,9 +59,7 @@ in {
url = config.services.gitea.settings.server.ROOT_URL; url = config.services.gitea.settings.server.ROOT_URL;
tokenFile = config.age.secrets.gitea-runner-token.path; tokenFile = config.age.secrets.gitea-runner-token.path;
name = "Default"; name = "Default";
settings = { settings = { runner.capacity = 8; };
runner.capacity = 8;
};
labels = [ labels = [
"default:docker://nixos/nix:latest" "default:docker://nixos/nix:latest"
"alpine:docker://alpine:latest" "alpine:docker://alpine:latest"

View File

@ -1,5 +1,4 @@
{ ... }: { ... }: {
{
services.journald = { services.journald = {
extraConfig = '' extraConfig = ''
SystemMaxUse=100G SystemMaxUse=100G

View File

@ -1,5 +1,4 @@
{ config, pkgs, blog, fqdn, ... }: { config, pkgs, blog, fqdn, ... }: {
{
services.nginx = { services.nginx = {
enable = true; enable = true;
recommendedProxySettings = true; recommendedProxySettings = true;

View File

@ -1,5 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }: {
{
services.postgresqlBackup = { services.postgresqlBackup = {
location = "/var/backup/postgresql"; location = "/var/backup/postgresql";
backupAll = true; backupAll = true;
@ -16,18 +15,24 @@
log_statement = "all"; log_statement = "all";
log_destination = lib.mkForce "syslog,jsonlog"; log_destination = lib.mkForce "syslog,jsonlog";
}; };
ensureUsers = [ ensureUsers = [{
{
name = "root"; name = "root";
ensureClauses.superuser = true; ensureClauses.superuser = true;
} }];
];
}; };
environment.systemPackages = [ pkgs.pgloader ]; environment.systemPackages = [ pkgs.pgloader ];
environment.persistence.save.directories = [ environment.persistence.save.directories = [
{ directory = config.services.postgresql.dataDir; user = "postgres"; group = "postgres"; } {
{ directory = config.services.postgresqlBackup.location; user = "postgres"; group = "postgres"; } directory = config.services.postgresql.dataDir;
user = "postgres";
group = "postgres";
}
{
directory = config.services.postgresqlBackup.location;
user = "postgres";
group = "postgres";
}
]; ];
} }

View File

@ -7,11 +7,7 @@
dates = "05:00"; dates = "05:00";
allowReboot = true; allowReboot = true;
flake = self.outPath; flake = self.outPath;
flags = [ flags = [ "--update-input" "nixpkgs" "-L" ];
"--update-input"
"nixpkgs"
"-L"
];
}; };
}; };
} }

View File

@ -14,6 +14,9 @@
}; };
environment.persistence.ephemeral.users = { environment.persistence.ephemeral.users = {
price = { files = [ ".bash_history" ]; }; price = { files = [ ".bash_history" ]; };
root = { home = "/root"; files = [ ".bash_history" ]; }; root = {
home = "/root";
files = [ ".bash_history" ];
};
}; };
} }

View File

@ -1,10 +1,6 @@
{ modulesPath, pkgs, ... }: { modulesPath, pkgs, ... }: {
{
imports = imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
[
(modulesPath + "/installer/scan/not-detected.nix")
];
boot = { boot = {
tmp = { tmp = {

View File

@ -1,14 +1,9 @@
{ lib, root-disk, persist-dir, ... }: { lib, root-disk, persist-dir, ... }: {
{
services = { services = {
fstrim.enable = true; fstrim.enable = true;
btrfs.autoScrub = { btrfs.autoScrub = {
enable = true; enable = true;
fileSystems = [ fileSystems = [ "/" "/nix" "/persist" ];
"/"
"/nix"
"/persist"
];
}; };
snapper = { snapper = {
# NOTE: According to `snapper-config(5)` the default timeline count for all timelines is 10 # NOTE: According to `snapper-config(5)` the default timeline count for all timelines is 10
@ -23,19 +18,15 @@
fileSystems."${persist-dir}".neededForBoot = true; fileSystems."${persist-dir}".neededForBoot = true;
disko.devices = disko.devices = {
{
disk.${lib.removePrefix "/dev/" root-disk} = { disk.${lib.removePrefix "/dev/" root-disk} = {
type = "disk"; type = "disk";
device = "${root-disk}"; device = "${root-disk}";
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {
esp = esp = let label = "NixOS-Boot";
let in {
label = "NixOS-Boot";
in
{
priority = 1; priority = 1;
size = "512M"; size = "512M";
type = "EF00"; type = "EF00";
@ -44,17 +35,11 @@
type = "filesystem"; type = "filesystem";
format = "vfat"; format = "vfat";
mountpoint = "/boot"; mountpoint = "/boot";
mountOptions = [ mountOptions = [ "umask=0077" "defaults" ];
"umask=0077"
"defaults"
];
}; };
}; };
root = root = let label = "NixOS-Primary";
let in {
label = "NixOS-Primary";
in
{
size = "100%"; size = "100%";
content = { content = {
type = "btrfs"; type = "btrfs";
@ -66,9 +51,7 @@
btrfs subvolume snapshot -r "$MOUNT/root" "$MOUNT/root-base" btrfs subvolume snapshot -r "$MOUNT/root" "$MOUNT/root-base"
''; '';
subvolumes = { subvolumes = {
"/root" = { "/root" = { mountpoint = "/"; };
mountpoint = "/";
};
"/var-log" = { "/var-log" = {
mountpoint = "/var/log"; mountpoint = "/var/log";
mountOptions = [ "compress=zstd" "noatime" ]; mountOptions = [ "compress=zstd" "noatime" ];

View File

@ -1,6 +1,6 @@
{ lib, config, ... }: { lib, config, ... }: {
{ hardware.cpu.intel.updateMicrocode =
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; lib.mkDefault config.hardware.enableRedistributableFirmware;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
services.fstrim.enable = true; services.fstrim.enable = true;
} }

View File

@ -1,5 +1,4 @@
{ config, lib, nixpkgs, ... }: { config, lib, nixpkgs, ... }: {
{
imports = (lib.recurseFilesInDirs [ ./os ./modules ] ".nix"); imports = (lib.recurseFilesInDirs [ ./os ./modules ] ".nix");
system.stateVersion = "24.05"; system.stateVersion = "24.05";
} }

View File

@ -3,9 +3,7 @@
{ {
hardware.bluetooth.enable = true; hardware.bluetooth.enable = true;
services.blueman.enable = true; services.blueman.enable = true;
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [ bluez ];
bluez
];
systemd.user.services.mpris-proxy = { systemd.user.services.mpris-proxy = {
description = "Mpris proxy"; description = "Mpris proxy";

View File

@ -16,6 +16,7 @@
# Remove NVIDIA VGA/3D controller devices # Remove NVIDIA VGA/3D controller devices
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", ATTR{power/control}="auto", ATTR{remove}="1" ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", ATTR{power/control}="auto", ATTR{remove}="1"
''; '';
boot.blacklistedKernelModules = [ "nouveau" "nvidia" "nvidia_drm" "nvidia_modeset" ]; boot.blacklistedKernelModules =
[ "nouveau" "nvidia" "nvidia_drm" "nvidia_modeset" ];
} }

View File

@ -25,8 +25,7 @@ let
"2606:4700:4700::1111#cloudflare-dns.com" "2606:4700:4700::1111#cloudflare-dns.com"
"2606:4700:4700::1001#cloudflare-dns.com" "2606:4700:4700::1001#cloudflare-dns.com"
]; ];
in in {
{
systemd.network = { systemd.network = {
enable = true; enable = true;
networks = { networks = {

View File

@ -1,19 +1,14 @@
{ config, ... }: { config, ... }: {
{
services.openssh = { services.openssh = {
enable = true; enable = true;
startWhenNeeded = true; startWhenNeeded = true;
# We set the hostkeys manually so they persist through reboots # We set the hostkeys manually so they persist through reboots
hostKeys = [ hostKeys = [{
{ path = (config.environment.persistence.ephemeral.persistentStoragePath
path = (config.environment.persistence.ephemeral.persistentStoragePath + "/etc/ssh/ssh_host_ed25519_key"); + "/etc/ssh/ssh_host_ed25519_key");
type = "ed25519"; type = "ed25519";
} }];
]; sftpFlags = [ "-f AUTHPRIV" "-l INFO" ];
sftpFlags = [
"-f AUTHPRIV"
"-l INFO"
];
extraConfig = '' extraConfig = ''
AllowUsers price AllowUsers price
''; '';
@ -41,9 +36,7 @@
"umac-128-etm@openssh.com" "umac-128-etm@openssh.com"
]; ];
}; };
ports = [ ports = [ 2200 ];
2200
];
banner = '' banner = ''
Orion Technologies - Security Notice Orion Technologies - Security Notice

View File

@ -14,6 +14,9 @@
}; };
environment.persistence.ephemeral.users = { environment.persistence.ephemeral.users = {
price = { files = [ ".bash_history" ]; }; price = { files = [ ".bash_history" ]; };
root = { home = "/root"; files = [ ".bash_history" ]; }; root = {
home = "/root";
files = [ ".bash_history" ];
};
}; };
} }

View File

@ -1,9 +1,7 @@
{ modulesPath, pkgs, ... }: { { modulesPath, pkgs, ... }: {
# imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; # imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
imports = imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
[ (modulesPath + "/profiles/qemu-guest.nix")
];
boot = { boot = {
loader = { loader = {
@ -14,7 +12,8 @@
kernelParams = [ "audit=1" ]; kernelParams = [ "audit=1" ];
extraModulePackages = [ ]; extraModulePackages = [ ];
initrd = { initrd = {
availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ]; availableKernelModules =
[ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ];
# availableKernelModules = # availableKernelModules =
# [ "xhci_pci" "thunderbolt" "vmd" "nvme" "usbhid" "rtsx_pci_sdmmc" ]; # [ "xhci_pci" "thunderbolt" "vmd" "nvme" "usbhid" "rtsx_pci_sdmmc" ];
# kernelModules = [ ]; # kernelModules = [ ];

View File

@ -1,31 +1,22 @@
# Some of these functions were taken from https://github.com/NixOS/nixpkgs/blob/master/lib/ # Some of these functions were taken from https://github.com/NixOS/nixpkgs/blob/master/lib/
{ lib ? (import <nixpkgs> { }).lib }: { lib ? (import <nixpkgs> { }).lib }: rec {
rec { hasSuffix = suffix: string:
hasSuffix =
suffix:
string:
let let
lenSuffix = builtins.stringLength suffix; lenSuffix = builtins.stringLength suffix;
lenString = builtins.stringLength string; lenString = builtins.stringLength string;
in in (lenString >= lenSuffix
( && (builtins.substring (lenString - lenSuffix) lenString string)
lenString >= lenSuffix && (builtins.substring (lenString - lenSuffix) lenString string) == suffix == suffix);
);
recurseDir = dir: recurseDir = dir:
let let dirContents = builtins.readDir dir;
dirContents = builtins.readDir dir; in (builtins.concatMap (dirItem:
in
(builtins.concatMap
(dirItem:
let let
itemType = builtins.getAttr dirItem dirContents; itemType = builtins.getAttr dirItem dirContents;
itemPath = dir + "/${dirItem}"; itemPath = dir + "/${dirItem}";
in in if itemType == "directory" then
if itemType == "directory" then
(recurseDir itemPath) (recurseDir itemPath)
else else
[ itemPath ]) [ itemPath ]) (builtins.attrNames dirContents));
(builtins.attrNames dirContents));
recurseFilesInDir = dir: suffix: recurseFilesInDir = dir: suffix:
(builtins.filter (file: hasSuffix "${suffix}" file) (recurseDir dir)); (builtins.filter (file: hasSuffix "${suffix}" file) (recurseDir dir));
recurseFilesInDirs = dirs: suffix: recurseFilesInDirs = dirs: suffix:
@ -35,14 +26,13 @@ rec {
let let
f = attrPath: f = attrPath:
lib.zipAttrsWith (n: values: lib.zipAttrsWith (n: values:
if lib.tail values == [ ] if lib.tail values == [ ] then
then lib.head values lib.head values
else if lib.all builtins.isList values else if lib.all builtins.isList values then
then lib.unique (lib.concatLists values) lib.unique (lib.concatLists values)
else if lib.all builtins.isAttrs values else if lib.all builtins.isAttrs values then
then f (attrPath ++ [ n ]) values f (attrPath ++ [ n ]) values
else lib.last values else
); lib.last values);
in in f [ ] attrList;
f [ ] attrList;
} }

View File

@ -5,52 +5,32 @@ let
"age1ur2lr3z6d2eftgxcalc6s5x9840ew9x43upl9k23wg0ugacrn5as4zl6sj" "age1ur2lr3z6d2eftgxcalc6s5x9840ew9x43upl9k23wg0ugacrn5as4zl6sj"
]; ];
hosts = { hosts = {
luna = luna = let secrets = "luna";
let in {
secrets = "luna";
in
{
users-root-pw = "${secrets}/users-root-pw.age"; users-root-pw = "${secrets}/users-root-pw.age";
users-price-pw = "${secrets}/users-price-pw.age"; users-price-pw = "${secrets}/users-price-pw.age";
gitea-db-pass = "${secrets}/gitea-db-pass.age"; gitea-db-pass = "${secrets}/gitea-db-pass.age";
gitea-runner-token = "${secrets}/gitea-runner-token.age"; gitea-runner-token = "${secrets}/gitea-runner-token.age";
}; };
orion = orion = let secrets = "orion";
let in {
secrets = "orion";
in
{
users-root-pw = "${secrets}/users-root-pw.age"; users-root-pw = "${secrets}/users-root-pw.age";
users-price-pw = "${secrets}/users-price-pw.age"; users-price-pw = "${secrets}/users-price-pw.age";
}; };
}; };
in in if agenix then
if agenix then (builtins.listToAttrs (builtins.concatMap (host:
(builtins.listToAttrs let hostSecrets = (builtins.getAttr host hosts);
(builtins.concatMap in (builtins.map (hostSecretName:
(host: let secret = (builtins.getAttr hostSecretName hostSecrets);
let in {
hostSecrets = (builtins.getAttr host hosts);
in
(builtins.map
(hostSecretName:
let
secret = (builtins.getAttr hostSecretName hostSecrets);
in
{
name = builtins.toString secret; name = builtins.toString secret;
value = { value = {
publicKeys = [ (import ./../hosts/${host}/pubkey.nix) ] ++ masterKeys; publicKeys = [ (import ./../hosts/${host}/pubkey.nix) ] ++ masterKeys;
}; };
}) }) (builtins.attrNames hostSecrets))) (builtins.attrNames hosts)))
(builtins.attrNames hostSecrets)))
(builtins.attrNames hosts)))
else else
(builtins.mapAttrs (builtins.mapAttrs (host: secrets:
(host: secrets: (lib.recursiveMerge (builtins.map (secretName: {
(lib.recursiveMerge (builtins.map
(secretName: {
age.secrets.${secretName}.file = ./${secrets.${secretName}}; age.secrets.${secretName}.file = ./${secrets.${secretName}};
}) }) (builtins.attrNames hosts.${host})))) hosts)
(builtins.attrNames hosts.${host}))))
hosts)