Compare commits

...

2 commits

Author SHA1 Message Date
ee46717618
style: format with nixfmt-rfc-style 2024-09-18 16:10:20 +02:00
4750ca705d
chore: switch out deploy-rs key 2024-09-18 16:00:16 +02:00
27 changed files with 284 additions and 205 deletions

View file

@ -1,4 +1,5 @@
{config, ...}: { { config, ... }:
{
security.acme = { security.acme = {
acceptTerms = true; acceptTerms = true;
defaults.email = "hey@winston.sh"; defaults.email = "hey@winston.sh";

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
imports = [ imports = [
./games ./games
./secrets ./secrets

View file

@ -1,5 +1,7 @@
{lib, ...}: { { lib, ... }:
nixpkgs.config.allowUnfreePredicate = pkg: {
nixpkgs.config.allowUnfreePredicate =
pkg:
builtins.elem (lib.getName pkg) [ builtins.elem (lib.getName pkg) [
"valheim-server" "valheim-server"
"steamworks-sdk-redist" "steamworks-sdk-redist"

View file

@ -1,12 +1,16 @@
{ {
nix = { nix = {
gc.automatic = true; gc.automatic = true;
settings = settings = (import ../flake.nix).nixConfig // {
(import ../flake.nix).nixConfig
// {
auto-optimise-store = true; auto-optimise-store = true;
experimental-features = ["nix-command" "flakes"]; experimental-features = [
trusted-users = ["@wheel" "winston"]; "nix-command"
"flakes"
];
trusted-users = [
"@wheel"
"winston"
];
}; };
}; };
} }

View file

@ -1,7 +1,13 @@
{lib, ...}: { { lib, ... }:
age.secrets = with builtins; {
listToAttrs (map (k: { age.secrets =
with builtins;
listToAttrs (
map (k: {
name = lib.removeSuffix ".age" k; name = lib.removeSuffix ".age" k;
value = {file = ./. + "/${k}";}; value = {
}) (attrNames (import ./secrets.nix))); file = ./. + "/${k}";
};
}) (attrNames (import ./secrets.nix))
);
} }

View file

@ -2,8 +2,12 @@ let
users.winston = "age1yubikey1qfkn095xth4ukxjye98ew4ul6xdkyz7sek0hd67yfjs5z6tv7q9jgnfchls"; users.winston = "age1yubikey1qfkn095xth4ukxjye98ew4ul6xdkyz7sek0hd67yfjs5z6tv7q9jgnfchls";
systems.main-node = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFcY5fuyxK8rs3eocLuLnvSPDL6qcvq7oUdYrE+wLj0y"; systems.main-node = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFcY5fuyxK8rs3eocLuLnvSPDL6qcvq7oUdYrE+wLj0y";
default = [users.winston systems.main-node]; default = [
in { users.winston
systems.main-node
];
in
{
"containers/faerber.env.age".publicKeys = default; "containers/faerber.env.age".publicKeys = default;
"containers/ghcr-token.age".publicKeys = default; "containers/ghcr-token.age".publicKeys = default;

View file

@ -1,4 +1,5 @@
{config, ...}: { { config, ... }:
{
services.atticd = { services.atticd = {
enable = true; enable = true;
credentialsFile = config.age.secrets."services/attic/atticd.env".path; credentialsFile = config.age.secrets."services/attic/atticd.env".path;

View file

@ -1,8 +1,5 @@
{ config, pkgs, ... }:
{ {
config,
pkgs,
...
}: {
services.atuin = { services.atuin = {
enable = true; enable = true;
package = pkgs.unstable.atuin; package = pkgs.unstable.atuin;

View file

@ -3,14 +3,17 @@
inputs, inputs,
pkgs, pkgs,
... ...
}: let }:
modules = ["services/misc/forgejo.nix" "services/continuous-integration/gitea-actions-runner.nix"]; let
in { modules = [
"services/misc/forgejo.nix"
"services/continuous-integration/gitea-actions-runner.nix"
];
in
{
# swap out stable for unstable modules # swap out stable for unstable modules
disabledModules = modules; disabledModules = modules;
imports = imports = builtins.map (v: "${inputs.nixpkgs-unstable}/nixos/modules/${v}") modules;
builtins.map (v: "${inputs.nixpkgs-unstable}/nixos/modules/${v}")
modules;
age.secrets = { age.secrets = {
"services/forgejo/minio-secretkey".owner = config.services.forgejo.user; "services/forgejo/minio-secretkey".owner = config.services.forgejo.user;
@ -44,10 +47,13 @@ in {
settings = { settings = {
DEFAULT.APP_NAME = "winston's forgejo"; DEFAULT.APP_NAME = "winston's forgejo";
indexer = with config.services.elasticsearch; let indexer =
with config.services.elasticsearch;
let
indexer = "elasticsearch"; indexer = "elasticsearch";
conn = "http://${listenAddress}:${toString port}"; conn = "http://${listenAddress}:${toString port}";
in { in
{
REPO_INDEXER_ENABLED = true; REPO_INDEXER_ENABLED = true;
REPO_INDEXER_CONN_STR = conn; REPO_INDEXER_CONN_STR = conn;
REPO_INDEXER_TYPE = indexer; REPO_INDEXER_TYPE = indexer;

View file

@ -1,4 +1,5 @@
{config, ...}: { { config, ... }:
{
services.freshrss = rec { services.freshrss = rec {
enable = true; enable = true;

View file

@ -1,10 +1,15 @@
{config, ...}: { { config, ... }:
{
services.geoipupdate = { services.geoipupdate = {
enable = true; enable = true;
settings = { settings = {
AccountID = 1062126; AccountID = 1062126;
LicenseKey = config.age.secrets."services/geoipupdate/license".path; LicenseKey = config.age.secrets."services/geoipupdate/license".path;
EditionIDs = ["GeoLite2-ASN" "GeoLite2-City" "GeoLite2-Country"]; EditionIDs = [
"GeoLite2-ASN"
"GeoLite2-City"
"GeoLite2-Country"
];
}; };
}; };
} }

View file

@ -1,4 +1,5 @@
{config, ...}: { { config, ... }:
{
services.minio = { services.minio = {
enable = true; enable = true;
browser = true; browser = true;

View file

@ -3,7 +3,8 @@
lib, lib,
pkgs, pkgs,
... ...
}: let }:
let
geoipDir = config.services.geoipupdate.settings.DatabaseDirectory; geoipDir = config.services.geoipupdate.settings.DatabaseDirectory;
log_params = [ log_params = [
@ -25,7 +26,8 @@
]; ];
log_format = lib.concatStringsSep " " (map (p: "${p}=\"\$${p}\"") log_params); log_format = lib.concatStringsSep " " (map (p: "${p}=\"\$${p}\"") log_params);
log_file = "/var/log/nginx/access.log"; log_file = "/var/log/nginx/access.log";
in { in
{
services.grafana = { services.grafana = {
enable = true; enable = true;
settings = { settings = {
@ -82,10 +84,12 @@ in {
globalConfig.scrape_interval = "10s"; globalConfig.scrape_interval = "10s";
scrapeConfigs = scrapeConfigs =
(builtins.map (config: { (builtins.map
(config: {
inherit (config) job_name; inherit (config) job_name;
static_configs = [ { targets = [ "localhost:${toString config.port}" ]; } ]; static_configs = [ { targets = [ "localhost:${toString config.port}" ]; } ];
}) [ })
[
{ {
job_name = "fail2ban"; job_name = "fail2ban";
port = 9191; port = 9191;
@ -106,7 +110,8 @@ in {
job_name = "postgres"; job_name = "postgres";
port = config.services.prometheus.exporters.postgres.port; port = config.services.prometheus.exporters.postgres.port;
} }
]) ]
)
++ [ ++ [
{ {
job_name = "minio"; job_name = "minio";
@ -116,7 +121,9 @@ in {
} }
{ {
job_name = "forgejo"; job_name = "forgejo";
static_configs = with config.services.forgejo.settings.server; [{targets = ["${HTTP_ADDR}:${toString HTTP_PORT}"];}]; static_configs = with config.services.forgejo.settings.server; [
{ targets = [ "${HTTP_ADDR}:${toString HTTP_PORT}" ]; }
];
} }
]; ];
@ -165,8 +172,24 @@ in {
}; };
node = { node = {
enable = true; enable = true;
enabledCollectors = ["logind" "processes" "systemd"]; enabledCollectors = [
disabledCollectors = ["bonding" "fibrechannel" "infiniband" "ipvs" "mdadm" "nfs" "nfsd" "nvme" "tapestats" "watchdog" "zfs"]; "logind"
"processes"
"systemd"
];
disabledCollectors = [
"bonding"
"fibrechannel"
"infiniband"
"ipvs"
"mdadm"
"nfs"
"nfsd"
"nvme"
"tapestats"
"watchdog"
"zfs"
];
}; };
postgres = { postgres = {
enable = true; enable = true;

View file

@ -1,8 +1,5 @@
{ config, pkgs, ... }:
{ {
config,
pkgs,
...
}: {
age.secrets = { age.secrets = {
"services/nextcloud/admin-password".owner = "nextcloud"; "services/nextcloud/admin-password".owner = "nextcloud";
"services/nextcloud/s3-secret".owner = "nextcloud"; "services/nextcloud/s3-secret".owner = "nextcloud";
@ -20,8 +17,7 @@
}; };
extraApps = { extraApps = {
inherit inherit (config.services.nextcloud.package.packages.apps)
(config.services.nextcloud.package.packages.apps)
end_to_end_encryption end_to_end_encryption
previewgenerator previewgenerator
twofactor_webauthn twofactor_webauthn

View file

@ -1,13 +1,11 @@
{ { config, pkgs, ... }:
config, let
pkgs,
...
}: let
snakeoilCert = pkgs.runCommand "nginx-snakeoil-cert" { buildInputs = [ pkgs.openssl ]; } '' snakeoilCert = pkgs.runCommand "nginx-snakeoil-cert" { buildInputs = [ pkgs.openssl ]; } ''
mkdir "$out" mkdir "$out"
openssl req -newkey rsa:4096 -x509 -sha256 -days 36500 -subj '/CN=Snakeoil CA' -nodes -out "$out/cert.pem" -keyout "$out/cert.key" openssl req -newkey rsa:4096 -x509 -sha256 -days 36500 -subj '/CN=Snakeoil CA' -nodes -out "$out/cert.pem" -keyout "$out/cert.key"
''; '';
in { in
{
services.nginx = { services.nginx = {
enable = true; enable = true;
package = pkgs.nginxMainline; package = pkgs.nginxMainline;
@ -47,7 +45,10 @@ in {
params.nginx = { }; params.nginx = { };
}; };
networking.firewall.allowedTCPPorts = [80 443]; networking.firewall.allowedTCPPorts = [
80
443
];
# allow nginx to access Acme secrets # allow nginx to access Acme secrets
users.users.nginx.extraGroups = [ "acme" ]; users.users.nginx.extraGroups = [ "acme" ];

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
services.postgresql = { services.postgresql = {
enable = true; enable = true;
package = pkgs.postgresql_14; package = pkgs.postgresql_14;

View file

@ -3,7 +3,8 @@
inputs, inputs,
pkgs, pkgs,
... ...
}: { }:
{
imports = [ "${inputs.nixpkgs-unstable}/nixos/modules/services/misc/renovate.nix" ]; imports = [ "${inputs.nixpkgs-unstable}/nixos/modules/services/misc/renovate.nix" ];
services.renovate = { services.renovate = {

View file

@ -1,8 +1,5 @@
{ config, pkgs, ... }:
{ {
config,
pkgs,
...
}: {
services.wakapi = { services.wakapi = {
enable = true; enable = true;
package = pkgs.unstable.wakapi; package = pkgs.unstable.wakapi;

View file

@ -3,29 +3,35 @@
lib, lib,
pkgs, pkgs,
... ...
}: let }:
let
nu_scripts = "${pkgs.nu_scripts}/share/nu_scripts"; nu_scripts = "${pkgs.nu_scripts}/share/nu_scripts";
mkCompletions = completions: mkCompletions =
completions:
lib.concatStringsSep "\n" ( lib.concatStringsSep "\n" (
builtins.map ( builtins.map (
el: "source ${nu_scripts}/custom-completions/${el.name or el}/${el.filename or el}-completions.nu" el: "source ${nu_scripts}/custom-completions/${el.name or el}/${el.filename or el}-completions.nu"
) ) completions
completions
); );
in { in
{
i18n.defaultLocale = "en_US.UTF-8"; i18n.defaultLocale = "en_US.UTF-8";
users = { users = {
mutableUsers = false; mutableUsers = false;
users.root = { users.root = {
hashedPasswordFile = config.age.secrets."system/password-root".path; hashedPasswordFile = config.age.secrets."system/password-root".path;
openssh.authorizedKeys.keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ/mwLoiuaQ6KH+1IOvYO541gq37S43pYtMetilMG3v5"] ++ config.users.users.winston.openssh.authorizedKeys.keys; openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICgFwSZPS1B3wndghjmgmamdM5LZ7hqv4fZsbcmYBQWT"
] ++ config.users.users.winston.openssh.authorizedKeys.keys;
}; };
users.winston = { users.winston = {
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
hashedPasswordFile = config.age.secrets."system/password-winston".path; hashedPasswordFile = config.age.secrets."system/password-winston".path;
isNormalUser = true; isNormalUser = true;
openssh.authorizedKeys.keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILm0O46zW/XfVOSwz0okRWYeOAg+wCVkCtCAoVTpZsOh"]; openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILm0O46zW/XfVOSwz0okRWYeOAg+wCVkCtCAoVTpZsOh"
];
}; };
}; };
@ -102,7 +108,12 @@ in {
} }
source ${nu_scripts}/aliases/git/git-aliases.nu source ${nu_scripts}/aliases/git/git-aliases.nu
${mkCompletions ["git" "man" "rg" "tar"]} ${mkCompletions [
"git"
"man"
"rg"
"tar"
]}
''; '';
}; };
starship.enable = true; starship.enable = true;

View file

@ -1,11 +1,13 @@
{ {
outputs = { outputs =
{
flake-parts, flake-parts,
nixpkgs, nixpkgs,
nixpkgs-unstable, nixpkgs-unstable,
self, self,
... ...
} @ inputs: let }@inputs:
let
overlays = [ overlays = [
(final: _: { (final: _: {
unstable = nixpkgs-unstable.legacyPackages.${final.system}; unstable = nixpkgs-unstable.legacyPackages.${final.system};
@ -33,7 +35,9 @@
inputs.satisfactory-server.nixosModules.default inputs.satisfactory-server.nixosModules.default
inputs.valheim-server.nixosModules.default inputs.valheim-server.nixosModules.default
]; ];
specialArgs = {inherit inputs;}; specialArgs = {
inherit inputs;
};
}; };
checks = builtins.mapAttrs (_: deployLib: deployLib.deployChecks self.deploy) inputs.deploy-rs.lib; checks = builtins.mapAttrs (_: deployLib: deployLib.deployChecks self.deploy) inputs.deploy-rs.lib;
@ -47,17 +51,17 @@
}; };
}; };
perSystem = { perSystem =
{
config, config,
inputs', inputs',
pkgs, pkgs,
self', self',
system, system,
... ...
}: { }:
_module.args.pkgs = import nixpkgs { {
inherit overlays system; _module.args.pkgs = import nixpkgs { inherit overlays system; };
};
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
inherit (config.pre-commit.devShell) shellHook; inherit (config.pre-commit.devShell) shellHook;
@ -71,24 +75,28 @@
]; ];
}; };
formatter = pkgs.alejandra; formatter = pkgs.nixfmt-rfc-style;
pre-commit = { pre-commit = {
check.enable = true; check.enable = true;
settings.excludes = [ "_sources/" ]; settings.excludes = [ "_sources/" ];
settings.hooks = { settings.hooks = {
alejandra.enable = true;
commitizen.enable = true; commitizen.enable = true;
deadnix.enable = true;
editorconfig-checker.enable = true; editorconfig-checker.enable = true;
nil.enable = true; nil.enable = true;
nixfmt-rfc-style.enable = true;
shellcheck.enable = true; shellcheck.enable = true;
}; };
}; };
}; };
imports = [ inputs.pre-commit-hooks.flakeModule ]; imports = [ inputs.pre-commit-hooks.flakeModule ];
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"]; systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
}; };
inputs = { inputs = {

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
imports = [ ./hardware-configuration.nix ]; imports = [ ./hardware-configuration.nix ];
boot = { boot = {

View file

@ -3,12 +3,18 @@
lib, lib,
modulesPath, modulesPath,
... ...
}: { }:
imports = [ {
(modulesPath + "/profiles/qemu-guest.nix") imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
];
boot.initrd.availableKernelModules = ["ata_piix" "uhci_hcd" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod"]; boot.initrd.availableKernelModules = [
"ata_piix"
"uhci_hcd"
"virtio_pci"
"virtio_scsi"
"sd_mod"
"sr_mod"
];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ]; boot.kernelModules = [ ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];

View file

@ -1,5 +1 @@
{ { imports = [ ./wakapi.nix ]; }
imports = [
./wakapi.nix
];
}

View file

@ -3,7 +3,8 @@
lib, lib,
pkgs, pkgs,
... ...
}: let }:
let
cfg = config.services.wakapi; cfg = config.services.wakapi;
settingsFormat = pkgs.formats.yaml { }; settingsFormat = pkgs.formats.yaml { };
inherit (lib) types; inherit (lib) types;
@ -36,7 +37,11 @@
ProtectKernelTunables = true; ProtectKernelTunables = true;
ProtectProc = "invisible"; ProtectProc = "invisible";
ProtectSystem = "strict"; ProtectSystem = "strict";
RestrictAddressFamilies = ["AF_INET" "AF_INET6" "AF_UNIX"]; RestrictAddressFamilies = [
"AF_INET"
"AF_INET6"
"AF_UNIX"
];
RestrictNamespaces = true; RestrictNamespaces = true;
RestrictRealtime = true; RestrictRealtime = true;
RestrictSUIDSGID = true; RestrictSUIDSGID = true;
@ -97,7 +102,8 @@
public_url = lib.mkDefault cfg.domain; public_url = lib.mkDefault cfg.domain;
}; };
}; };
in { in
{
options.services.wakapi = { options.services.wakapi = {
enable = lib.mkEnableOption "Wakapi"; enable = lib.mkEnableOption "Wakapi";
package = lib.mkPackageOption pkgs "wakapi" { }; package = lib.mkPackageOption pkgs "wakapi" { };
@ -185,9 +191,11 @@ in {
}; };
}; };
config = lib.mkIf cfg.enable (lib.mkMerge [ config = lib.mkIf cfg.enable (
lib.mkMerge [
databaseConfig databaseConfig
nginxConfig nginxConfig
serviceConfig serviceConfig
]); ]
);
} }

View file

@ -2,7 +2,8 @@
buildGoModule, buildGoModule,
fetchFromGitLab, fetchFromGitLab,
lib, lib,
}: let }:
let
version = "0.10.1"; version = "0.10.1";
in in
buildGoModule { buildGoModule {