Skip to content

Commit 0ab4e7d

Browse files
committed
Add a README.md
1 parent f76523e commit 0ab4e7d

File tree

2 files changed

+167
-0
lines changed

2 files changed

+167
-0
lines changed

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<div align="center">
2+
<h1>my NixOS configurations.</h1>
3+
<p>This repo stores all my nix configurations. It is modular in terms of host machines, modules and users. The main branch should be regarded as a rolling release.</p>
4+
</div>
5+
6+
> [!NOTE]
7+
> Disk partitioning still needs to be done manually for each machine. I did not yet have the nerve to make this declarative.
8+
9+
# Setting up a new host
10+
To bootstrap a new machine with the configuration from withing the installer, follow the [official installation guide](https://nixos.wiki/wiki/NixOS_Installation_Guide) up to the *Create NixOS Config* section, or just:
11+
- make sure networking is working:
12+
```sh
13+
ping -c 2 papertoilet.com
14+
```
15+
- make sure all disks are correctly formatted and mounted:
16+
```sh
17+
lsblk -f
18+
```
19+
20+
Then, after nix flakes are enabled:
21+
```sh
22+
export NIX_CONFIG="experimental-features = nix-command flakes"
23+
```
24+
25+
clone this repo:
26+
```sh
27+
nix-shell -p git vim
28+
git clone https://github.com/inverted-tree/nixos-config.git /mnt/etc/nixos
29+
```
30+
31+
and generate the `hardware-configuration.nix`:
32+
```sh
33+
nixos-generate-config --root /mnt
34+
mkdir -p /mnt/etc/nixos/hosts/<newhostname>
35+
mv /mnt/etc/nixos/configuration.nix /mnt/etc/nixos/hardware-configuration.nix /mnt/etc/nixos/hosts/<newhostname>
36+
```
37+
38+
Adapt the generated config:
39+
```sh
40+
vim /mnt/etc/nixos/hosts/<newhostname>/configuration.nix
41+
```
42+
43+
it should look something like [the default template](./hosts/templates/default-configuration.nix):
44+
```nix
45+
{
46+
imports = [
47+
# The hardware-dependent options
48+
./hardware-configuration.nix
49+
# All (shared/non-specific) users
50+
../../users/iamgroot.nix
51+
# All custom modules
52+
../../modules/somemodule.nix
53+
];
54+
55+
nix.settings.experimental-features = [
56+
"nix-command"
57+
"flakes"
58+
];
59+
60+
...
61+
}
62+
```
63+
64+
and then install the OS wiht the flake:
65+
```sh
66+
nixos-install --flake /mnt/etc/nixos#<newhostname>
67+
```
68+
69+
Finally, set a root password and reboot.
70+
71+
---
72+
73+
> [!WARNING]
74+
> This repo mainly acts as a way to sync my configurations across host machines and make it easy to set up a new machine with minimal effort. Feel free to use my code and break your system.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# A default nixos configuration to build a new system from.
2+
{ config, lib, pkgs, ... }@args:
3+
let
4+
inherit (args) inputs;
5+
in
6+
{
7+
imports = [
8+
# The hardware-dependent options
9+
./hardware-configuration.nix
10+
# All (shared/non-specific) users
11+
../../users/lukas.nix
12+
# All custom modules
13+
];
14+
15+
nix.settings.experimental-features = [
16+
"nix-command"
17+
"flakes"
18+
];
19+
20+
time.timeZone = "Europe/Berlin";
21+
22+
boot = {
23+
loader.grub = {
24+
enable = true;
25+
zfsSupport = true;
26+
efiSupport = true;
27+
efiInstallAsRemovable = true;
28+
mirroredBoots = [
29+
{
30+
devices = [ "nodev" ];
31+
path = "/boot";
32+
}
33+
];
34+
};
35+
zfs.extraPools = [ "zpool" ];
36+
};
37+
38+
networking = {
39+
hostName = "<HOSTNAME>";
40+
hostId = "<SOME_RANDOM_8_CHARS>";
41+
networkmanager.enable = true;
42+
useDHCP = true;
43+
nameservers = [
44+
"1.1.1.1"
45+
"1.0.0.1"
46+
"100.100.100.100"
47+
];
48+
firewall = {
49+
allowedTCPPorts = [ ];
50+
allowedUDPPorts = [ ];
51+
};
52+
search = [ "tabby-crocodile.ts.net" ];
53+
};
54+
55+
i18n.defaultLocale = "en_US.UTF-8";
56+
console = {
57+
font = "Lat2-Terminus16";
58+
useXkbConfig = true;
59+
};
60+
61+
environment.systemPackages = with pkgs; [
62+
git
63+
tailscale
64+
tree
65+
vim
66+
];
67+
68+
services = {
69+
openssh = {
70+
enable = true;
71+
ports = [ 22 ];
72+
settings = {
73+
PasswordAuthentication = true;
74+
KbdInteractiveAuthentication = true;
75+
PermitRootLogin = "no";
76+
AllowUsers = [ "lukas" ];
77+
};
78+
};
79+
fail2ban = {
80+
enable = true;
81+
};
82+
envfs.enable = true;
83+
tailscale.enable = true;
84+
};
85+
86+
programs = {
87+
zsh.enable = true;
88+
neovim.enable = true;
89+
neovim.defaultEditor = true;
90+
};
91+
92+
system.stateVersion = "25.05";
93+
}

0 commit comments

Comments
 (0)