Compare commits
30 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 53f33fa74b | |||
| 698292e00a | |||
| 83c1f23d61 | |||
| 63a32cee92 | |||
| 6287704cf3 | |||
| c3631f1ef8 | |||
| 0ec2a2cc7d | |||
| 8f3d0e7a7d | |||
| fdb1b8aeb5 | |||
| 40e311e5e4 | |||
| f5adb9d6d7 | |||
| afc7385c95 | |||
| 907d8bc9d2 | |||
| 9838e913b5 | |||
| 8f165dbc05 | |||
| 982e7edd2d | |||
| 830376454c | |||
| 830b945d91 | |||
| fd1da06173 | |||
| e79b2eeb05 | |||
| 45b1a1e7ec | |||
| ba224d45a4 | |||
| 632f4d9b38 | |||
| 66b68ce658 | |||
| 37558060f4 | |||
| 58c5ddd075 | |||
| 4b17075968 | |||
| 95e23247b0 | |||
| b500c0a4cc | |||
| 180a071620 |
148 changed files with 2234 additions and 4430 deletions
14
.gitignore
vendored
14
.gitignore
vendored
|
|
@ -1,13 +1,3 @@
|
||||||
# Nix build outputs
|
result/
|
||||||
result
|
|
||||||
result-*
|
|
||||||
.direnv/
|
.direnv/
|
||||||
oci-trantor/
|
.pre-commit-config.yaml
|
||||||
tailscale-tailnet/
|
|
||||||
cloudflare-baduhaidev
|
|
||||||
|
|
||||||
# Personal notes and temporary files
|
|
||||||
todo.md
|
|
||||||
notes.md
|
|
||||||
scratch/
|
|
||||||
tmp/
|
|
||||||
|
|
|
||||||
48
deploy.nix
48
deploy.nix
|
|
@ -1,48 +0,0 @@
|
||||||
{ inputs, self, ... }:
|
|
||||||
{
|
|
||||||
flake.deploy = {
|
|
||||||
remoteBuild = true;
|
|
||||||
nodes = {
|
|
||||||
alexandria = {
|
|
||||||
hostname = "alexandria";
|
|
||||||
profiles.system = {
|
|
||||||
sshUser = "user";
|
|
||||||
path = inputs.deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.alexandria;
|
|
||||||
user = "root";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
trantor = {
|
|
||||||
hostname = "trantor";
|
|
||||||
profiles.system = {
|
|
||||||
sshUser = "user";
|
|
||||||
path = inputs.deploy-rs.lib.aarch64-linux.activate.nixos self.nixosConfigurations.trantor;
|
|
||||||
user = "root";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
io = {
|
|
||||||
hostname = "io";
|
|
||||||
profiles = {
|
|
||||||
system = {
|
|
||||||
sshUser = "user";
|
|
||||||
path = inputs.deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.io;
|
|
||||||
user = "root";
|
|
||||||
remoteBuild = false;
|
|
||||||
};
|
|
||||||
user = {
|
|
||||||
sshUser = "user";
|
|
||||||
path = inputs.deploy-rs.lib.x86_64-linux.activate.home-manager self.homeConfigurations."user@io";
|
|
||||||
user = "user";
|
|
||||||
remoteBuild = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
perSystem =
|
|
||||||
{ system, ... }:
|
|
||||||
{
|
|
||||||
checks = inputs.deploy-rs.lib.${system}.deployChecks self.deploy;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
{ inputs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
perSystem =
|
|
||||||
{ pkgs, system, ... }:
|
|
||||||
{
|
|
||||||
devShells.default = pkgs.mkShell {
|
|
||||||
packages = with pkgs; [
|
|
||||||
inputs.agenix.packages.${system}.default
|
|
||||||
deploy-rs
|
|
||||||
nil
|
|
||||||
nixfmt-rfc-style
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
1156
flake.lock
generated
1156
flake.lock
generated
File diff suppressed because it is too large
Load diff
217
flake.nix
217
flake.nix
|
|
@ -2,8 +2,6 @@
|
||||||
description = "My nix hosts";
|
description = "My nix hosts";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
|
||||||
|
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-25.05";
|
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-25.05";
|
||||||
|
|
||||||
|
|
@ -11,67 +9,186 @@
|
||||||
url = "github:nix-community/home-manager/master";
|
url = "github:nix-community/home-manager/master";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
home-manager-stable = {
|
||||||
|
url = "github:nix-community/home-manager/release-25.05";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs-stable";
|
||||||
|
};
|
||||||
|
|
||||||
|
disko = {
|
||||||
|
url = "github:nix-community/disko?ref=v1.11.0";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs-stable";
|
||||||
|
};
|
||||||
|
|
||||||
agenix = {
|
agenix = {
|
||||||
url = "github:ryantm/agenix";
|
url = "github:ryantm/agenix";
|
||||||
inputs.nixpkgs.follows = "nixpkgs-stable";
|
inputs.nixpkgs.follows = "nixpkgs-stable";
|
||||||
};
|
};
|
||||||
|
|
||||||
disko.url = "github:nix-community/disko";
|
deploy-rs = {
|
||||||
|
url = "github:serokell/deploy-rs";
|
||||||
noctalia = {
|
inputs.nixpkgs.follows = "nixpkgs-stable";
|
||||||
url = "github:noctalia-dev/noctalia-shell";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
stylix.url = "github:danth/stylix";
|
nix-flatpak.url = "github:gmodena/nix-flatpak/latest";
|
||||||
|
|
||||||
nixos-cli.url = "github:nix-community/nixos-cli";
|
|
||||||
|
|
||||||
nix-flatpak.url = "github:gmodena/nix-flatpak/main";
|
|
||||||
|
|
||||||
zen-browser.url = "github:0xc000022070/zen-browser-flake";
|
|
||||||
|
|
||||||
impermanence.url = "github:nix-community/impermanence";
|
impermanence.url = "github:nix-community/impermanence";
|
||||||
|
|
||||||
deploy-rs.url = "github:serokell/deploy-rs";
|
|
||||||
|
|
||||||
niri-flake.url = "github:sodiboo/niri-flake";
|
|
||||||
|
|
||||||
niri.url = "github:baduhai/niri/auto-center-when-space-available";
|
|
||||||
|
|
||||||
nix-index-database = {
|
|
||||||
url = "github:nix-community/nix-index-database";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
terranix = {
|
|
||||||
url = "github:terranix/terranix";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
nix-ai-tools.url = "github:numtide/nix-ai-tools";
|
|
||||||
|
|
||||||
vicinae.url = "github:vicinaehq/vicinae";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
inputs@{ flake-parts, ... }:
|
inputs@{
|
||||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
self,
|
||||||
systems = [
|
nixpkgs,
|
||||||
"x86_64-linux"
|
nixpkgs-stable,
|
||||||
"aarch64-linux"
|
home-manager,
|
||||||
];
|
home-manager-stable,
|
||||||
|
disko,
|
||||||
|
agenix,
|
||||||
|
deploy-rs,
|
||||||
|
nix-flatpak,
|
||||||
|
impermanence,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
nixosConfigurations =
|
||||||
|
let
|
||||||
|
mkHost =
|
||||||
|
{
|
||||||
|
hostname,
|
||||||
|
type, # workstation|server
|
||||||
|
system ? "x86_64-linux",
|
||||||
|
extraModules ? [ ],
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
pkgs = if type == "server" then nixpkgs-stable else nixpkgs;
|
||||||
|
hm = if type == "server" then home-manager-stable else home-manager;
|
||||||
|
hostTypeFlags = {
|
||||||
|
isServer = type == "server";
|
||||||
|
isWorkstation = type == "workstation";
|
||||||
|
};
|
||||||
|
defaultModules = [
|
||||||
|
./hosts/${hostname}.nix
|
||||||
|
agenix.nixosModules.default
|
||||||
|
disko.nixosModules.default
|
||||||
|
hm.nixosModules.default
|
||||||
|
impermanence.nixosModules.impermanence
|
||||||
|
nix-flatpak.nixosModules.nix-flatpak
|
||||||
|
{
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
agenix.overlays.default
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
workstationModules = [
|
||||||
|
{
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
self.overlays.workstationOverlay
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
serverModules = [
|
||||||
|
{
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
self.overlays.serverOverlay
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
typeModules = if type == "server" then serverModules else workstationModules;
|
||||||
|
allModules = defaultModules ++ typeModules ++ extraModules;
|
||||||
|
in
|
||||||
|
pkgs.lib.nixosSystem {
|
||||||
|
inherit system;
|
||||||
|
specialArgs = {
|
||||||
|
inherit inputs;
|
||||||
|
hostType = hostTypeFlags;
|
||||||
|
};
|
||||||
|
modules = allModules;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
rotterdam = mkHost {
|
||||||
|
hostname = "rotterdam";
|
||||||
|
type = "workstation";
|
||||||
|
};
|
||||||
|
io = mkHost {
|
||||||
|
hostname = "io";
|
||||||
|
type = "workstation";
|
||||||
|
};
|
||||||
|
alexandria = mkHost {
|
||||||
|
hostname = "alexandria";
|
||||||
|
type = "server";
|
||||||
|
extraModules = [ self.nixosModules.qbittorrent ];
|
||||||
|
};
|
||||||
|
trantor = mkHost {
|
||||||
|
hostname = "trantor";
|
||||||
|
type = "server";
|
||||||
|
system = "aarch64-linux";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
imports = [
|
overlays = {
|
||||||
./deploy.nix
|
overlay = final: prev: {
|
||||||
./devShells.nix
|
};
|
||||||
./homeConfigurations.nix
|
workstationOverlay = final: prev: {
|
||||||
./nixosConfigurations.nix
|
plasticity = nixpkgs.legacyPackages."x86_64-linux".callPackage ./packages/plasticity.nix { };
|
||||||
./nixosModules.nix
|
toggleaudiosink =
|
||||||
./overlays.nix
|
nixpkgs.legacyPackages."x86_64-linux".callPackage ./packages/toggleaudiosink.nix
|
||||||
./packages.nix
|
{ };
|
||||||
./terranixConfigurations.nix
|
};
|
||||||
];
|
serverOverlay = final: prev: {
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
deploy = {
|
||||||
|
autoRollback = true;
|
||||||
|
magicRollback = false;
|
||||||
|
nodes = {
|
||||||
|
alexandria = {
|
||||||
|
hostname = "alexandria";
|
||||||
|
profiles = {
|
||||||
|
system = {
|
||||||
|
user = "root";
|
||||||
|
sshUser = "root";
|
||||||
|
remoteBuild = true;
|
||||||
|
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.alexandria;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
trantor = {
|
||||||
|
hostname = "trantor";
|
||||||
|
profiles = {
|
||||||
|
system = {
|
||||||
|
user = "root";
|
||||||
|
sshUser = "root";
|
||||||
|
remoteBuild = true;
|
||||||
|
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.alexandria;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
io = {
|
||||||
|
hostname = "io";
|
||||||
|
profiles = {
|
||||||
|
system = {
|
||||||
|
user = "root";
|
||||||
|
sshUser = "root";
|
||||||
|
remoteBuild = false;
|
||||||
|
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.io;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;
|
||||||
|
|
||||||
|
devShells."x86_64-linux".default = nixpkgs.legacyPackages."x86_64-linux".mkShell {
|
||||||
|
packages = with nixpkgs.legacyPackages."x86_64-linux"; [
|
||||||
|
nil
|
||||||
|
nixfmt-rfc-style
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
nixosModules.qbittorrent = import ./modules/qbittorrent.nix;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
{ inputs, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
lib = inputs.nixpkgs.lib;
|
|
||||||
utils = import ./utils.nix { inherit inputs lib; };
|
|
||||||
inherit (utils) mkHome;
|
|
||||||
in
|
|
||||||
|
|
||||||
{
|
|
||||||
flake.homeConfigurations = {
|
|
||||||
"user@rotterdam" = mkHome {
|
|
||||||
username = "user";
|
|
||||||
hostname = "rotterdam";
|
|
||||||
tags = [
|
|
||||||
"desktop"
|
|
||||||
"btop"
|
|
||||||
"comma"
|
|
||||||
"direnv"
|
|
||||||
"gaming"
|
|
||||||
"helix"
|
|
||||||
"obs-studio"
|
|
||||||
"starship"
|
|
||||||
"stylix"
|
|
||||||
"tmux"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
"user@io" = mkHome {
|
|
||||||
username = "user";
|
|
||||||
hostname = "io";
|
|
||||||
tags = [
|
|
||||||
"desktop"
|
|
||||||
"btop"
|
|
||||||
"comma"
|
|
||||||
"direnv"
|
|
||||||
"helix"
|
|
||||||
"starship"
|
|
||||||
"stylix"
|
|
||||||
"tmux"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
12
hosts/alexandria.nix
Normal file
12
hosts/alexandria.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
networking.hostName = "alexandria";
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
./modules/alexandria
|
||||||
|
./modules
|
||||||
|
];
|
||||||
|
|
||||||
|
nix.nixPath = [ "nixos-config=${./alexandria.nix}" ];
|
||||||
|
}
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
{ lib, inputs, ... }:
|
|
||||||
let
|
|
||||||
utils = import ../../utils.nix { inherit inputs lib; };
|
|
||||||
inherit (utils) mkNginxVHosts;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
services.jellyfin = {
|
|
||||||
enable = true;
|
|
||||||
openFirewall = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.nginx.virtualHosts = mkNginxVHosts {
|
|
||||||
domains."jellyfin.baduhai.dev".locations."/".proxyPass = "http://127.0.0.1:8096/";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,83 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
inputs,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
utils = import ../../utils.nix { inherit inputs lib; };
|
|
||||||
inherit (utils) mkNginxVHosts;
|
|
||||||
kanidmCertDir = "/var/lib/kanidm/certs";
|
|
||||||
in
|
|
||||||
|
|
||||||
{
|
|
||||||
services.kanidm = {
|
|
||||||
enableServer = true;
|
|
||||||
enableClient = true;
|
|
||||||
package = pkgs.kanidm;
|
|
||||||
|
|
||||||
serverSettings = {
|
|
||||||
domain = "auth.baduhai.dev";
|
|
||||||
origin = "https://auth.baduhai.dev";
|
|
||||||
bindaddress = "127.0.0.1:8443";
|
|
||||||
ldapbindaddress = "127.0.0.1:636";
|
|
||||||
trust_x_forward_for = true;
|
|
||||||
# Use self-signed certificates for internal TLS
|
|
||||||
tls_chain = "${kanidmCertDir}/cert.pem";
|
|
||||||
tls_key = "${kanidmCertDir}/key.pem";
|
|
||||||
};
|
|
||||||
|
|
||||||
clientSettings = {
|
|
||||||
uri = "https://auth.baduhai.dev";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
services.nginx.virtualHosts = mkNginxVHosts {
|
|
||||||
domains."auth.baduhai.dev" = {
|
|
||||||
locations."/" = {
|
|
||||||
proxyPass = "https://127.0.0.1:8443";
|
|
||||||
extraConfig = ''
|
|
||||||
proxy_ssl_verify off;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [ 636 ];
|
|
||||||
|
|
||||||
# Generate self-signed certificates for kanidm's internal TLS
|
|
||||||
systemd.services.kanidm-generate-certs = {
|
|
||||||
description = "Generate self-signed TLS certificates for Kanidm";
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
before = [ "kanidm.service" ];
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
RemainAfterExit = true;
|
|
||||||
};
|
|
||||||
script = ''
|
|
||||||
mkdir -p ${kanidmCertDir}
|
|
||||||
if [ ! -f ${kanidmCertDir}/key.pem ]; then
|
|
||||||
${pkgs.openssl}/bin/openssl req -x509 -newkey rsa:4096 \
|
|
||||||
-keyout ${kanidmCertDir}/key.pem \
|
|
||||||
-out ${kanidmCertDir}/cert.pem \
|
|
||||||
-days 3650 -nodes \
|
|
||||||
-subj "/CN=localhost" \
|
|
||||||
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
|
|
||||||
chown -R kanidm:kanidm ${kanidmCertDir}
|
|
||||||
chmod 600 ${kanidmCertDir}/key.pem
|
|
||||||
chmod 644 ${kanidmCertDir}/cert.pem
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
# Ensure certificate generation runs before kanidm starts
|
|
||||||
systemd.services.kanidm = {
|
|
||||||
after = [ "kanidm-generate-certs.service" ];
|
|
||||||
wants = [ "kanidm-generate-certs.service" ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
inputs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
utils = import ../../utils.nix { inherit inputs lib; };
|
|
||||||
inherit (utils) mkNginxVHosts services;
|
|
||||||
|
|
||||||
# Get all unique domains from shared services that have LAN IPs (served by this host)
|
|
||||||
localDomains = lib.unique (map (s: s.domain) (lib.filter (s: s.host == "alexandria") services));
|
|
||||||
|
|
||||||
# Generate ACME cert configs for all local domains
|
|
||||||
acmeCerts = lib.genAttrs localDomains (domain: {
|
|
||||||
group = "nginx";
|
|
||||||
});
|
|
||||||
in
|
|
||||||
|
|
||||||
{
|
|
||||||
security.acme = {
|
|
||||||
acceptTerms = true;
|
|
||||||
defaults = {
|
|
||||||
email = "baduhai@proton.me";
|
|
||||||
dnsResolver = "1.1.1.1:53";
|
|
||||||
dnsProvider = "cloudflare";
|
|
||||||
credentialsFile = config.age.secrets.cloudflare.path;
|
|
||||||
};
|
|
||||||
certs = acmeCerts;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.nginx = {
|
|
||||||
enable = true;
|
|
||||||
recommendedGzipSettings = true;
|
|
||||||
recommendedOptimisation = true;
|
|
||||||
recommendedProxySettings = true;
|
|
||||||
recommendedTlsSettings = true;
|
|
||||||
virtualHosts = {
|
|
||||||
"_" = {
|
|
||||||
default = true;
|
|
||||||
locations."/".return = "444";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
users.users.nginx.extraGroups = [ "acme" ];
|
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [
|
|
||||||
80
|
|
||||||
443
|
|
||||||
];
|
|
||||||
|
|
||||||
age.secrets.cloudflare = {
|
|
||||||
file = ../../secrets/cloudflare.age;
|
|
||||||
owner = "nginx";
|
|
||||||
group = "nginx";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
{ inputs, lib, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
utils = import ../../utils.nix { inherit inputs lib; };
|
|
||||||
in
|
|
||||||
|
|
||||||
{
|
|
||||||
services.unbound = {
|
|
||||||
enable = true;
|
|
||||||
enableRootTrustAnchor = true;
|
|
||||||
settings = {
|
|
||||||
server = {
|
|
||||||
interface = [
|
|
||||||
"0.0.0.0"
|
|
||||||
"::"
|
|
||||||
];
|
|
||||||
access-control = [
|
|
||||||
"127.0.0.0/8 allow"
|
|
||||||
"192.168.0.0/16 allow"
|
|
||||||
"::1/128 allow"
|
|
||||||
];
|
|
||||||
|
|
||||||
num-threads = 2;
|
|
||||||
msg-cache-size = "50m";
|
|
||||||
rrset-cache-size = "100m";
|
|
||||||
cache-min-ttl = 300;
|
|
||||||
cache-max-ttl = 86400;
|
|
||||||
prefetch = true;
|
|
||||||
prefetch-key = true;
|
|
||||||
hide-identity = true;
|
|
||||||
hide-version = true;
|
|
||||||
so-rcvbuf = "1m";
|
|
||||||
so-sndbuf = "1m";
|
|
||||||
|
|
||||||
# LAN-only DNS records
|
|
||||||
local-zone = ''"baduhai.dev." transparent'';
|
|
||||||
local-data = map (e: ''"${e.domain}. IN A ${e.lanIP}"'')
|
|
||||||
(lib.filter (e: e ? lanIP) utils.services);
|
|
||||||
};
|
|
||||||
|
|
||||||
forward-zone = [
|
|
||||||
{
|
|
||||||
name = ".";
|
|
||||||
forward-addr = [
|
|
||||||
"1.1.1.1@853#cloudflare-dns.com"
|
|
||||||
"1.0.0.1@853#cloudflare-dns.com"
|
|
||||||
];
|
|
||||||
forward-tls-upstream = true;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
networking.firewall = {
|
|
||||||
allowedTCPPorts = [ 53 ];
|
|
||||||
allowedUDPPorts = [ 53 ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
inputs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
utils = import ../../utils.nix { inherit inputs lib; };
|
|
||||||
inherit (utils) mkNginxVHosts;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
services.vaultwarden = {
|
|
||||||
enable = true;
|
|
||||||
config = {
|
|
||||||
DOMAIN = "https://pass.baduhai.dev";
|
|
||||||
SIGNUPS_ALLOWED = false;
|
|
||||||
ROCKET_ADDRESS = "127.0.0.1";
|
|
||||||
ROCKET_PORT = 58222;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
services.nginx.virtualHosts = mkNginxVHosts {
|
|
||||||
domains."pass.baduhai.dev".locations."/".proxyPass =
|
|
||||||
"http://${config.services.vaultwarden.config.ROCKET_ADDRESS}:${toString config.services.vaultwarden.config.ROCKET_PORT}/";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
12
hosts/io.nix
Normal file
12
hosts/io.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
networking.hostName = "io";
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
./modules/io
|
||||||
|
./modules
|
||||||
|
];
|
||||||
|
|
||||||
|
nix.nixPath = [ "nixos-config=${./io.nix}" ];
|
||||||
|
}
|
||||||
|
|
@ -1,79 +0,0 @@
|
||||||
{ inputs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [ inputs.disko.nixosModules.default ];
|
|
||||||
|
|
||||||
disko.devices.disk.main = {
|
|
||||||
type = "disk";
|
|
||||||
device = "/dev/disk/by-id/mmc-hDEaP3_0x1041b689";
|
|
||||||
content = {
|
|
||||||
type = "gpt";
|
|
||||||
partitions = {
|
|
||||||
ESP = {
|
|
||||||
priority = 1;
|
|
||||||
name = "ESP";
|
|
||||||
start = "1MiB";
|
|
||||||
end = "1GiB";
|
|
||||||
type = "EF00";
|
|
||||||
content = {
|
|
||||||
type = "filesystem";
|
|
||||||
format = "vfat";
|
|
||||||
mountpoint = "/boot/efi";
|
|
||||||
mountOptions = [
|
|
||||||
"noatime"
|
|
||||||
"fmask=0077"
|
|
||||||
"dmask=0077"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
cryptroot = {
|
|
||||||
priority = 2;
|
|
||||||
name = "root";
|
|
||||||
size = "100%";
|
|
||||||
content = {
|
|
||||||
type = "luks";
|
|
||||||
name = "cryptroot";
|
|
||||||
content = {
|
|
||||||
type = "btrfs";
|
|
||||||
extraArgs = [ "-f" ];
|
|
||||||
subvolumes = {
|
|
||||||
"@root" = {
|
|
||||||
mountpoint = "/";
|
|
||||||
mountOptions = [
|
|
||||||
"noatime"
|
|
||||||
"compress=zstd"
|
|
||||||
"subvol=@root"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
"@home" = {
|
|
||||||
mountpoint = "/home";
|
|
||||||
mountOptions = [
|
|
||||||
"noatime"
|
|
||||||
"compress=zstd"
|
|
||||||
"subvol=@home"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
"@nix" = {
|
|
||||||
mountpoint = "/nix";
|
|
||||||
mountOptions = [
|
|
||||||
"noatime"
|
|
||||||
"compress=zstd"
|
|
||||||
"subvol=@nix"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
"@persistent" = {
|
|
||||||
mountpoint = "/persistent";
|
|
||||||
mountOptions = [
|
|
||||||
"noatime"
|
|
||||||
"compress=zstd"
|
|
||||||
"subvol=@persistent"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
modulesPath,
|
|
||||||
inputs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
|
|
||||||
|
|
||||||
boot = {
|
|
||||||
initrd = {
|
|
||||||
availableKernelModules = [
|
|
||||||
"xhci_pci"
|
|
||||||
"ahci"
|
|
||||||
"usb_storage"
|
|
||||||
"sd_mod"
|
|
||||||
"sdhci_pci"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
kernelModules = [ "kvm-intel" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
zramSwap = {
|
|
||||||
enable = true;
|
|
||||||
memoryPercent = 100;
|
|
||||||
};
|
|
||||||
|
|
||||||
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
|
|
||||||
|
|
||||||
networking.useDHCP = lib.mkDefault true;
|
|
||||||
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
|
||||||
|
|
||||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
{ inputs, pkgs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
environment.systemPackages = with inputs.nix-ai-tools.packages.${pkgs.system}; [
|
|
||||||
claude-desktop
|
|
||||||
claude-code
|
|
||||||
claudebox
|
|
||||||
opencode
|
|
||||||
];
|
|
||||||
}
|
|
||||||
20
hosts/modules/alexandria/changedetection.nix
Normal file
20
hosts/modules/alexandria/changedetection.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services = {
|
||||||
|
changedetection-io = {
|
||||||
|
enable = true;
|
||||||
|
behindProxy = true;
|
||||||
|
datastorePath = "/data/changedetection";
|
||||||
|
port = lib.toInt "${config.ports.changedetection-io}";
|
||||||
|
baseURL = "https://detect.baduhai.dev";
|
||||||
|
};
|
||||||
|
|
||||||
|
nginx.virtualHosts."detect.baduhai.dev" = {
|
||||||
|
useACMEHost = "baduhai.dev";
|
||||||
|
forceSSL = true;
|
||||||
|
kTLS = true;
|
||||||
|
locations."/".proxyPass = "http://127.0.0.1:${config.ports.changedetection-io}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
23
hosts/modules/alexandria/cinny.nix
Normal file
23
hosts/modules/alexandria/cinny.nix
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
virtualisation.oci-containers.containers."cinny" = {
|
||||||
|
image = "ghcr.io/cinnyapp/cinny:latest";
|
||||||
|
ports = [ "${config.ports.cinny}:80" ];
|
||||||
|
environment = {
|
||||||
|
TZ = "America/Bahia";
|
||||||
|
};
|
||||||
|
volumes = [ "/data/matrix/cinny-config.json:/app/config.json" ];
|
||||||
|
extraOptions = [
|
||||||
|
"--pull=newer"
|
||||||
|
"--label=io.containers.autoupdate=registry"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.nginx.virtualHosts."matrix.baduhai.dev" = {
|
||||||
|
useACMEHost = "baduhai.dev";
|
||||||
|
forceSSL = true;
|
||||||
|
kTLS = true;
|
||||||
|
locations."/".proxyPass = "http://127.0.0.1:${config.ports.cinny}";
|
||||||
|
};
|
||||||
|
}
|
||||||
49
hosts/modules/alexandria/default.nix
Normal file
49
hosts/modules/alexandria/default.nix
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
mkStringOption =
|
||||||
|
default:
|
||||||
|
lib.mkOption {
|
||||||
|
inherit default;
|
||||||
|
type = lib.types.str;
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./changedetection.nix
|
||||||
|
./cinny.nix
|
||||||
|
./forgejo.nix
|
||||||
|
./hardware-configuration.nix
|
||||||
|
./jellyfin.nix
|
||||||
|
./librespeed.nix
|
||||||
|
./memos.nix
|
||||||
|
# ./nextcloud.nix
|
||||||
|
./nginx.nix
|
||||||
|
./searx.nix
|
||||||
|
./services.nix
|
||||||
|
./users.nix
|
||||||
|
./vaultwarden.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
options.ports = {
|
||||||
|
bazaar = mkStringOption "6767";
|
||||||
|
radarr = mkStringOption "7878";
|
||||||
|
vaultwarden = mkStringOption "8000";
|
||||||
|
changedetection-io = mkStringOption "8001";
|
||||||
|
cinny = mkStringOption "8002";
|
||||||
|
librespeed = mkStringOption "8003";
|
||||||
|
paperless = mkStringOption "8004";
|
||||||
|
yousable = mkStringOption "8005";
|
||||||
|
cinny2 = mkStringOption "8006";
|
||||||
|
searx = mkStringOption "8007";
|
||||||
|
qbittorrent = mkStringOption "8008";
|
||||||
|
actual = mkStringOption "8009";
|
||||||
|
memos = mkStringOption "8010";
|
||||||
|
collabora = mkStringOption "8011";
|
||||||
|
jellyfin = mkStringOption "8096";
|
||||||
|
sonarr = mkStringOption "8989";
|
||||||
|
jackett = mkStringOption "9117";
|
||||||
|
};
|
||||||
|
}
|
||||||
33
hosts/modules/alexandria/forgejo.nix
Normal file
33
hosts/modules/alexandria/forgejo.nix
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
domain = "git.baduhai.dev";
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
services = {
|
||||||
|
forgejo = {
|
||||||
|
enable = true;
|
||||||
|
repositoryRoot = "/data/forgejo";
|
||||||
|
settings = {
|
||||||
|
session.COOKIE_SECURE = true;
|
||||||
|
server = {
|
||||||
|
PROTOCOL = "http+unix";
|
||||||
|
DOMAIN = domain;
|
||||||
|
ROOT_URL = "https://${domain}";
|
||||||
|
OFFLINE_MODE = true; # disable use of CDNs
|
||||||
|
SSH_DOMAIN = "baduhai.dev";
|
||||||
|
};
|
||||||
|
log.LEVEL = "Warn";
|
||||||
|
mailer.ENABLED = false;
|
||||||
|
actions.ENABLED = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
nginx.virtualHosts.${domain} = {
|
||||||
|
useACMEHost = "baduhai.dev";
|
||||||
|
forceSSL = true;
|
||||||
|
kTLS = true;
|
||||||
|
locations."/".proxyPass = "http://unix:${config.services.forgejo.settings.server.HTTP_ADDR}:/";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
19
hosts/modules/alexandria/jellyfin.nix
Normal file
19
hosts/modules/alexandria/jellyfin.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services = {
|
||||||
|
jellyfin = {
|
||||||
|
enable = true;
|
||||||
|
user = "user";
|
||||||
|
group = "hosted";
|
||||||
|
openFirewall = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
nginx.virtualHosts."jellyfin.baduhai.dev" = {
|
||||||
|
useACMEHost = "baduhai.dev";
|
||||||
|
forceSSL = true;
|
||||||
|
kTLS = true;
|
||||||
|
locations."/".proxyPass = "http://127.0.0.1:${config.ports.jellyfin}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
22
hosts/modules/alexandria/librespeed.nix
Normal file
22
hosts/modules/alexandria/librespeed.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
virtualisation.oci-containers.containers."librespeed" = {
|
||||||
|
image = "lscr.io/linuxserver/librespeed:latest";
|
||||||
|
environment = {
|
||||||
|
TZ = "America/Bahia";
|
||||||
|
};
|
||||||
|
ports = [ "${config.ports.librespeed}:80" ];
|
||||||
|
extraOptions = [
|
||||||
|
"--pull=newer"
|
||||||
|
"--label=io.containers.autoupdate=registry"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.nginx.virtualHosts."speed.baduhai.dev" = {
|
||||||
|
useACMEHost = "baduhai.dev";
|
||||||
|
forceSSL = true;
|
||||||
|
kTLS = true;
|
||||||
|
locations."/".proxyPass = "http://127.0.0.1:${config.ports.librespeed}";
|
||||||
|
};
|
||||||
|
}
|
||||||
23
hosts/modules/alexandria/memos.nix
Normal file
23
hosts/modules/alexandria/memos.nix
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
virtualisation.oci-containers.containers."memos" = {
|
||||||
|
image = "docker.io/neosmemo/memos:stable";
|
||||||
|
ports = [ "${config.ports.memos}:5230" ];
|
||||||
|
environment = {
|
||||||
|
TZ = "America/Bahia";
|
||||||
|
};
|
||||||
|
volumes = [ "/data/memos/:/var/opt/memos" ];
|
||||||
|
extraOptions = [
|
||||||
|
"--pull=newer"
|
||||||
|
"--label=io.containers.autoupdate=registry"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.nginx.virtualHosts."notes.baduhai.dev" = {
|
||||||
|
useACMEHost = "baduhai.dev";
|
||||||
|
forceSSL = true;
|
||||||
|
kTLS = true;
|
||||||
|
locations."/".proxyPass = "http://127.0.0.1:${config.ports.memos}";
|
||||||
|
};
|
||||||
|
}
|
||||||
17
hosts/modules/alexandria/networking.nix
Normal file
17
hosts/modules/alexandria/networking.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
networking = {
|
||||||
|
firewall = {
|
||||||
|
allowedTCPPorts = [
|
||||||
|
80 # HTTP
|
||||||
|
443 # HTTPS
|
||||||
|
25565 # Minecraft
|
||||||
|
];
|
||||||
|
allowedUDPPorts = [
|
||||||
|
19132 # Minecraft Bedrock
|
||||||
|
25565 # Minecraft
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -2,37 +2,22 @@
|
||||||
lib,
|
lib,
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
inputs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
|
||||||
utils = import ../../utils.nix { inherit inputs lib; };
|
|
||||||
inherit (utils) mkNginxVHosts;
|
|
||||||
in
|
|
||||||
|
|
||||||
{
|
{
|
||||||
services = {
|
services = {
|
||||||
nextcloud = {
|
nextcloud = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.nextcloud32;
|
package = pkgs.nextcloud31;
|
||||||
datadir = "/data/nextcloud";
|
datadir = "/data/nextcloud";
|
||||||
hostName = "cloud.baduhai.dev";
|
hostName = "cloud.baduhai.dev";
|
||||||
configureRedis = true;
|
configureRedis = true;
|
||||||
https = true;
|
https = true;
|
||||||
|
autoUpdateApps.enable = true;
|
||||||
secretFile = config.age.secrets."nextcloud-secrets.json".path;
|
secretFile = config.age.secrets."nextcloud-secrets.json".path;
|
||||||
database.createLocally = true;
|
database.createLocally = true;
|
||||||
maxUploadSize = "16G";
|
maxUploadSize = "16G";
|
||||||
extraApps = {
|
|
||||||
inherit (config.services.nextcloud.package.packages.apps)
|
|
||||||
calendar
|
|
||||||
contacts
|
|
||||||
notes
|
|
||||||
tasks
|
|
||||||
user_oidc
|
|
||||||
;
|
|
||||||
};
|
|
||||||
extraAppsEnable = true;
|
|
||||||
caching = {
|
caching = {
|
||||||
apcu = true;
|
apcu = true;
|
||||||
redis = true;
|
redis = true;
|
||||||
|
|
@ -41,7 +26,6 @@ in
|
||||||
trusted_proxies = [ "127.0.0.1" ];
|
trusted_proxies = [ "127.0.0.1" ];
|
||||||
default_phone_region = "BR";
|
default_phone_region = "BR";
|
||||||
maintenance_window_start = "4";
|
maintenance_window_start = "4";
|
||||||
allow_local_remote_servers = true;
|
|
||||||
enabledPreviewProviders = [
|
enabledPreviewProviders = [
|
||||||
"OC\\Preview\\BMP"
|
"OC\\Preview\\BMP"
|
||||||
"OC\\Preview\\EMF"
|
"OC\\Preview\\EMF"
|
||||||
|
|
@ -77,21 +61,43 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nginx.virtualHosts = mkNginxVHosts {
|
collabora-online = {
|
||||||
domains."cloud.baduhai.dev" = { };
|
enable = true;
|
||||||
|
port = lib.strings.toInt config.ports.collabora;
|
||||||
|
settings.ssl = {
|
||||||
|
enable = false;
|
||||||
|
termination = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nginx.virtualHosts = {
|
||||||
|
${config.services.nextcloud.hostName} = {
|
||||||
|
useACMEHost = "baduhai.dev";
|
||||||
|
forceSSL = true;
|
||||||
|
kTLS = true;
|
||||||
|
};
|
||||||
|
"office.baduhai.dev" = {
|
||||||
|
useACMEHost = "baduhai.dev";
|
||||||
|
forceSSL = true;
|
||||||
|
kTLS = true;
|
||||||
|
locations."/" = {
|
||||||
|
proxyPass = "http://127.0.0.1:${config.ports.collabora}";
|
||||||
|
proxyWebsockets = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
age.secrets = {
|
age.secrets = {
|
||||||
"nextcloud-secrets.json" = {
|
"nextcloud-secrets.json" = {
|
||||||
file = ../../secrets/nextcloud-secrets.json.age;
|
file = ../../../secrets/nextcloud-secrets.json.age;
|
||||||
owner = "nextcloud";
|
owner = "nextcloud";
|
||||||
group = "nextcloud";
|
group = "hosted";
|
||||||
};
|
};
|
||||||
nextcloud-adminpass = {
|
nextcloud-adminpass = {
|
||||||
file = ../../secrets/nextcloud-adminpass.age;
|
file = ../../../secrets/nextcloud-adminpass.age;
|
||||||
owner = "nextcloud";
|
owner = "nextcloud";
|
||||||
group = "nextcloud";
|
group = "hosted";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
37
hosts/modules/alexandria/nginx.nix
Normal file
37
hosts/modules/alexandria/nginx.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services.nginx = {
|
||||||
|
enable = true;
|
||||||
|
group = "hosted";
|
||||||
|
recommendedGzipSettings = true;
|
||||||
|
recommendedOptimisation = true;
|
||||||
|
recommendedProxySettings = true;
|
||||||
|
recommendedTlsSettings = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
security.acme = {
|
||||||
|
acceptTerms = true;
|
||||||
|
defaults = {
|
||||||
|
email = "baduhai@proton.me";
|
||||||
|
dnsResolver = "1.1.1.1:53";
|
||||||
|
dnsProvider = "cloudflare";
|
||||||
|
credentialsFile = config.age.secrets.cloudflare.path;
|
||||||
|
};
|
||||||
|
certs."baduhai.dev" = {
|
||||||
|
extraDomainNames = [ "*.baduhai.dev" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
boot.kernel.sysctl = {
|
||||||
|
"net.ipv4.ip_forward" = 1;
|
||||||
|
"net.ipv6.conf.all.forwarding" = 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
age.secrets.cloudflare = {
|
||||||
|
file = ../../../secrets/cloudflare.age;
|
||||||
|
owner = "nginx";
|
||||||
|
group = "hosted";
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
28
hosts/modules/alexandria/searx.nix
Normal file
28
hosts/modules/alexandria/searx.nix
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
services = {
|
||||||
|
searx = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.searxng;
|
||||||
|
settings.server = {
|
||||||
|
port = lib.toInt "${config.ports.searx}";
|
||||||
|
bind_address = "0.0.0.0";
|
||||||
|
secret_key = "&yEf!xLA@y3FdJ5BjKnUnNAkqer$iW!9";
|
||||||
|
method = "GET";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nginx.virtualHosts."search.baduhai.dev" = {
|
||||||
|
useACMEHost = "baduhai.dev";
|
||||||
|
forceSSL = true;
|
||||||
|
kTLS = true;
|
||||||
|
locations."/".proxyPass = "http://127.0.0.1:${config.ports.searx}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
11
hosts/modules/alexandria/services.nix
Normal file
11
hosts/modules/alexandria/services.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services.postgresql.enable = true;
|
||||||
|
|
||||||
|
# TODO: remove when bug fix
|
||||||
|
# serokell/deploy-rs/issues/57
|
||||||
|
# NixOS/nixpkgs/issues/180175
|
||||||
|
# Workaround for upstream bug in NetworkManager-wait-online.service
|
||||||
|
systemd.services.NetworkManager-wait-online.enable = false;
|
||||||
|
}
|
||||||
19
hosts/modules/alexandria/users.nix
Normal file
19
hosts/modules/alexandria/users.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
users = {
|
||||||
|
users = {
|
||||||
|
nginx.extraGroups = [ "acme" ];
|
||||||
|
};
|
||||||
|
groups = {
|
||||||
|
hosted = {
|
||||||
|
gid = 1005;
|
||||||
|
members = [
|
||||||
|
"user"
|
||||||
|
"paperless"
|
||||||
|
"vaultwarden"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
22
hosts/modules/alexandria/vaultwarden.nix
Normal file
22
hosts/modules/alexandria/vaultwarden.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services = {
|
||||||
|
vaultwarden = {
|
||||||
|
enable = true;
|
||||||
|
config = {
|
||||||
|
DOMAIN = "https://pass.baduhai.dev";
|
||||||
|
SIGNUPS_ALLOWED = true;
|
||||||
|
ROCKET_ADDRESS = "127.0.0.1";
|
||||||
|
ROCKET_PORT = "${config.ports.vaultwarden}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nginx.virtualHosts."pass.baduhai.dev" = {
|
||||||
|
useACMEHost = "baduhai.dev";
|
||||||
|
forceSSL = true;
|
||||||
|
kTLS = true;
|
||||||
|
locations."/".proxyPass = "http://127.0.0.1:${config.ports.vaultwarden}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
hardware.bluetooth.enable = true;
|
|
||||||
}
|
|
||||||
61
hosts/modules/boot.nix
Normal file
61
hosts/modules/boot.nix
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
{
|
||||||
|
hostType,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = lib.mkMerge [
|
||||||
|
# Common configuration
|
||||||
|
{
|
||||||
|
boot = {
|
||||||
|
loader = {
|
||||||
|
timeout = 1;
|
||||||
|
efi.canTouchEfiVariables = true;
|
||||||
|
systemd-boot = {
|
||||||
|
enable = true;
|
||||||
|
editor = false;
|
||||||
|
consoleMode = "max";
|
||||||
|
sortKey = "aa";
|
||||||
|
netbootxyz = {
|
||||||
|
enable = true;
|
||||||
|
sortKey = "zz";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
# Server specific configuration
|
||||||
|
(lib.mkIf hostType.isServer {
|
||||||
|
boot.kernelPackages = pkgs.linuxPackages_hardened;
|
||||||
|
})
|
||||||
|
|
||||||
|
# Workstation specific configuration
|
||||||
|
(lib.mkIf hostType.isWorkstation {
|
||||||
|
boot = {
|
||||||
|
plymouth.enable = true;
|
||||||
|
initrd.systemd.enable = true;
|
||||||
|
loader.efi.efiSysMountPoint = "/boot/efi";
|
||||||
|
kernelPackages = pkgs.linuxPackages_xanmod_latest;
|
||||||
|
extraModprobeConfig = ''
|
||||||
|
options bluetooth disable_ertm=1
|
||||||
|
'';
|
||||||
|
kernel.sysctl = {
|
||||||
|
"net.ipv4.tcp_mtu_probing" = 1;
|
||||||
|
};
|
||||||
|
kernelParams = [
|
||||||
|
"quiet"
|
||||||
|
"splash"
|
||||||
|
"i2c-dev"
|
||||||
|
"i2c-piix4"
|
||||||
|
"loglevel=3"
|
||||||
|
"udev.log_priority=3"
|
||||||
|
"rd.udev.log_level=3"
|
||||||
|
"rd.systemd.show_status=false"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
{ pkgs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
boot = {
|
|
||||||
loader = {
|
|
||||||
timeout = 1;
|
|
||||||
efi.canTouchEfiVariables = true;
|
|
||||||
systemd-boot = {
|
|
||||||
enable = true;
|
|
||||||
editor = false;
|
|
||||||
consoleMode = "max";
|
|
||||||
sortKey = "aa";
|
|
||||||
netbootxyz = {
|
|
||||||
enable = true;
|
|
||||||
sortKey = "zz";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
console = {
|
|
||||||
useXkbConfig = true;
|
|
||||||
earlySetup = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
networking = {
|
|
||||||
firewall.enable = true;
|
|
||||||
nftables.enable = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
time.timeZone = "America/Bahia";
|
|
||||||
|
|
||||||
i18n = {
|
|
||||||
defaultLocale = "en_US.UTF-8";
|
|
||||||
extraLocaleSettings = {
|
|
||||||
LC_ADDRESS = "pt_BR.utf8";
|
|
||||||
LC_COLLATE = "pt_BR.utf8";
|
|
||||||
LC_IDENTIFICATION = "pt_BR.utf8";
|
|
||||||
LC_MEASUREMENT = "pt_BR.utf8";
|
|
||||||
LC_MONETARY = "pt_BR.utf8";
|
|
||||||
LC_NAME = "pt_BR.utf8";
|
|
||||||
LC_NUMERIC = "pt_BR.utf8";
|
|
||||||
LC_PAPER = "pt_BR.utf8";
|
|
||||||
LC_TELEPHONE = "pt_BR.utf8";
|
|
||||||
LC_TIME = "en_IE.utf8";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
{ inputs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [ inputs.nixos-cli.nixosModules.nixos-cli ];
|
|
||||||
|
|
||||||
nix = {
|
|
||||||
settings = {
|
|
||||||
auto-optimise-store = true;
|
|
||||||
connect-timeout = 10;
|
|
||||||
log-lines = 25;
|
|
||||||
min-free = 128000000;
|
|
||||||
max-free = 1000000000;
|
|
||||||
trusted-users = [ "@wheel" ];
|
|
||||||
};
|
|
||||||
extraOptions = "experimental-features = nix-command flakes";
|
|
||||||
gc = {
|
|
||||||
automatic = true;
|
|
||||||
options = "--delete-older-than 8d";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
nixpkgs.config = {
|
|
||||||
allowUnfree = true;
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
buildManPages = false;
|
|
||||||
buildDocs = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.nixos-cli = {
|
|
||||||
enable = true;
|
|
||||||
config = {
|
|
||||||
use_nvd = true;
|
|
||||||
ignore_dirty_tree = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
system.stateVersion = "22.11";
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
services.openssh = {
|
|
||||||
enable = true;
|
|
||||||
settings.PermitRootLogin = "no";
|
|
||||||
extraConfig = ''
|
|
||||||
PrintLastLog no
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
{ lib, pkgs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
environment = {
|
|
||||||
systemPackages = with pkgs; [
|
|
||||||
### Dev Tools ###
|
|
||||||
git
|
|
||||||
### System Utilities ###
|
|
||||||
btop
|
|
||||||
fastfetch
|
|
||||||
helix
|
|
||||||
nixos-firewall-tool
|
|
||||||
nvd
|
|
||||||
sysz
|
|
||||||
tmux
|
|
||||||
wget
|
|
||||||
yazi
|
|
||||||
];
|
|
||||||
shellAliases = {
|
|
||||||
cat = "${lib.getExe pkgs.bat} --paging=never --style=plain";
|
|
||||||
ls = "${lib.getExe pkgs.eza} --icons --group-directories-first";
|
|
||||||
tree = "ls --tree";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
programs = {
|
|
||||||
command-not-found.enable = false;
|
|
||||||
fish = {
|
|
||||||
enable = true;
|
|
||||||
interactiveShellInit = ''
|
|
||||||
set fish_greeting
|
|
||||||
if set -q SSH_CONNECTION
|
|
||||||
export TERM=xterm-256color
|
|
||||||
clear
|
|
||||||
fastfetch
|
|
||||||
end
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
security = {
|
|
||||||
unprivilegedUsernsClone = true; # Needed for rootless podman
|
|
||||||
sudo = {
|
|
||||||
wheelNeedsPassword = false;
|
|
||||||
extraConfig = ''
|
|
||||||
Defaults lecture = never
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
services = {
|
|
||||||
dbus.implementation = "broker";
|
|
||||||
irqbalance.enable = true;
|
|
||||||
fstrim.enable = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
services.tailscale = {
|
|
||||||
enable = true;
|
|
||||||
extraUpFlags = [ "--operator=user" ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
{ pkgs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
users.users = {
|
|
||||||
user = {
|
|
||||||
isNormalUser = true;
|
|
||||||
shell = pkgs.fish;
|
|
||||||
extraGroups = [
|
|
||||||
"networkmanager"
|
|
||||||
"wheel"
|
|
||||||
];
|
|
||||||
openssh.authorizedKeys.keys = [
|
|
||||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICQPkAyy+Du9Omc2WtnUF2TV8jFAF4H6mJi2D4IZ1nzg user@himalia"
|
|
||||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO3Y0PVpGfJHonqDS7qoCFhqzUvqGq9I9sax+F9e/5cs user@io"
|
|
||||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA1v3+q3EaruiiStWjubEJWvtejam/r41uoOpCdwJtLL user@rotterdam"
|
|
||||||
];
|
|
||||||
hashedPassword = "$6$Pj7v/CpstyuWQQV0$cNujVDhfMBdwlGVEnnd8t71.kZPixbo0u25cd.874iaqLTH4V5fa1f98V5zGapjQCz5JyZmsR94xi00sUrntT0";
|
|
||||||
};
|
|
||||||
root = {
|
|
||||||
shell = pkgs.fish;
|
|
||||||
hashedPassword = "!";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
21
hosts/modules/console.nix
Normal file
21
hosts/modules/console.nix
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
{ hostType, lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = lib.mkMerge [
|
||||||
|
# Common configuration
|
||||||
|
{
|
||||||
|
console = {
|
||||||
|
useXkbConfig = true;
|
||||||
|
earlySetup = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
# Server specific configuration
|
||||||
|
(lib.mkIf hostType.isServer {
|
||||||
|
})
|
||||||
|
|
||||||
|
# Workstation specific configuration
|
||||||
|
(lib.mkIf hostType.isWorkstation {
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
18
hosts/modules/default.nix
Normal file
18
hosts/modules/default.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./boot.nix
|
||||||
|
./console.nix
|
||||||
|
./desktop.nix
|
||||||
|
./impermanence.nix
|
||||||
|
./locale.nix
|
||||||
|
./networking.nix
|
||||||
|
./nix.nix
|
||||||
|
./programs.nix
|
||||||
|
./security.nix
|
||||||
|
./services.nix
|
||||||
|
./users.nix
|
||||||
|
./virtualisation.nix
|
||||||
|
];
|
||||||
|
}
|
||||||
64
hosts/modules/desktop.nix
Normal file
64
hosts/modules/desktop.nix
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
{
|
||||||
|
hostType,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = lib.mkMerge [
|
||||||
|
# Common configuration
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
# Server specific configuration
|
||||||
|
(lib.mkIf hostType.isServer {
|
||||||
|
})
|
||||||
|
|
||||||
|
# Workstation specific configuration
|
||||||
|
(lib.mkIf hostType.isWorkstation {
|
||||||
|
services = {
|
||||||
|
pipewire = {
|
||||||
|
enable = true;
|
||||||
|
alsa.enable = true;
|
||||||
|
alsa.support32Bit = true;
|
||||||
|
pulse.enable = true;
|
||||||
|
jack.enable = true;
|
||||||
|
wireplumber.enable = true;
|
||||||
|
};
|
||||||
|
greetd = {
|
||||||
|
enable = true;
|
||||||
|
settings.default_session.command = "${pkgs.greetd.tuigreet}/bin/tuigreet --remember --asterisks --time";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
programs.niri.enable = true;
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
anyrun
|
||||||
|
foot
|
||||||
|
gsettings-desktop-schemas
|
||||||
|
swaybg
|
||||||
|
swww
|
||||||
|
xwayland-satellite
|
||||||
|
];
|
||||||
|
|
||||||
|
hardware = {
|
||||||
|
xpadneo.enable = true;
|
||||||
|
bluetooth.enable = true;
|
||||||
|
steam-hardware.enable = true; # Allow steam client to manage controllers
|
||||||
|
graphics.enable32Bit = true; # For OpenGL games
|
||||||
|
i2c.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
security.rtkit.enable = true; # Needed for pipewire to acquire realtime priority
|
||||||
|
|
||||||
|
xdg.portal = {
|
||||||
|
enable = true;
|
||||||
|
xdgOpenUsePortal = true;
|
||||||
|
extraPortals = with pkgs; [
|
||||||
|
xdg-desktop-portal-gtk
|
||||||
|
xdg-desktop-portal-gnome
|
||||||
|
];
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
{ pkgs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
boot = {
|
|
||||||
plymouth.enable = true;
|
|
||||||
initrd.systemd.enable = true;
|
|
||||||
loader.efi.efiSysMountPoint = "/boot/efi";
|
|
||||||
kernelPackages = pkgs.linuxPackages_xanmod_latest;
|
|
||||||
extraModprobeConfig = ''
|
|
||||||
options bluetooth disable_ertm=1
|
|
||||||
'';
|
|
||||||
kernel.sysctl = {
|
|
||||||
"net.ipv4.tcp_mtu_probing" = 1;
|
|
||||||
};
|
|
||||||
kernelParams = [
|
|
||||||
"quiet"
|
|
||||||
"splash"
|
|
||||||
"i2c-dev"
|
|
||||||
"i2c-piix4"
|
|
||||||
"loglevel=3"
|
|
||||||
"udev.log_priority=3"
|
|
||||||
"rd.udev.log_level=3"
|
|
||||||
"rd.systemd.show_status=false"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,163 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
inputs,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
inputs.niri-flake.nixosModules.niri
|
|
||||||
inputs.nix-flatpak.nixosModules.nix-flatpak
|
|
||||||
];
|
|
||||||
|
|
||||||
environment = {
|
|
||||||
sessionVariables = {
|
|
||||||
KDEHOME = "$XDG_CONFIG_HOME/kde4"; # Stops kde from placing a .kde4 folder in the home dir
|
|
||||||
NIXOS_OZONE_WL = "1"; # Forces chromium and most electron apps to run in wayland
|
|
||||||
};
|
|
||||||
systemPackages = with pkgs; [
|
|
||||||
### Web ###
|
|
||||||
bitwarden-desktop
|
|
||||||
fragments
|
|
||||||
nextcloud-client
|
|
||||||
tor-browser
|
|
||||||
vesktop
|
|
||||||
inputs.zen-browser.packages."${system}".default
|
|
||||||
### Office & Productivity ###
|
|
||||||
aspell
|
|
||||||
aspellDicts.de
|
|
||||||
aspellDicts.en
|
|
||||||
aspellDicts.en-computers
|
|
||||||
aspellDicts.pt_BR
|
|
||||||
libreoffice
|
|
||||||
onlyoffice-desktopeditors
|
|
||||||
papers
|
|
||||||
presenterm
|
|
||||||
rnote
|
|
||||||
### Graphics & Design ###
|
|
||||||
gimp
|
|
||||||
inkscape
|
|
||||||
plasticity
|
|
||||||
### System Utilities ###
|
|
||||||
adwaita-icon-theme
|
|
||||||
ghostty
|
|
||||||
gnome-disk-utility
|
|
||||||
junction
|
|
||||||
libfido2
|
|
||||||
mission-center
|
|
||||||
nautilus
|
|
||||||
p7zip
|
|
||||||
rclone
|
|
||||||
toggleaudiosink
|
|
||||||
unrar
|
|
||||||
### Media ###
|
|
||||||
decibels
|
|
||||||
loupe
|
|
||||||
obs-studio
|
|
||||||
showtime
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
services = {
|
|
||||||
pipewire = {
|
|
||||||
enable = true;
|
|
||||||
alsa.enable = true;
|
|
||||||
alsa.support32Bit = true;
|
|
||||||
pulse.enable = true;
|
|
||||||
jack.enable = true;
|
|
||||||
wireplumber.enable = true;
|
|
||||||
};
|
|
||||||
greetd = {
|
|
||||||
enable = true;
|
|
||||||
settings = {
|
|
||||||
default_session = {
|
|
||||||
command = "${lib.getExe pkgs.tuigreet} --user-menu --time --remember --asterisks --cmd ${config.programs.niri.package}/bin/niri-session";
|
|
||||||
user = "greeter";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// lib.optionalAttrs (config.networking.hostName == "io") {
|
|
||||||
initial_session = {
|
|
||||||
command = "${config.programs.niri.package}/bin/niri-session";
|
|
||||||
user = "user";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
flatpak = {
|
|
||||||
enable = true;
|
|
||||||
packages = [
|
|
||||||
### Graphics & Design ###
|
|
||||||
"com.boxy_svg.BoxySVG"
|
|
||||||
rec {
|
|
||||||
appId = "io.github.softfever.OrcaSlicer";
|
|
||||||
sha256 = "0hdx5sg6fknj1pfnfxvlfwb5h6y1vjr6fyajbsnjph5gkp97c6p1";
|
|
||||||
bundle = "${pkgs.fetchurl {
|
|
||||||
url = "https://github.com/SoftFever/OrcaSlicer/releases/download/v2.3.0/OrcaSlicer-Linux-flatpak_V2.3.0_x86_64.flatpak";
|
|
||||||
inherit sha256;
|
|
||||||
}}";
|
|
||||||
}
|
|
||||||
### System Utilities ###
|
|
||||||
"com.github.tchx84.Flatseal"
|
|
||||||
"com.rustdesk.RustDesk"
|
|
||||||
];
|
|
||||||
uninstallUnmanaged = true;
|
|
||||||
update.auto.enable = true;
|
|
||||||
};
|
|
||||||
gvfs.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
security.rtkit.enable = true; # Needed for pipewire to acquire realtime priority
|
|
||||||
|
|
||||||
users = {
|
|
||||||
users.greeter = {
|
|
||||||
isSystemUser = true;
|
|
||||||
group = "greeter";
|
|
||||||
};
|
|
||||||
groups.greeter = { };
|
|
||||||
};
|
|
||||||
|
|
||||||
programs = {
|
|
||||||
niri = {
|
|
||||||
enable = true;
|
|
||||||
package = inputs.niri.packages.${pkgs.system}.niri;
|
|
||||||
};
|
|
||||||
kdeconnect = {
|
|
||||||
enable = true;
|
|
||||||
package = pkgs.valent;
|
|
||||||
};
|
|
||||||
dconf.enable = true;
|
|
||||||
appimage = {
|
|
||||||
enable = true;
|
|
||||||
binfmt = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
niri-flake.cache.enable = false;
|
|
||||||
|
|
||||||
fonts = {
|
|
||||||
fontDir.enable = true;
|
|
||||||
packages = with pkgs; [
|
|
||||||
corefonts
|
|
||||||
inter
|
|
||||||
nerd-fonts.fira-code
|
|
||||||
noto-fonts-cjk-sans
|
|
||||||
noto-fonts-color-emoji
|
|
||||||
roboto
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
xdg.portal = {
|
|
||||||
extraPortals = with pkgs; [
|
|
||||||
xdg-desktop-portal-gnome
|
|
||||||
xdg-desktop-portal-gtk
|
|
||||||
];
|
|
||||||
config = {
|
|
||||||
common.default = "*";
|
|
||||||
niri.default = [
|
|
||||||
"gtk"
|
|
||||||
"gnome"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
{ inputs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
environment.etc."channels/nixpkgs".source = inputs.nixpkgs.outPath;
|
|
||||||
|
|
||||||
nix = {
|
|
||||||
registry.nixpkgs.flake = inputs.nixpkgs;
|
|
||||||
nixPath = [
|
|
||||||
"nixpkgs=${inputs.nixpkgs}"
|
|
||||||
"/nix/var/nix/profiles/per-user/root/channels"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
{ pkgs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
services = {
|
|
||||||
printing.enable = true;
|
|
||||||
udev.packages = with pkgs; [ yubikey-personalization ];
|
|
||||||
keyd = {
|
|
||||||
enable = true;
|
|
||||||
keyboards.all = {
|
|
||||||
ids = [ "*" ];
|
|
||||||
settings.main.capslock = "overload(meta, esc)";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
{ pkgs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
environment.systemPackages = with pkgs; [
|
|
||||||
bat
|
|
||||||
lazygit
|
|
||||||
fd
|
|
||||||
fzf
|
|
||||||
glow
|
|
||||||
nixfmt-rfc-style
|
|
||||||
nix-init
|
|
||||||
nix-output-monitor
|
|
||||||
ripgrep
|
|
||||||
];
|
|
||||||
|
|
||||||
programs.adb.enable = true;
|
|
||||||
|
|
||||||
users.users.user.extraGroups = [ "adbusers" ];
|
|
||||||
}
|
|
||||||
4
hosts/modules/environment.nix
Normal file
4
hosts/modules/environment.nix
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
{ config, inputs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
inputs.impermanence.nixosModules.impermanence
|
|
||||||
inputs.self.nixosModules.ephemeral
|
|
||||||
];
|
|
||||||
|
|
||||||
ephemeral = {
|
|
||||||
enable = true;
|
|
||||||
rootDevice =
|
|
||||||
if config.networking.hostName == "trantor" then
|
|
||||||
"/dev/disk/by-id/scsi-360b207ed25d84372a95d1ecf842f8e20-part2"
|
|
||||||
else
|
|
||||||
"/dev/mapper/cryptroot";
|
|
||||||
rootSubvolume = "@root";
|
|
||||||
};
|
|
||||||
|
|
||||||
environment.persistence.main = {
|
|
||||||
persistentStoragePath = "/persistent";
|
|
||||||
files = [
|
|
||||||
"/etc/machine-id"
|
|
||||||
"/etc/ssh/ssh_host_ed25519_key"
|
|
||||||
"/etc/ssh/ssh_host_ed25519_key.pub"
|
|
||||||
"/etc/ssh/ssh_host_rsa_key"
|
|
||||||
"/etc/ssh/ssh_host_rsa_key.pub"
|
|
||||||
];
|
|
||||||
directories = [
|
|
||||||
"/etc/NetworkManager/system-connections"
|
|
||||||
"/etc/nixos"
|
|
||||||
"/var/lib/bluetooth"
|
|
||||||
"/var/lib/flatpak"
|
|
||||||
"/var/lib/lxd"
|
|
||||||
"/var/lib/nixos"
|
|
||||||
"/var/lib/systemd/coredump"
|
|
||||||
"/var/lib/systemd/timers"
|
|
||||||
"/var/lib/tailscale"
|
|
||||||
"/var/log"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
services.fwupd.enable = true;
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
{ pkgs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
environment.systemPackages = with pkgs; [
|
|
||||||
clonehero
|
|
||||||
heroic
|
|
||||||
mangohud
|
|
||||||
prismlauncher
|
|
||||||
steam-run
|
|
||||||
];
|
|
||||||
|
|
||||||
programs = {
|
|
||||||
steam = {
|
|
||||||
enable = true;
|
|
||||||
extraCompatPackages = [ pkgs.proton-ge-bin ];
|
|
||||||
};
|
|
||||||
gamemode.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
hardware = {
|
|
||||||
xpadneo.enable = true;
|
|
||||||
steam-hardware.enable = true; # Allow steam client to manage controllers
|
|
||||||
graphics.enable32Bit = true; # For OpenGL games
|
|
||||||
};
|
|
||||||
|
|
||||||
services.flatpak.packages = [
|
|
||||||
"com.github.k4zmu2a.spacecadetpinball"
|
|
||||||
"com.steamgriddb.SGDBoop"
|
|
||||||
"io.github.Foldex.AdwSteamGtk"
|
|
||||||
"io.itch.itch"
|
|
||||||
"io.mrarm.mcpelauncher"
|
|
||||||
"net.retrodeck.retrodeck"
|
|
||||||
"org.freedesktop.Platform.VulkanLayer.MangoHud/x86_64/24.08"
|
|
||||||
];
|
|
||||||
}
|
|
||||||
41
hosts/modules/impermanence.nix
Normal file
41
hosts/modules/impermanence.nix
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
hostType,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = lib.mkMerge [
|
||||||
|
# Common configuration
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
# Server specific configuration
|
||||||
|
(lib.mkIf hostType.isServer {
|
||||||
|
})
|
||||||
|
|
||||||
|
# Workstation specific configuration
|
||||||
|
(lib.mkIf hostType.isWorkstation {
|
||||||
|
environment.persistence.main = {
|
||||||
|
persistentStoragePath = "/persistent";
|
||||||
|
files = [
|
||||||
|
"/etc/machine-id"
|
||||||
|
"/etc/ssh/ssh_host_ed25519_key"
|
||||||
|
"/etc/ssh/ssh_host_ed25519_key.pub"
|
||||||
|
"/etc/ssh/ssh_host_rsa_key"
|
||||||
|
"/etc/ssh/ssh_host_rsa_key.pub"
|
||||||
|
];
|
||||||
|
directories = [
|
||||||
|
"/etc/NetworkManager/system-connections"
|
||||||
|
"/var/lib/bluetooth"
|
||||||
|
"/var/lib/flatpak"
|
||||||
|
"/var/lib/nixos"
|
||||||
|
"/var/lib/systemd/coredump"
|
||||||
|
"/var/lib/systemd/timers"
|
||||||
|
"/var/lib/tailscale"
|
||||||
|
"/var/log"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
boot = {
|
boot = {
|
||||||
# TODO check if future kernel versions fix boot issue with systemd initrd with tpm
|
# TODO check if future kernel versions fix boot issue with systemd initrd with tpm
|
||||||
11
hosts/modules/io/default.nix
Normal file
11
hosts/modules/io/default.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./boot.nix
|
||||||
|
./ephermal.nix
|
||||||
|
./hardware-configuration.nix
|
||||||
|
./programs.nix
|
||||||
|
./services.nix
|
||||||
|
];
|
||||||
|
}
|
||||||
46
hosts/modules/io/ephermal.nix
Normal file
46
hosts/modules/io/ephermal.nix
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
boot.initrd.systemd.services.recreate-root = {
|
||||||
|
description = "Rolling over and creating new filesystem root";
|
||||||
|
requires = [ "initrd-root-device.target" ];
|
||||||
|
after = [
|
||||||
|
"local-fs-pre.target"
|
||||||
|
"initrd-root-device.target"
|
||||||
|
];
|
||||||
|
requiredBy = [ "initrd-root-fs.target" ];
|
||||||
|
before = [ "sysroot.mount" ];
|
||||||
|
unitConfig = {
|
||||||
|
AssertPathExists = "/etc/initrd-release";
|
||||||
|
DefaultDependencies = false;
|
||||||
|
};
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = true;
|
||||||
|
};
|
||||||
|
script = ''
|
||||||
|
mkdir /btrfs_tmp
|
||||||
|
mount /dev/disk/by-uuid/3638cea6-5503-43cc-aa4f-3d37ebedad2f /btrfs_tmp
|
||||||
|
if [[ -e /btrfs_tmp/@root ]]; then
|
||||||
|
mkdir -p /btrfs_tmp/old_roots
|
||||||
|
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/@root)" "+%Y-%m-%-d_%H:%M:%S")
|
||||||
|
mv /btrfs_tmp/@root "/btrfs_tmp/old_roots/$timestamp"
|
||||||
|
fi
|
||||||
|
|
||||||
|
delete_subvolume_recursively() {
|
||||||
|
IFS=$'\n'
|
||||||
|
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
|
||||||
|
delete_subvolume_recursively "/btrfs_tmp/$i"
|
||||||
|
done
|
||||||
|
btrfs subvolume delete "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do
|
||||||
|
delete_subvolume_recursively "$i"
|
||||||
|
done
|
||||||
|
|
||||||
|
btrfs subvolume create /btrfs_tmp/@root
|
||||||
|
umount /btrfs_tmp
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
88
hosts/modules/io/hardware-configuration.nix
Normal file
88
hosts/modules/io/hardware-configuration.nix
Normal file
|
|
@ -0,0 +1,88 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
modulesPath,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
|
||||||
|
|
||||||
|
boot = {
|
||||||
|
initrd = {
|
||||||
|
availableKernelModules = [
|
||||||
|
"xhci_pci"
|
||||||
|
"ahci"
|
||||||
|
"usb_storage"
|
||||||
|
"sd_mod"
|
||||||
|
"sdhci_pci"
|
||||||
|
];
|
||||||
|
luks.devices."enc" = {
|
||||||
|
device = "/dev/disk/by-uuid/8018720e-42dd-453c-b374-adaa02eb48c9";
|
||||||
|
keyFile = "/dev/disk/by-partuuid/cbc7e305-d32d-4250-b6ae-6a8264ea096e";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
kernelModules = [ "kvm-intel" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems = {
|
||||||
|
"/" = {
|
||||||
|
device = "/dev/disk/by-uuid/3638cea6-5503-43cc-aa4f-3d37ebedad2f";
|
||||||
|
fsType = "btrfs";
|
||||||
|
options = [
|
||||||
|
"subvol=@root"
|
||||||
|
"noatime"
|
||||||
|
"compress=zstd"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
"/home" = {
|
||||||
|
device = "/dev/disk/by-uuid/3638cea6-5503-43cc-aa4f-3d37ebedad2f";
|
||||||
|
fsType = "btrfs";
|
||||||
|
options = [
|
||||||
|
"subvol=@home"
|
||||||
|
"noatime"
|
||||||
|
"compress=zstd"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
"/nix" = {
|
||||||
|
device = "/dev/disk/by-uuid/3638cea6-5503-43cc-aa4f-3d37ebedad2f";
|
||||||
|
fsType = "btrfs";
|
||||||
|
options = [
|
||||||
|
"subvol=@nix"
|
||||||
|
"noatime"
|
||||||
|
"compress=zstd"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
"/persistent" = {
|
||||||
|
device = "/dev/disk/by-uuid/3638cea6-5503-43cc-aa4f-3d37ebedad2f";
|
||||||
|
fsType = "btrfs";
|
||||||
|
options = [
|
||||||
|
"subvol=@persistent"
|
||||||
|
"noatime"
|
||||||
|
"compress=zstd"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
"/boot/efi" = {
|
||||||
|
device = "/dev/disk/by-uuid/31C9-08FF";
|
||||||
|
fsType = "vfat";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"fmask=0077"
|
||||||
|
"dmask=0077"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
zramSwap = {
|
||||||
|
enable = true;
|
||||||
|
memoryPercent = 100;
|
||||||
|
};
|
||||||
|
|
||||||
|
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
|
||||||
|
|
||||||
|
networking.useDHCP = lib.mkDefault true;
|
||||||
|
|
||||||
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
|
|
||||||
|
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||||
|
}
|
||||||
|
|
@ -19,9 +19,19 @@ in
|
||||||
{
|
{
|
||||||
environment = {
|
environment = {
|
||||||
systemPackages = with pkgs; [
|
systemPackages = with pkgs; [
|
||||||
|
arduino-ide
|
||||||
|
esptool
|
||||||
|
# fritzing
|
||||||
maliit-keyboard
|
maliit-keyboard
|
||||||
sof-firmware
|
sof-firmware
|
||||||
];
|
];
|
||||||
sessionVariables.ALSA_CONFIG_UCM2 = "${cml-ucm-conf}/share/alsa/ucm2";
|
sessionVariables.ALSA_CONFIG_UCM2 = "${cml-ucm-conf}/share/alsa/ucm2";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# TODO: remove once gmodena/nix-flatpak/issues/45 fixed
|
||||||
|
systemd.services."flatpak-managed-install" = {
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStartPre = "${pkgs.coreutils}/bin/sleep 5";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
{ pkgs, ... }:
|
{ ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
services = {
|
services = {
|
||||||
|
|
@ -48,14 +48,5 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
upower.enable = true;
|
|
||||||
power-profiles-daemon.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
# TODO: remove once gmodena/nix-flatpak/issues/45 fixed
|
|
||||||
systemd.services."flatpak-managed-install" = {
|
|
||||||
serviceConfig = {
|
|
||||||
ExecStartPre = "${pkgs.coreutils}/bin/sleep 5";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
virtualisation.libvirtd.enable = true;
|
|
||||||
|
|
||||||
programs.virt-manager.enable = true;
|
|
||||||
|
|
||||||
users.users.user.extraGroups = [
|
|
||||||
"libvirt"
|
|
||||||
"libvirtd"
|
|
||||||
];
|
|
||||||
}
|
|
||||||
33
hosts/modules/locale.nix
Normal file
33
hosts/modules/locale.nix
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
{ hostType, lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = lib.mkMerge [
|
||||||
|
# Common configuration
|
||||||
|
{
|
||||||
|
time.timeZone = "America/Bahia";
|
||||||
|
|
||||||
|
i18n = {
|
||||||
|
defaultLocale = "en_US.UTF-8";
|
||||||
|
extraLocaleSettings = {
|
||||||
|
LC_ADDRESS = "pt_BR.utf8";
|
||||||
|
LC_IDENTIFICATION = "pt_BR.utf8";
|
||||||
|
LC_MEASUREMENT = "pt_BR.utf8";
|
||||||
|
LC_MONETARY = "pt_BR.utf8";
|
||||||
|
LC_NAME = "pt_BR.utf8";
|
||||||
|
LC_NUMERIC = "pt_BR.utf8";
|
||||||
|
LC_PAPER = "pt_BR.utf8";
|
||||||
|
LC_TELEPHONE = "pt_BR.utf8";
|
||||||
|
LC_TIME = "en_IE.utf8";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
# Server specific configuration
|
||||||
|
(lib.mkIf hostType.isServer {
|
||||||
|
})
|
||||||
|
|
||||||
|
# Workstation specific configuration
|
||||||
|
(lib.mkIf hostType.isWorkstation {
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
40
hosts/modules/networking.nix
Normal file
40
hosts/modules/networking.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
hostType,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = lib.mkMerge [
|
||||||
|
# Common configuration
|
||||||
|
{
|
||||||
|
networking = {
|
||||||
|
networkmanager.enable = true;
|
||||||
|
firewall.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
services = {
|
||||||
|
tailscale = {
|
||||||
|
enable = true;
|
||||||
|
extraUpFlags = [ "--operator=user" ];
|
||||||
|
};
|
||||||
|
openssh = {
|
||||||
|
enable = true;
|
||||||
|
settings.PermitRootLogin = "no";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
# Server specific configuration
|
||||||
|
(lib.mkIf hostType.isServer {
|
||||||
|
services.tailscale = {
|
||||||
|
extraSetFlags = [ "--advertise-exit-node" ];
|
||||||
|
useRoutingFeatures = "server";
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
||||||
|
# Workstation specific configuration
|
||||||
|
(lib.mkIf hostType.isWorkstation {
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
networking.networkmanager = {
|
|
||||||
enable = true;
|
|
||||||
wifi.backend = "iwd";
|
|
||||||
};
|
|
||||||
|
|
||||||
users.users.user.extraGroups = [ "networkmanager" ];
|
|
||||||
}
|
|
||||||
64
hosts/modules/nix.nix
Normal file
64
hosts/modules/nix.nix
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
{
|
||||||
|
inputs,
|
||||||
|
lib,
|
||||||
|
hostType,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = lib.mkMerge [
|
||||||
|
# Common configuration
|
||||||
|
{
|
||||||
|
nix = {
|
||||||
|
settings = {
|
||||||
|
auto-optimise-store = true;
|
||||||
|
connect-timeout = 10;
|
||||||
|
log-lines = 25;
|
||||||
|
min-free = 128000000;
|
||||||
|
max-free = 1000000000;
|
||||||
|
trusted-users = [ "@wheel" ];
|
||||||
|
};
|
||||||
|
extraOptions = "experimental-features = nix-command flakes";
|
||||||
|
gc = {
|
||||||
|
automatic = true;
|
||||||
|
options = "--delete-older-than 8d";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nixpkgs.config = {
|
||||||
|
allowUnfree = true;
|
||||||
|
enableParallelBuilding = true;
|
||||||
|
buildManPages = false;
|
||||||
|
buildDocs = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
system.stateVersion = "22.11";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Server specific configuration
|
||||||
|
(lib.mkIf hostType.isServer {
|
||||||
|
environment.etc."channels/nixpkgs".source = inputs.nixpkgs-stable.outPath;
|
||||||
|
|
||||||
|
nix = {
|
||||||
|
registry.nixpkgs.flake = inputs.nixpkgs-stable;
|
||||||
|
nixPath = [
|
||||||
|
"nixpkgs=/etc/channels/nixpkgs"
|
||||||
|
"/nix/var/nix/profiles/per-user/root/channels"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
||||||
|
# Workstation specific configuration
|
||||||
|
(lib.mkIf hostType.isWorkstation {
|
||||||
|
environment.etc."channels/nixpkgs".source = inputs.nixpkgs.outPath;
|
||||||
|
|
||||||
|
nix = {
|
||||||
|
registry.nixpkgs.flake = inputs.nixpkgs;
|
||||||
|
nixPath = [
|
||||||
|
"nixpkgs=${inputs.nixpkgs}"
|
||||||
|
"/nix/var/nix/profiles/per-user/root/channels"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
{ pkgs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
virtualisation.podman = {
|
|
||||||
enable = true;
|
|
||||||
autoPrune.enable = true;
|
|
||||||
extraPackages = [ pkgs.podman-compose ];
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd = {
|
|
||||||
services.podman-auto-update.enable = true;
|
|
||||||
timers.podman-auto-update.enable = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
164
hosts/modules/programs.nix
Normal file
164
hosts/modules/programs.nix
Normal file
|
|
@ -0,0 +1,164 @@
|
||||||
|
{
|
||||||
|
hostType,
|
||||||
|
inputs,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = lib.mkMerge [
|
||||||
|
# Common configuration
|
||||||
|
{
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
### Dev Tools ###
|
||||||
|
agenix
|
||||||
|
git
|
||||||
|
helix
|
||||||
|
### System Utilities ###
|
||||||
|
btop
|
||||||
|
fastfetch
|
||||||
|
nixos-firewall-tool
|
||||||
|
sysz
|
||||||
|
wget
|
||||||
|
tmux
|
||||||
|
];
|
||||||
|
|
||||||
|
programs = {
|
||||||
|
fish.enable = true;
|
||||||
|
command-not-found.enable = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
environment.shellAliases = {
|
||||||
|
ls = "${pkgs.eza}/bin/eza --icons --group-directories-first";
|
||||||
|
neofetch = "fastfetch";
|
||||||
|
tree = "ls --tree";
|
||||||
|
syscleanup = "sudo nix-collect-garbage -d; sudo /run/current-system/bin/switch-to-configuration boot";
|
||||||
|
};
|
||||||
|
|
||||||
|
services.flatpak.enable = lib.mkDefault false;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Server specific configuration
|
||||||
|
(lib.mkIf hostType.isServer {
|
||||||
|
})
|
||||||
|
|
||||||
|
# Workstation specific configuration
|
||||||
|
(lib.mkIf hostType.isWorkstation ({
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
### Dev Tools ###
|
||||||
|
bat
|
||||||
|
deploy-rs
|
||||||
|
fd
|
||||||
|
fzf
|
||||||
|
nixfmt-rfc-style
|
||||||
|
nix-init
|
||||||
|
nix-output-monitor
|
||||||
|
ripgrep
|
||||||
|
### Internet Browsers & Communication ###
|
||||||
|
beeper
|
||||||
|
brave
|
||||||
|
tor-browser
|
||||||
|
vesktop
|
||||||
|
### Office & Productivity ###
|
||||||
|
aspell
|
||||||
|
aspellDicts.de
|
||||||
|
aspellDicts.en
|
||||||
|
aspellDicts.en-computers
|
||||||
|
aspellDicts.pt_BR
|
||||||
|
libreoffice-qt
|
||||||
|
obsidian
|
||||||
|
(octaveFull.withPackages (octavePackages: with octavePackages; [ signal ]))
|
||||||
|
onlyoffice-desktopeditors
|
||||||
|
rnote
|
||||||
|
### Graphics & Design ###
|
||||||
|
gimp
|
||||||
|
inkscape
|
||||||
|
orca-slicer
|
||||||
|
plasticity
|
||||||
|
### Gaming & Entertainment ###
|
||||||
|
clonehero
|
||||||
|
heroic
|
||||||
|
mangohud
|
||||||
|
prismlauncher
|
||||||
|
### System Utilities ###
|
||||||
|
adwaita-icon-theme
|
||||||
|
junction
|
||||||
|
kara
|
||||||
|
kde-rounded-corners
|
||||||
|
libfido2
|
||||||
|
morewaita-icon-theme
|
||||||
|
nautilus
|
||||||
|
mission-center
|
||||||
|
p7zip
|
||||||
|
qbittorrent
|
||||||
|
quickemu
|
||||||
|
quickgui
|
||||||
|
rustdesk
|
||||||
|
steam-run
|
||||||
|
toggleaudiosink
|
||||||
|
unrar
|
||||||
|
### Media ###
|
||||||
|
mpv
|
||||||
|
obs-studio
|
||||||
|
qview
|
||||||
|
];
|
||||||
|
|
||||||
|
programs = {
|
||||||
|
adb.enable = true;
|
||||||
|
steam = {
|
||||||
|
enable = true;
|
||||||
|
extraCompatPackages = [ pkgs.proton-ge-bin ];
|
||||||
|
};
|
||||||
|
dconf.enable = true;
|
||||||
|
nix-ld.enable = true;
|
||||||
|
kdeconnect.enable = true;
|
||||||
|
partition-manager.enable = true;
|
||||||
|
gamemode.enable = true;
|
||||||
|
appimage = {
|
||||||
|
enable = true;
|
||||||
|
binfmt = true;
|
||||||
|
};
|
||||||
|
nh = {
|
||||||
|
enable = true;
|
||||||
|
flake = "/home/user/Projects/personal/nix-config";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
fonts = {
|
||||||
|
fontDir.enable = true;
|
||||||
|
packages = with pkgs; [
|
||||||
|
corefonts
|
||||||
|
inter
|
||||||
|
nerd-fonts.hack
|
||||||
|
noto-fonts-cjk-sans
|
||||||
|
roboto
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.flatpak = {
|
||||||
|
enable = true;
|
||||||
|
packages = [
|
||||||
|
### Dev Tools ###
|
||||||
|
### Internet Browsers & Communication ###
|
||||||
|
"app.zen_browser.zen"
|
||||||
|
### Office & Productivity ###
|
||||||
|
### Graphics & Design ###
|
||||||
|
"com.boxy_svg.BoxySVG"
|
||||||
|
### Gaming & Entertainment ###
|
||||||
|
"com.github.k4zmu2a.spacecadetpinball"
|
||||||
|
"io.itch.itch"
|
||||||
|
"io.mrarm.mcpelauncher"
|
||||||
|
"org.freedesktop.Platform.VulkanLayer.MangoHud/x86_64/24.08"
|
||||||
|
### System Utilities ###
|
||||||
|
"com.github.tchx84.Flatseal"
|
||||||
|
"io.github.Foldex.AdwSteamGtk"
|
||||||
|
"com.steamgriddb.SGDBoop"
|
||||||
|
### Media ###
|
||||||
|
];
|
||||||
|
uninstallUnmanaged = true;
|
||||||
|
update.auto.enable = true;
|
||||||
|
};
|
||||||
|
}))
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -12,7 +12,11 @@ in
|
||||||
kernelParams = [
|
kernelParams = [
|
||||||
"processor.max_cstate=1" # Fixes bug where ryzen cpus freeze when in highest C state
|
"processor.max_cstate=1" # Fixes bug where ryzen cpus freeze when in highest C state
|
||||||
"clearcpuid=514"
|
"clearcpuid=514"
|
||||||
"amdgpu.ppfeaturemask=0xfffd3fff" # Fixes amdgpu freezing
|
# Fixes amdgpu freezing
|
||||||
|
"amdgpu.noretry=0"
|
||||||
|
"amdgpu.ppfeaturemask=0xfffd3fff"
|
||||||
|
"amdgpu.gpu_recovery=1"
|
||||||
|
"amdgpu.lockup_timeout=1000"
|
||||||
];
|
];
|
||||||
# QubesOS boot entry
|
# QubesOS boot entry
|
||||||
loader.systemd-boot = {
|
loader.systemd-boot = {
|
||||||
12
hosts/modules/rotterdam/default.nix
Normal file
12
hosts/modules/rotterdam/default.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./boot.nix
|
||||||
|
./ephermal.nix
|
||||||
|
./hardware-configuration.nix
|
||||||
|
./hardware.nix
|
||||||
|
./programs.nix
|
||||||
|
./services.nix
|
||||||
|
];
|
||||||
|
}
|
||||||
47
hosts/modules/rotterdam/ephermal.nix
Normal file
47
hosts/modules/rotterdam/ephermal.nix
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
boot.initrd.systemd.services.recreate-root = {
|
||||||
|
description = "Rolling over and creating new filesystem root";
|
||||||
|
requires = [ "initrd-root-device.target" ];
|
||||||
|
after = [
|
||||||
|
"local-fs-pre.target"
|
||||||
|
"initrd-root-device.target"
|
||||||
|
];
|
||||||
|
requiredBy = [ "initrd-root-fs.target" ];
|
||||||
|
before = [ "sysroot.mount" ];
|
||||||
|
unitConfig = {
|
||||||
|
AssertPathExists = "/etc/initrd-release";
|
||||||
|
DefaultDependencies = false;
|
||||||
|
};
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = true;
|
||||||
|
};
|
||||||
|
script = ''
|
||||||
|
mkdir /btrfs_tmp
|
||||||
|
mount /dev/disk/by-uuid/3287dbc3-c0fa-4096-a0b3-59b017cfecc8 /btrfs_tmp
|
||||||
|
|
||||||
|
if [[ -e /btrfs_tmp/@root ]]; then
|
||||||
|
mkdir -p /btrfs_tmp/old_roots
|
||||||
|
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/@root)" "+%Y-%m-%-d_%H:%M:%S")
|
||||||
|
mv /btrfs_tmp/@root "/btrfs_tmp/old_roots/$timestamp"
|
||||||
|
fi
|
||||||
|
|
||||||
|
delete_subvolume_recursively() {
|
||||||
|
IFS=$'\n'
|
||||||
|
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
|
||||||
|
delete_subvolume_recursively "/btrfs_tmp/$i"
|
||||||
|
done
|
||||||
|
btrfs subvolume delete "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do
|
||||||
|
delete_subvolume_recursively "$i"
|
||||||
|
done
|
||||||
|
|
||||||
|
btrfs subvolume create /btrfs_tmp/@root
|
||||||
|
umount /btrfs_tmp
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,10 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
hardware = {
|
hardware = {
|
||||||
amdgpu.opencl.enable = true;
|
amdgpu = {
|
||||||
|
opencl.enable = true;
|
||||||
|
amdvlk.enable = true;
|
||||||
|
};
|
||||||
graphics.extraPackages = with pkgs; [ rocmPackages.clr.icd ];
|
graphics.extraPackages = with pkgs; [ rocmPackages.clr.icd ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -27,5 +27,7 @@ in
|
||||||
{
|
{
|
||||||
environment.systemPackages = [ reboot-into-qubes ];
|
environment.systemPackages = [ reboot-into-qubes ];
|
||||||
|
|
||||||
|
services.flatpak.packages = [ "net.retrodeck.retrodeck" ];
|
||||||
|
|
||||||
programs.steam.dedicatedServer.openFirewall = true;
|
programs.steam.dedicatedServer.openFirewall = true;
|
||||||
}
|
}
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
services.keyd = {
|
services.keyd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
26
hosts/modules/security.nix
Normal file
26
hosts/modules/security.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
{ hostType, lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = lib.mkMerge [
|
||||||
|
# Common configuration
|
||||||
|
{
|
||||||
|
security = {
|
||||||
|
unprivilegedUsernsClone = true; # Needed for rootless podman
|
||||||
|
sudo = {
|
||||||
|
wheelNeedsPassword = false;
|
||||||
|
extraConfig = ''
|
||||||
|
Defaults lecture = never
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
# Server specific configuration
|
||||||
|
(lib.mkIf hostType.isServer {
|
||||||
|
})
|
||||||
|
|
||||||
|
# Workstation specific configuration
|
||||||
|
(lib.mkIf hostType.isWorkstation {
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
{ pkgs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
boot.kernelPackages = pkgs.linuxPackages_hardened;
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
{ inputs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
environment.etc."channels/nixpkgs".source = inputs.nixpkgs-stable.outPath;
|
|
||||||
|
|
||||||
nix = {
|
|
||||||
registry.nixpkgs.flake = inputs.nixpkgs-stable;
|
|
||||||
nixPath = [
|
|
||||||
"nixpkgs=/etc/channels/nixpkgs"
|
|
||||||
"/nix/var/nix/profiles/per-user/root/channels"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
services.tailscale = {
|
|
||||||
extraSetFlags = [ "--advertise-exit-node" ];
|
|
||||||
useRoutingFeatures = "server";
|
|
||||||
};
|
|
||||||
|
|
||||||
boot.kernel.sysctl = {
|
|
||||||
"net.ipv4.ip_forward" = 1;
|
|
||||||
"net.ipv6.conf.all.forwarding" = 1;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
37
hosts/modules/services.nix
Normal file
37
hosts/modules/services.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
hostType,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = lib.mkMerge [
|
||||||
|
# Common configuration
|
||||||
|
{
|
||||||
|
services = {
|
||||||
|
fwupd.enable = true;
|
||||||
|
fstrim.enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
# Server specific configuration
|
||||||
|
(lib.mkIf hostType.isServer {
|
||||||
|
})
|
||||||
|
|
||||||
|
# Workstation specific configuration
|
||||||
|
(lib.mkIf hostType.isWorkstation {
|
||||||
|
services = {
|
||||||
|
printing.enable = true;
|
||||||
|
udev.packages = with pkgs; [ yubikey-personalization ];
|
||||||
|
keyd = {
|
||||||
|
enable = true;
|
||||||
|
keyboards.all = {
|
||||||
|
ids = [ "*" ];
|
||||||
|
settings.main.capslock = "overload(meta, esc)";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
9
hosts/modules/trantor/boot.nix
Normal file
9
hosts/modules/trantor/boot.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
boot = {
|
||||||
|
loader.efi.efiSysMountPoint = "/boot";
|
||||||
|
initrd.systemd.enable = true;
|
||||||
|
kernel.sysctl."net.ipv4.ip_forward" = 1;
|
||||||
|
};
|
||||||
|
}
|
||||||
10
hosts/modules/trantor/default.nix
Normal file
10
hosts/modules/trantor/default.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./boot.nix
|
||||||
|
./disko.nix
|
||||||
|
./hardware-configuration.nix
|
||||||
|
./networking.nix
|
||||||
|
];
|
||||||
|
}
|
||||||
32
hosts/modules/trantor/disko.nix
Normal file
32
hosts/modules/trantor/disko.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
{
|
||||||
|
disko.devices = {
|
||||||
|
disk = {
|
||||||
|
main = {
|
||||||
|
type = "disk";
|
||||||
|
device = "/dev/sda";
|
||||||
|
content = {
|
||||||
|
type = "gpt";
|
||||||
|
partitions = {
|
||||||
|
boot = {
|
||||||
|
size = "512M";
|
||||||
|
type = "EF00";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "vfat";
|
||||||
|
mountpoint = "/boot";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
root = {
|
||||||
|
size = "100%";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "ext4";
|
||||||
|
mountpoint = "/";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
27
hosts/modules/trantor/hardware-configuration.nix
Normal file
27
hosts/modules/trantor/hardware-configuration.nix
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
modulesPath,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
|
||||||
|
|
||||||
|
boot = {
|
||||||
|
kernelModules = [ ];
|
||||||
|
extraModulePackages = [ ];
|
||||||
|
initrd = {
|
||||||
|
availableKernelModules = [
|
||||||
|
"xhci_pci"
|
||||||
|
"virtio_pci"
|
||||||
|
"virtio_scsi"
|
||||||
|
"usbhid"
|
||||||
|
];
|
||||||
|
kernelModules = [ ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.useDHCP = lib.mkDefault true;
|
||||||
|
|
||||||
|
nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux";
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
networking = {
|
networking = {
|
||||||
firewall = {
|
firewall = {
|
||||||
82
hosts/modules/users.nix
Normal file
82
hosts/modules/users.nix
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
{
|
||||||
|
hostType,
|
||||||
|
inputs,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = lib.mkMerge [
|
||||||
|
# Common configuration
|
||||||
|
{
|
||||||
|
users.users = {
|
||||||
|
user = {
|
||||||
|
isNormalUser = true;
|
||||||
|
shell = pkgs.fish;
|
||||||
|
extraGroups = [
|
||||||
|
"networkmanager"
|
||||||
|
"docker"
|
||||||
|
"wheel"
|
||||||
|
];
|
||||||
|
openssh.authorizedKeys.keys = [
|
||||||
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA1v3+q3EaruiiStWjubEJWvtejam/r41uoOpCdwJtLL user@rotterdam"
|
||||||
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO3Y0PVpGfJHonqDS7qoCFhqzUvqGq9I9sax+F9e/5cs user@io"
|
||||||
|
];
|
||||||
|
hashedPassword = "$6$Pj7v/CpstyuWQQV0$cNujVDhfMBdwlGVEnnd8t71.kZPixbo0u25cd.874iaqLTH4V5fa1f98V5zGapjQCz5JyZmsR94xi00sUrntT0";
|
||||||
|
};
|
||||||
|
root = {
|
||||||
|
shell = pkgs.fish;
|
||||||
|
hashedPassword = "!";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
home-manager = {
|
||||||
|
useGlobalPkgs = true;
|
||||||
|
useUserPackages = true;
|
||||||
|
backupFileExtension = "bkp";
|
||||||
|
users = {
|
||||||
|
user = import ../../users/user.nix;
|
||||||
|
root = import ../../users/root.nix;
|
||||||
|
};
|
||||||
|
extraSpecialArgs = {
|
||||||
|
inherit hostType;
|
||||||
|
inherit inputs;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
# Server specific configuration
|
||||||
|
(lib.mkIf hostType.isServer {
|
||||||
|
})
|
||||||
|
|
||||||
|
# Workstation specific configuration
|
||||||
|
(lib.mkIf hostType.isWorkstation {
|
||||||
|
environment.sessionVariables = {
|
||||||
|
KDEHOME = "$XDG_CONFIG_HOME/kde4"; # Stops kde from placing a .kde4 folder in the home dir
|
||||||
|
NIXOS_OZONE_WL = "1"; # Forces chromium and most electron apps to run in wayland
|
||||||
|
};
|
||||||
|
|
||||||
|
users.users = {
|
||||||
|
user = {
|
||||||
|
description = "William";
|
||||||
|
uid = 1000;
|
||||||
|
extraGroups = [
|
||||||
|
"uaccess" # Needed for HID dev
|
||||||
|
"dialout" # Needed for arduino dev
|
||||||
|
"libvirt"
|
||||||
|
"libvirtd"
|
||||||
|
"adbusers"
|
||||||
|
"i2c"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
ewans = {
|
||||||
|
description = "Ewans";
|
||||||
|
isNormalUser = true;
|
||||||
|
uid = 1001;
|
||||||
|
hashedPassword = "$y$j9T$yHLUDvj6bDIP19dchU.aA/$OY4qeFNtx/GvI.VUYx4LapHiiVwi0MEvs8AT0HN7j58";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
38
hosts/modules/virtualisation.nix
Normal file
38
hosts/modules/virtualisation.nix
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
hostType,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = lib.mkMerge [
|
||||||
|
# Common configuration
|
||||||
|
{
|
||||||
|
virtualisation.podman = {
|
||||||
|
enable = true;
|
||||||
|
dockerCompat = true;
|
||||||
|
autoPrune.enable = true;
|
||||||
|
extraPackages = [ pkgs.podman-compose ];
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd = {
|
||||||
|
services.podman-auto-update.enable = true;
|
||||||
|
timers.podman-auto-update.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Server specific configuration
|
||||||
|
(lib.mkIf hostType.isServer {
|
||||||
|
})
|
||||||
|
|
||||||
|
# Workstation specific configuration
|
||||||
|
(lib.mkIf hostType.isWorkstation {
|
||||||
|
virtualisation = {
|
||||||
|
libvirtd.enable = true;
|
||||||
|
lxd.enable = true;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
12
hosts/rotterdam.nix
Normal file
12
hosts/rotterdam.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
networking.hostName = "rotterdam";
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
./modules/rotterdam
|
||||||
|
./modules
|
||||||
|
];
|
||||||
|
|
||||||
|
nix.nixPath = [ "nixos-config=${./rotterdam.nix}" ];
|
||||||
|
}
|
||||||
13
hosts/trantor.nix
Normal file
13
hosts/trantor.nix
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
networking.hostName = "trantor";
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
./modules/trantor
|
||||||
|
./modules
|
||||||
|
];
|
||||||
|
|
||||||
|
nix.nixPath = [ "nixos-config=${./trantor.nix}" ];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
boot = {
|
|
||||||
initrd.systemd.enable = true;
|
|
||||||
loader.efi.efiSysMountPoint = "/boot/efi";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
{ inputs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [ inputs.disko.nixosModules.default ];
|
|
||||||
|
|
||||||
disko.devices.disk.main = {
|
|
||||||
type = "disk";
|
|
||||||
device = "/dev/disk/by-id/scsi-360b207ed25d84372a95d1ecf842f8e20";
|
|
||||||
content = {
|
|
||||||
type = "gpt";
|
|
||||||
partitions = {
|
|
||||||
ESP = {
|
|
||||||
priority = 1;
|
|
||||||
name = "ESP";
|
|
||||||
start = "1MiB";
|
|
||||||
end = "512MiB";
|
|
||||||
type = "EF00";
|
|
||||||
content = {
|
|
||||||
type = "filesystem";
|
|
||||||
format = "vfat";
|
|
||||||
mountpoint = "/boot/efi";
|
|
||||||
mountOptions = [
|
|
||||||
"noatime"
|
|
||||||
"fmask=0077"
|
|
||||||
"dmask=0077"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
root = {
|
|
||||||
priority = 2;
|
|
||||||
name = "root";
|
|
||||||
size = "100%";
|
|
||||||
content = {
|
|
||||||
type = "btrfs";
|
|
||||||
extraArgs = [ "-f" ];
|
|
||||||
subvolumes = {
|
|
||||||
"@root" = {
|
|
||||||
mountpoint = "/";
|
|
||||||
mountOptions = [
|
|
||||||
"noatime"
|
|
||||||
"compress=zstd"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
"@nix" = {
|
|
||||||
mountpoint = "/nix";
|
|
||||||
mountOptions = [
|
|
||||||
"noatime"
|
|
||||||
"compress=zstd"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
"@persistent" = {
|
|
||||||
mountpoint = "/persistent";
|
|
||||||
mountOptions = [
|
|
||||||
"noatime"
|
|
||||||
"compress=zstd"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
{ config, pkgs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
services.fail2ban = {
|
|
||||||
enable = true;
|
|
||||||
maxretry = 5;
|
|
||||||
ignoreIP = [
|
|
||||||
"127.0.0.0/8"
|
|
||||||
"::1"
|
|
||||||
"10.0.0.0/8"
|
|
||||||
"172.16.0.0/12"
|
|
||||||
"192.168.0.0/16"
|
|
||||||
"100.64.0.0/10"
|
|
||||||
];
|
|
||||||
bantime = "1h";
|
|
||||||
bantime-increment = {
|
|
||||||
enable = true;
|
|
||||||
multipliers = "1 2 4 8 16 32 64";
|
|
||||||
maxtime = "10000h";
|
|
||||||
overalljails = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,72 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
inputs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
utils = import ../../utils.nix { inherit inputs lib; };
|
|
||||||
inherit (utils) mkNginxVHosts;
|
|
||||||
in
|
|
||||||
|
|
||||||
{
|
|
||||||
services = {
|
|
||||||
forgejo = {
|
|
||||||
enable = true;
|
|
||||||
settings = {
|
|
||||||
session.COOKIE_SECURE = true;
|
|
||||||
server = {
|
|
||||||
PROTOCOL = "http+unix";
|
|
||||||
DOMAIN = "git.baduhai.dev";
|
|
||||||
ROOT_URL = "https://git.baduhai.dev";
|
|
||||||
OFFLINE_MODE = true; # disable use of CDNs
|
|
||||||
SSH_DOMAIN = "git.baduhai.dev";
|
|
||||||
};
|
|
||||||
log.LEVEL = "Warn";
|
|
||||||
mailer.ENABLED = false;
|
|
||||||
actions.ENABLED = false;
|
|
||||||
service.DISABLE_REGISTRATION = true;
|
|
||||||
oauth2_client = {
|
|
||||||
ENABLE_AUTO_REGISTRATION = true;
|
|
||||||
UPDATE_AVATAR = true;
|
|
||||||
ACCOUNT_LINKING = "login";
|
|
||||||
USERNAME = "preferred_username";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
nginx.virtualHosts = mkNginxVHosts {
|
|
||||||
domains."git.baduhai.dev".locations."/".proxyPass =
|
|
||||||
"http://unix:${config.services.forgejo.settings.server.HTTP_ADDR}:/";
|
|
||||||
};
|
|
||||||
fail2ban.jails.forgejo = {
|
|
||||||
settings = {
|
|
||||||
enabled = true;
|
|
||||||
filter = "forgejo";
|
|
||||||
maxretry = 3;
|
|
||||||
findtime = "10m";
|
|
||||||
bantime = "1h";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
environment = {
|
|
||||||
etc."fail2ban/filter.d/forgejo.conf".text = ''
|
|
||||||
[Definition]
|
|
||||||
failregex = .*(Failed authentication attempt|invalid credentials|Attempted access of unknown user).* from <HOST>
|
|
||||||
ignoreregex =
|
|
||||||
journalmatch = _SYSTEMD_UNIT=forgejo.service
|
|
||||||
'';
|
|
||||||
|
|
||||||
persistence.main.directories = [
|
|
||||||
{
|
|
||||||
directory = config.services.forgejo.stateDir;
|
|
||||||
inherit (config.services.forgejo) user group;
|
|
||||||
mode = "0700";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
# Disable PrivateMounts to allow LoadCredential to work with bind-mounted directories
|
|
||||||
systemd.services.forgejo.serviceConfig.PrivateMounts = lib.mkForce false;
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
{
|
|
||||||
lib,
|
|
||||||
modulesPath,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
|
|
||||||
|
|
||||||
boot.initrd.availableKernelModules = [
|
|
||||||
"xhci_pci"
|
|
||||||
"virtio_pci"
|
|
||||||
"virtio_scsi"
|
|
||||||
"usbhid"
|
|
||||||
];
|
|
||||||
|
|
||||||
networking.useDHCP = lib.mkDefault true;
|
|
||||||
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux";
|
|
||||||
}
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
inputs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
utils = import ../../utils.nix { inherit inputs lib; };
|
|
||||||
inherit (utils) mkNginxVHosts services;
|
|
||||||
|
|
||||||
# Get all unique domains from shared services on trantor (host = "trantor")
|
|
||||||
localDomains = lib.unique (
|
|
||||||
map (s: s.domain) (lib.filter (s: s.host == "trantor") services)
|
|
||||||
);
|
|
||||||
|
|
||||||
# Generate ACME cert configs for all local domains
|
|
||||||
acmeCerts = lib.genAttrs localDomains (domain: {
|
|
||||||
group = "nginx";
|
|
||||||
});
|
|
||||||
in
|
|
||||||
|
|
||||||
{
|
|
||||||
security.acme = {
|
|
||||||
acceptTerms = true;
|
|
||||||
defaults = {
|
|
||||||
email = "baduhai@proton.me";
|
|
||||||
dnsResolver = "1.1.1.1:53";
|
|
||||||
dnsProvider = "cloudflare";
|
|
||||||
credentialsFile = config.age.secrets.cloudflare.path;
|
|
||||||
};
|
|
||||||
certs = acmeCerts;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.nginx = {
|
|
||||||
enable = true;
|
|
||||||
recommendedGzipSettings = true;
|
|
||||||
recommendedOptimisation = true;
|
|
||||||
recommendedProxySettings = true;
|
|
||||||
recommendedTlsSettings = true;
|
|
||||||
virtualHosts = {
|
|
||||||
"_" = {
|
|
||||||
default = true;
|
|
||||||
locations."/".return = "444";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
users.users.nginx.extraGroups = [ "acme" ];
|
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [
|
|
||||||
80
|
|
||||||
443
|
|
||||||
];
|
|
||||||
|
|
||||||
age.secrets.cloudflare = {
|
|
||||||
file = ../../secrets/cloudflare.age;
|
|
||||||
owner = "nginx";
|
|
||||||
group = "nginx";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
services = {
|
|
||||||
openssh = {
|
|
||||||
settings = {
|
|
||||||
PasswordAuthentication = false;
|
|
||||||
KbdInteractiveAuthentication = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
fail2ban.jails.sshd = {
|
|
||||||
settings = {
|
|
||||||
enabled = true;
|
|
||||||
port = "ssh";
|
|
||||||
filter = "sshd";
|
|
||||||
logpath = "/var/log/auth.log";
|
|
||||||
maxretry = 3;
|
|
||||||
findtime = "10m";
|
|
||||||
bantime = "1h";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
{ inputs, lib, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
utils = import ../../utils.nix { inherit inputs lib; };
|
|
||||||
in
|
|
||||||
|
|
||||||
{
|
|
||||||
services.unbound = {
|
|
||||||
enable = true;
|
|
||||||
enableRootTrustAnchor = true;
|
|
||||||
settings = {
|
|
||||||
server = {
|
|
||||||
interface = [
|
|
||||||
"0.0.0.0"
|
|
||||||
"::"
|
|
||||||
];
|
|
||||||
access-control = [
|
|
||||||
"127.0.0.0/8 allow"
|
|
||||||
"100.64.0.0/10 allow" # Tailscale CGNAT range
|
|
||||||
"::1/128 allow"
|
|
||||||
"fd7a:115c:a1e0::/48 allow" # Tailscale IPv6
|
|
||||||
];
|
|
||||||
|
|
||||||
num-threads = 2;
|
|
||||||
msg-cache-size = "50m";
|
|
||||||
rrset-cache-size = "100m";
|
|
||||||
cache-min-ttl = 300;
|
|
||||||
cache-max-ttl = 86400;
|
|
||||||
prefetch = true;
|
|
||||||
prefetch-key = true;
|
|
||||||
hide-identity = true;
|
|
||||||
hide-version = true;
|
|
||||||
so-rcvbuf = "1m";
|
|
||||||
so-sndbuf = "1m";
|
|
||||||
|
|
||||||
# Tailnet DNS records from shared services
|
|
||||||
local-zone = ''"baduhai.dev." transparent'';
|
|
||||||
local-data = map (e: ''"${e.domain}. IN A ${e.tailscaleIP}"'') utils.services;
|
|
||||||
};
|
|
||||||
|
|
||||||
forward-zone = [
|
|
||||||
{
|
|
||||||
name = ".";
|
|
||||||
forward-addr = [
|
|
||||||
"1.1.1.1@853#cloudflare-dns.com"
|
|
||||||
"1.0.0.1@853#cloudflare-dns.com"
|
|
||||||
];
|
|
||||||
forward-tls-upstream = true;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
networking.firewall = {
|
|
||||||
allowedTCPPorts = [ 53 ];
|
|
||||||
allowedUDPPorts = [ 53 ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,84 +0,0 @@
|
||||||
{ lib, config, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
cfg = config.ephemeral;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.ephemeral = {
|
|
||||||
enable = lib.mkEnableOption "ephemeral root with automatic rollback";
|
|
||||||
|
|
||||||
rootDevice = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
example = "/dev/mapper/cryptroot";
|
|
||||||
description = "Device path for the root btrfs filesystem";
|
|
||||||
};
|
|
||||||
|
|
||||||
rootSubvolume = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
example = "@root";
|
|
||||||
description = "Name of the root btrfs subvolume";
|
|
||||||
};
|
|
||||||
|
|
||||||
oldRootRetentionDays = lib.mkOption {
|
|
||||||
type = lib.types.int;
|
|
||||||
default = 30;
|
|
||||||
description = "Number of days to keep old root snapshots before deletion";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
|
||||||
boot.initrd.systemd.services.recreate-root = {
|
|
||||||
description = "Rolling over and creating new filesystem root";
|
|
||||||
requires = [ "initrd-root-device.target" ];
|
|
||||||
after = [
|
|
||||||
"local-fs-pre.target"
|
|
||||||
"initrd-root-device.target"
|
|
||||||
];
|
|
||||||
requiredBy = [ "initrd-root-fs.target" ];
|
|
||||||
before = [ "sysroot.mount" ];
|
|
||||||
unitConfig = {
|
|
||||||
AssertPathExists = "/etc/initrd-release";
|
|
||||||
DefaultDependencies = false;
|
|
||||||
};
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
RemainAfterExit = true;
|
|
||||||
};
|
|
||||||
script = ''
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
mkdir /btrfs_tmp
|
|
||||||
if ! mount ${cfg.rootDevice} /btrfs_tmp; then
|
|
||||||
echo "ERROR: Failed to mount ${cfg.rootDevice}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -e /btrfs_tmp/${cfg.rootSubvolume} ]]; then
|
|
||||||
mkdir -p /btrfs_tmp/old_roots
|
|
||||||
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/${cfg.rootSubvolume})" "+%Y-%m-%-d_%H:%M:%S")
|
|
||||||
mv /btrfs_tmp/${cfg.rootSubvolume} "/btrfs_tmp/old_roots/$timestamp"
|
|
||||||
fi
|
|
||||||
|
|
||||||
delete_subvolume_recursively() {
|
|
||||||
IFS=$'\n'
|
|
||||||
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
|
|
||||||
delete_subvolume_recursively "/btrfs_tmp/$i"
|
|
||||||
done
|
|
||||||
btrfs subvolume delete "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +${toString cfg.oldRootRetentionDays}); do
|
|
||||||
delete_subvolume_recursively "$i"
|
|
||||||
done
|
|
||||||
|
|
||||||
if ! btrfs subvolume create /btrfs_tmp/${cfg.rootSubvolume}; then
|
|
||||||
echo "ERROR: Failed to create subvolume ${cfg.rootSubvolume}"
|
|
||||||
umount /btrfs_tmp
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
umount /btrfs_tmp
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue