Self-host your own digital island

update template

+48
template/configuration.nix
···
+
{ pkgs, config, lib, ... }:
+
+
{
+
imports = [
+
./hardware-configuration.nix
+
];
+
+
nixpkgs.hostPlatform.system = "x86_64-linux";
+
nix.settings.experimental-features = [ "nix-command" "flakes" ];
+
system.stateVersion = "22.11";
+
+
services.openssh = {
+
enable = true;
+
settings.passwordAuthentication = false;
+
};
+
+
environment.systemPackages = with pkgs; [
+
git # for nix flakes
+
vim # for editing config files
+
];
+
+
users.users.root = {
+
initialHashedPassword = "";
+
users.users.root.openssh.authorizedKeys.keys = [
+
# "ssh-ed25519 <key> <name>"
+
];
+
};
+
+
# TODO replace this with domain
+
networking.domain = "example.org";
+
security.acme.acceptTerms = true;
+
+
eilean = {
+
# TODO replace these values
+
username = "user";
+
secretsDir = "/secrets";
+
serverIpv4 = "203.0.113.0";
+
serverIpv6 = "2001:DB8::/64";
+
publicInterface = "eth0";
+
+
# mailserver.enable = true;
+
# matrix.enable = true;
+
# turn.enable = true;
+
# mastodon.enable = true;
+
# gitea.enable = true;
+
# dns.enable = true;
+
};
+
}
-28
template/default.nix
···
-
{ pkgs, config, lib, ... }:
-
-
{
-
imports = [
-
./hardware-configuration.nix
-
];
-
-
eilean = {
-
# TODO replace these values
-
username = "user";
-
secretsDir = "/secrets";
-
serverIpv4 = "203.0.113.0";
-
serverIpv6 = "2001:DB8::/64";
-
publicInterface = "eth0";
-
-
mailserver.enable = true;
-
matrix.enable = true;
-
turn.enable = true;
-
mastodon.enable = true;
-
gitea.enable = true;
-
dns.enable = true;
-
};
-
-
# TODO replace this with domain
-
networking.domain = "example.org";
-
-
security.acme.acceptTerms = true;
-
}
+10 -24
template/flake.lock
···
"nodes": {
"eilean": {
"inputs": {
-
"nixpkgs": "nixpkgs"
+
"nixpkgs": [
+
"nixpkgs"
+
]
},
"locked": {
-
"lastModified": 1674648266,
-
"narHash": "sha256-8yQYToFU8mnz80bEs88zx+QSMYvv73FFAYxCvK3Br2M=",
+
"lastModified": 1677678055,
+
"narHash": "sha256-Sf+Hn8tMPudNu+MEWcPaGBs5mqg+b72nB520RTZlLmE=",
"owner": "RyanGibb",
"repo": "eilean-nix",
-
"rev": "804134e45a0ae1d161eeaf5a8ed441ac555ac82b",
+
"rev": "0b0a552480c78be16466c7b4b0e7d90de1862fd9",
"type": "github"
},
"original": {
···
},
"nixpkgs": {
"locked": {
-
"lastModified": 1667231093,
-
"narHash": "sha256-RERXruzBEBuf0c7OfZeX1hxEKB+PTCUNxWeB6C1jd8Y=",
-
"owner": "nixos",
-
"repo": "nixpkgs",
-
"rev": "d40fea9aeb8840fea0d377baa4b38e39b9582458",
-
"type": "github"
-
},
-
"original": {
+
"lastModified": 1677676435,
+
"narHash": "sha256-6FxdcmQr5JeZqsQvfinIMr0XcTyTuR7EXX0H3ANShpQ=",
"owner": "nixos",
-
"ref": "nixos-unstable",
"repo": "nixpkgs",
-
"type": "github"
-
}
-
},
-
"nixpkgs_2": {
-
"locked": {
-
"lastModified": 1674459583,
-
"narHash": "sha256-L0UZl/u2H3HGsrhN+by42c5kNYeKtdmJiPzIRvEVeiM=",
-
"owner": "nixos",
-
"repo": "nixpkgs",
-
"rev": "1b1f50645af2a70dc93eae18bfd88d330bfbcf7f",
+
"rev": "a08d6979dd7c82c4cef0dcc6ac45ab16051c1169",
"type": "github"
},
"original": {
···
"root": {
"inputs": {
"eilean": "eilean",
-
"nixpkgs": "nixpkgs_2"
+
"nixpkgs": "nixpkgs"
}
}
},
+9 -10
template/flake.nix
···
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
eilean.url ="github:RyanGibb/eilean-nix/main";
+
eilean.inputs.nixpkgs.follows = "nixpkgs";
};
-
outputs = { self, nixpkgs, eilean, ... }@inputs: rec {
-
nixosConfigurations.server =
-
let
-
system = "x86_64-linux";
-
in nixpkgs.lib.nixosSystem {
-
inherit system;
-
pkgs = import nixpkgs { inherit system; };
+
outputs = { self, nixpkgs, eilean, ... }@inputs:
+
let hostname = "eilean"; in
+
rec {
+
nixosConfigurations.${hostname} = nixpkgs.lib.nixosSystem {
+
system = null;
+
pkgs = null;
modules = [
-
./default.nix
+
./configuration.nix
eilean.nixosModules.default
{
-
networking.hostName = "server";
+
networking.hostName = hostname;
# pin nix command's nixpkgs flake to the system flake to avoid unnecessary downloads
nix.registry.nixpkgs.flake = nixpkgs;
-
system.stateVersion = "22.11";
# record git revision (can be queried with `nixos-version --json)
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;
}
-6
template/hardware-configuration.nix
···
-
-
# TODO generate this from `nixos-generate-config`
-
{
-
boot.loader.grub.device = "/dev/sda";
-
fileSystems."/" = { device = "/dev/sda1"; fsType = "ext4"; };
-
}