Skip to content

Commit

Permalink
rolling update in 20240205
Browse files Browse the repository at this point in the history
Signed-off-by: iosmanthus <[email protected]>
  • Loading branch information
iosmanthus committed Feb 5, 2024
1 parent ad2df6f commit 998be00
Show file tree
Hide file tree
Showing 17 changed files with 200 additions and 98 deletions.
69 changes: 24 additions & 45 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
};

jetbrains.url = "github:NixOS/nixpkgs/master";

nix-ld = {
url = "github:Mic92/nix-ld";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ self
Expand All @@ -34,7 +29,6 @@
, home-manager
, sops-nix
, berberman
, nix-ld
, ...
}@inputs:
let
Expand All @@ -50,7 +44,6 @@

sops-nix.nixosModules.sops
home-manager.nixosModules.home-manager
nix-ld.nixosModules.nix-ld

({ config, ... }: {
home-manager = {
Expand Down
8 changes: 8 additions & 0 deletions infra/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,13 @@ websites = [
{
name = "www"
zone = "72d18453e5277555259d8fee6c65b016"
},
{
name = "vault"
zone = "72d18453e5277555259d8fee6c65b016"
},
{
name = "atuin"
zone = "72d18453e5277555259d8fee6c65b016"
}
]
74 changes: 74 additions & 0 deletions modules/atuin/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{ config, pkgs, lib, ... }:
let
inherit (lib) mkOption types mdDoc mkIf;
cfg = config.iosmanthus.atuin;
in
{
options = {
iosmanthus.atuin = {
enable = lib.mkEnableOption (mdDoc "Atuin server for shell history sync");

environmentFile = mkOption {
type = types.path;
description = "Path to a file containing environment variables to be loaded by the atuin service";
};
};
};

config = mkIf cfg.enable {
systemd.services.atuin = {
description = "atuin server";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];

serviceConfig = {
ExecStart = "${pkgs.atuin}/bin/atuin server start";
RuntimeDirectory = "atuin";
RuntimeDirectoryMode = "0700";
DynamicUser = true;

# Hardening
CapabilityBoundingSet = "";
LockPersonality = true;
NoNewPrivileges = true;
MemoryDenyWriteExecute = true;
PrivateDevices = true;
PrivateMounts = true;
PrivateTmp = true;
PrivateUsers = true;
ProcSubset = "pid";
ProtectClock = true;
ProtectControlGroups = true;
ProtectHome = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectProc = "invisible";
ProtectSystem = "full";
RemoveIPC = true;
RestrictAddressFamilies = [
"AF_INET"
"AF_INET6"
# Required for connecting to database sockets,
"AF_UNIX"
];
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
SystemCallArchitectures = "native";
SystemCallFilter = [
"@system-service"
"~@privileged"
];
UMask = "0077";

EnvironmentFile = cfg.environmentFile;
};

environment = {
ATUIN_CONFIG_DIR = "/run/atuin"; # required to start, but not used as configuration is via environment variables
};
};
};
}
2 changes: 2 additions & 0 deletions modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
./gtk-theme
./wallpaper
./sing-box
./caddy

./monitors.nix
];
Expand All @@ -26,6 +27,7 @@
./sing-box
./caddy
./subgen
./atuin
];
};
}
24 changes: 24 additions & 0 deletions nixos/aws-lightsail-0/atuin/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{ config
, ...
}:
{
sops.templates."atuin.env".content = ''
ATUIN_HOST="127.0.0.1"
ATUIN_MAX_HISTORY_LENGTH=131072
ATUIN_OPEN_REGISTRATION=false
ATUIN_PAGE_SIZE=2048
ATUIN_PORT=8888
RUST_LOG="info,atuin_server=debug"
ATUIN_DB_URI="${config.sops.placeholder."atuin/db-uri"}"
'';

systemd.services.atuin.restartTriggers = [
config.sops.templates."atuin.env".content
];

iosmanthus.atuin = {
enable = true;
environmentFile = config.sops.templates."atuin.env".path;
};
}
42 changes: 22 additions & 20 deletions nixos/aws-lightsail-0/caddy/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
sops.templates."Caddyfile" = {
owner = config.iosmanthus.caddy.user;
content = ''
${config.sops.placeholder."caddy/virtual-host-a"} {
www.iosmanthus.com {
tls {
dns cloudflare ${config.sops.placeholder."cloudflare/api-token"}
}
Expand All @@ -24,43 +24,45 @@
}
reverse_proxy 127.0.0.1:8080
}
${config.sops.placeholder."caddy/virtual-host-b"} {
vault.iosmanthus.com {
tls {
dns cloudflare ${config.sops.placeholder."cloudflare/api-token"}
}
log {
level INFO
}
reverse_proxy 127.0.0.1:8080
header / {
-Last-Modified
-Server
-X-Powered-By
Strict-Transport-Security "max-age=31536000;"
X-Content-Type-Options "nosniff"
X-Frame-Options "DENY"
X-Robots-Tag "noindex, nofollow"
X-XSS-Protection "0"
}
reverse_proxy ${config.services.vaultwarden.config.ROCKET_ADDRESS}:${toString config.services.vaultwarden.config.ROCKET_PORT} {
header_up X-Real-IP {http.request.header.Cf-Connecting-Ip}
}
}
${config.sops.placeholder."caddy/virtual-host-c"} {
atuin.iosmanthus.com {
tls {
dns cloudflare ${config.sops.placeholder."cloudflare/api-token"}
}
log {
level INFO
}
# Uncomment to improve security (WARNING: only use if you understand the implications!)
# If you want to use FIDO2 WebAuthn, set X-Frame-Options to "SAMEORIGIN" or the Browser will block those requests
header / {
# Enable HTTP Strict Transport Security (HSTS)
-Last-Modified
-Server
-X-Powered-By
Strict-Transport-Security "max-age=31536000;"
# Disable cross-site filter (XSS)
X-XSS-Protection "0"
# Disallow the site to be rendered within a frame (clickjacking protection)
X-Content-Type-Options "nosniff"
X-Frame-Options "DENY"
# Prevent search engines from indexing (optional)
X-Robots-Tag "noindex, nofollow"
# Disallow sniffing of X-Content-Type-Options
X-Content-Type-Options "nosniff"
# Server name removing
-Server
# Remove X-Powered-By though this shouldn't be an issue, better opsec to remove
-X-Powered-By
# Remove Last-Modified because etag is the same and is as effective
-Last-Modified
X-XSS-Protection "0"
}
reverse_proxy ${config.services.vaultwarden.config.ROCKET_ADDRESS}:${toString config.services.vaultwarden.config.ROCKET_PORT} {
reverse_proxy 127.0.0.1:8888 {
header_up X-Real-IP {http.request.header.Cf-Connecting-Ip}
}
}
Expand Down
1 change: 1 addition & 0 deletions nixos/aws-lightsail-0/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
./promtail
./prometheus
./vaultwarden
./atuin
];

boot.loader.grub.device = lib.mkForce "/dev/nvme0n1";
Expand Down
Loading

0 comments on commit 998be00

Please sign in to comment.