Skip to content

Commit 665c0d5

Browse files
authored
add current configuration nix files from nixOS on Hetzner
1 parent 16f7b03 commit 665c0d5

File tree

3 files changed

+213
-0
lines changed

3 files changed

+213
-0
lines changed

nixos/configuration.nix

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{ config, pkgs, bonfire-app, ... }:
2+
3+
{
4+
imports =
5+
[
6+
./hardware-configuration.nix
7+
];
8+
9+
nix.settings.experimental-features =["nix-command" "flakes"];
10+
11+
time.timeZone = "europe/london";
12+
13+
boot = {
14+
kernelPackages = pkgs.linuxPackages_6_1;
15+
supportedFilesystems = [ "btrfs"];
16+
17+
loader.grub = {
18+
enable = true;
19+
version = 2;
20+
forceInstall = true;
21+
device = "/dev/sda";
22+
};
23+
};
24+
25+
networking = {
26+
hostName = "nixos-vm";
27+
useDHCP = false;
28+
29+
interfaces = {
30+
eth0.useDHCP = true;
31+
};
32+
33+
firewall = {
34+
enable = true;
35+
allowedTCPPorts =[];
36+
allowedUDPPorts =[];
37+
};
38+
};
39+
40+
nix = {
41+
gc = {
42+
automatic = true;
43+
dates = "monthly";
44+
options = "--delete-older-than 30d";
45+
};
46+
};
47+
48+
environment.systemPackages = with pkgs; [
49+
git
50+
vim
51+
bonfire-app.packages.${pkgs.system}.default
52+
];
53+
54+
services.openssh = {
55+
enable = true;
56+
permitRootLogin = "yes";
57+
passwordAuthentication = false;
58+
};
59+
60+
services.fail2ban.enable = true;
61+
62+
users.users.root.openssh.authorizedKeys.keys = [
63+
"ssh-ed25519 <ssh-key-here>"
64+
];
65+
66+
services.postgresql = {
67+
enable = true;
68+
package = pkgs.postgresql_15;
69+
ensureDatabases = [ "bonfire" ];
70+
ensureUsers = [
71+
{
72+
name = "bonfire";
73+
}
74+
];
75+
authentication = ''
76+
local all all md5
77+
host all all 127.0.0.1/32 md5
78+
host all all ::1/128 md5
79+
'';
80+
};
81+
82+
systemd.services.bonfire = {
83+
description = "Bonfire federated social app";
84+
after = [ "network.target" "postgresql.service" ];
85+
wantedBy = [ "multi-user.target" ];
86+
environment = {
87+
DATABASE_URL = "postgresql://bonfire:bonfirepassword@localhost/bonfire";
88+
};
89+
serviceConfig = {
90+
ExecStart = "${bonfire-app.packages.${pkgs.system}.default}/bin/bonfire";
91+
Restart = "always";
92+
User = "bonfire";
93+
WorkingDirectory = "/var/lib/bonfire";
94+
};
95+
preStart = ''
96+
mkdir -p /var/lib/bonfire
97+
chown bonfire:bonfire /var/lib/bonfire
98+
'';
99+
};
100+
101+
users.users.bonfire = {
102+
isSystemUser = true;
103+
home = "/var/lib/bonfire";
104+
createHome = true;
105+
group = "bonfire";
106+
};
107+
users.groups.bonfire = {};
108+
109+
system.stateVersion = "23.11";
110+
}

nixos/configuration.nix.old

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{ config, pkgs, ... }:
2+
3+
{
4+
imports =
5+
[
6+
./hardware-configuration.nix
7+
];
8+
9+
nix.settings.experimental-features =["nix-command" "flakes"];
10+
11+
time.timeZone = "europe/london";
12+
13+
boot = {
14+
kernelPackages = pkgs.linuxPackages_6_1;
15+
supportedFilesystems = [ "btrfs"];
16+
17+
loader.grub = {
18+
enable = true;
19+
version = 2;
20+
forceInstall = true;
21+
device = "/dev/sda";
22+
};
23+
};
24+
25+
networking = {
26+
hostName = "nixos-vm";
27+
useDHCP = false;
28+
29+
interfaces = {
30+
eth0.useDHCP = true;
31+
};
32+
33+
firewall = {
34+
enable = true;
35+
allowedTCPPorts =[];
36+
allowedUDPPorts =[];
37+
};
38+
};
39+
40+
nix = {
41+
gc = {
42+
automatic = true;
43+
dates = "monthly";
44+
options = "--delete-older-than 30d";
45+
};
46+
};
47+
48+
environment.systemPackages = with pkgs; [
49+
git
50+
vim
51+
];
52+
53+
services.openssh = {
54+
enable = true;
55+
permitRootLogin = "yes";
56+
passwordAuthentication = false;
57+
};
58+
59+
services.fail2ban.enable = true;
60+
61+
users.users.root.openssh.authorizedKeys.keys = [
62+
"ssh-ed25519 <ssh key>"
63+
];
64+
65+
system.stateVersion = "23.11";
66+
}

nixos/hardware-configuration.nix

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Do not modify this file! It was generated by ‘nixos-generate-config’
2+
# and may be overwritten by future invocations. Please make changes
3+
# to /etc/nixos/configuration.nix instead.
4+
{ config, lib, pkgs, modulesPath, ... }:
5+
6+
{
7+
imports =
8+
[ (modulesPath + "/profiles/qemu-guest.nix")
9+
];
10+
11+
boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ];
12+
boot.initrd.kernelModules = [ ];
13+
boot.kernelModules = [ ];
14+
boot.extraModulePackages = [ ];
15+
16+
fileSystems."/" =
17+
{ device = "/dev/disk/by-uuid/a8cd745f-4e9f-4583-ab14-57e20123ad7d";
18+
fsType = "ext4";
19+
};
20+
21+
fileSystems."/boot" =
22+
{ device = "/dev/disk/by-uuid/AC2D-CE36";
23+
fsType = "vfat";
24+
options = [ "fmask=0077" "dmask=0077" ];
25+
};
26+
27+
swapDevices = [ ];
28+
29+
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
30+
# (the default) this is the recommended approach. When using systemd-networkd it's
31+
# still possible to use this option, but it's recommended to use it in conjunction
32+
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
33+
networking.useDHCP = lib.mkDefault true;
34+
# networking.interfaces.enp1s0.useDHCP = lib.mkDefault true;
35+
36+
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
37+
}

0 commit comments

Comments
 (0)