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");
system.stateVersion = "24.05";
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,4 @@
{ config, lib, pkgs, ... }:
{
{ config, lib, pkgs, ... }: {
services.postgresqlBackup = {
location = "/var/backup/postgresql";
backupAll = true;
@ -16,18 +15,24 @@
log_statement = "all";
log_destination = lib.mkForce "syslog,jsonlog";
};
ensureUsers = [
{
ensureUsers = [{
name = "root";
ensureClauses.superuser = true;
}
];
}];
};
environment.systemPackages = [ pkgs.pgloader ];
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";
allowReboot = true;
flake = self.outPath;
flags = [
"--update-input"
"nixpkgs"
"-L"
];
flags = [ "--update-input" "nixpkgs" "-L" ];
};
};
}

View File

@ -14,6 +14,9 @@
};
environment.persistence.ephemeral.users = {
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 =
[
(modulesPath + "/installer/scan/not-detected.nix")
];
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot = {
tmp = {

View File

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

View File

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

View File

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

View File

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

View File

@ -16,6 +16,7 @@
# 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"
'';
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::1001#cloudflare-dns.com"
];
in
{
in {
systemd.network = {
enable = true;
networks = {

View File

@ -5,7 +5,7 @@
settings = {
experimental-features = [ "nix-command" "flakes" ];
auto-optimise-store = true;
trusted-users = ["@wheel"];
trusted-users = [ "@wheel" ];
};
gc = {
automatic = true;

View File

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

View File

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

View File

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

View File

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

View File

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