modularized stuff
This commit is contained in:
parent
95de139644
commit
046aa3d168
|
@ -1,11 +1,16 @@
|
|||
{ pkgs
|
||||
, ...
|
||||
}:
|
||||
{
|
||||
pkgs,
|
||||
inputs,
|
||||
modulesPath,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
./services/openssh.nix
|
||||
./services/misc.nix
|
||||
./modules/git.nix
|
||||
./modules/nix-settings.nix
|
||||
./modules/zfs.nix
|
||||
|
||||
(import ./modules/networking.nix { hostname = "server"; })
|
||||
(import ./modules/users.nix { main-user = "baritone"; })
|
||||
];
|
||||
|
||||
boot.loader = {
|
||||
|
@ -14,56 +19,6 @@
|
|||
timeout = 0;
|
||||
};
|
||||
|
||||
boot.zfs.devNodes = "/dev/disk/by-path";
|
||||
|
||||
nix.settings.experimental-features = ["nix-command" "flakes"];
|
||||
nix.gc = {
|
||||
automatic = true;
|
||||
options = "--delete-older-than 30d";
|
||||
};
|
||||
nix.optimise = {
|
||||
automatic = true;
|
||||
dates = ["05:00"];
|
||||
};
|
||||
|
||||
networking.hostName = "enis";
|
||||
networking.hostId = "2ead098f";
|
||||
networking.networkmanager.enable = true;
|
||||
networking.firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [];
|
||||
allowedUDPPorts = [];
|
||||
};
|
||||
|
||||
home-manager = {
|
||||
extraSpecialArgs = {inherit inputs;};
|
||||
users = {
|
||||
"enis" = import ./home.nix;
|
||||
};
|
||||
};
|
||||
|
||||
users.users."enis" = {
|
||||
isNormalUser = true;
|
||||
hashedPassword = import ./password.nix;
|
||||
extraGroups = [
|
||||
"networkmanager"
|
||||
"audio"
|
||||
"wheel"
|
||||
];
|
||||
|
||||
shell = pkgs.zsh;
|
||||
};
|
||||
|
||||
users.users."nixos" = {
|
||||
isNormalUser = true;
|
||||
initialPassword = "1234";
|
||||
extraGroups = ["wheel"];
|
||||
};
|
||||
|
||||
users.users.root = {
|
||||
initialPassword = "1234";
|
||||
};
|
||||
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
enableGlobalCompInit = true;
|
||||
|
@ -77,8 +32,6 @@
|
|||
curl
|
||||
git
|
||||
vim
|
||||
|
||||
zfs
|
||||
];
|
||||
|
||||
environment.variables = {
|
||||
|
@ -97,20 +50,5 @@
|
|||
programs.mtr.enable = true;
|
||||
programs.gnupg.agent.enable = true;
|
||||
|
||||
services.udev.enable = true;
|
||||
services.thermald.enable = true;
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings = {
|
||||
PasswordAuthentication = false;
|
||||
KbdInteractiveAuthentication = false;
|
||||
AllowUsers = null;
|
||||
PermitRootLogin = "no";
|
||||
};
|
||||
};
|
||||
|
||||
nix.settings.trusted-users = ["@wheel"];
|
||||
|
||||
system.stateVersion = "24.11";
|
||||
}
|
||||
|
|
6
home.nix
6
home.nix
|
@ -1,8 +1,8 @@
|
|||
{...}: {
|
||||
{username ? throw "no username provided" }: {...}: {
|
||||
imports = [];
|
||||
|
||||
home.username = "enis";
|
||||
home.homeDirectory = "/home/enis";
|
||||
home.username = username;
|
||||
home.homeDirectory = "/home/${username}";
|
||||
|
||||
programs.home-manager.enable = true;
|
||||
|
||||
|
|
6
modules/git.nix
Normal file
6
modules/git.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{config, ...}:
|
||||
{
|
||||
programs.git.config = {
|
||||
safe.directory = [ "/etc/nixos" ];
|
||||
};
|
||||
}
|
11
modules/networking.nix
Normal file
11
modules/networking.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{ hostname ? "server" }: {...}:
|
||||
{
|
||||
networking.hostName = hostname;
|
||||
networking.hostId = "2ead098f";
|
||||
networking.networkmanager.enable = true;
|
||||
networking.firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [ ];
|
||||
allowedUDPPorts = [ ];
|
||||
};
|
||||
}
|
12
modules/nix-settings.nix
Normal file
12
modules/nix-settings.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
{ ... }: {
|
||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||
nix.gc = {
|
||||
automatic = true;
|
||||
options = "--delete-older-than 30d";
|
||||
};
|
||||
nix.optimise = {
|
||||
automatic = true;
|
||||
dates = [ "05:00" ];
|
||||
};
|
||||
nix.settings.trusted-users = [ "@wheel" ];
|
||||
}
|
32
modules/users.nix
Normal file
32
modules/users.nix
Normal file
|
@ -0,0 +1,32 @@
|
|||
{ main-user ? throw "No main user" }: { pkgs, inputs, ... }: {
|
||||
home-manager = {
|
||||
extraSpecialArgs = { inherit inputs; };
|
||||
users = {
|
||||
${main-user} = (import ../home.nix { username = main-user; });
|
||||
};
|
||||
};
|
||||
|
||||
users.users.${main-user} = {
|
||||
isNormalUser = true;
|
||||
hashedPassword = import ../password.nix;
|
||||
extraGroups = [
|
||||
"networkmanager"
|
||||
"audio"
|
||||
"wheel"
|
||||
];
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIFhTExbc9m4dCK6676wGiA8zPjE0l/9Fz2yf0IKvUvg snorre@archlinux"
|
||||
];
|
||||
|
||||
shell = pkgs.zsh;
|
||||
};
|
||||
|
||||
users.users."nixos" = {
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "wheel" ];
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIFhTExbc9m4dCK6676wGiA8zPjE0l/9Fz2yf0IKvUvg snorre@archlinux"
|
||||
];
|
||||
};
|
||||
|
||||
}
|
7
modules/zfs.nix
Normal file
7
modules/zfs.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{ pkgs, ... }: {
|
||||
boot.zfs.devNodes = "/dev/disk/by-path";
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
zfs
|
||||
];
|
||||
}
|
4
services/misc.nix
Normal file
4
services/misc.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{ ... }: {
|
||||
services.udev.enable = true;
|
||||
services.thermald.enable = true;
|
||||
}
|
27
services/openssh.nix
Normal file
27
services/openssh.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{ ... }: {
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings = {
|
||||
PasswordAuthentication = false;
|
||||
KbdInteractiveAuthentication = false;
|
||||
AllowUsers = null;
|
||||
PermitRootLogin = "no";
|
||||
};
|
||||
banner = ''
|
||||
OI! THIS IS A REALLY PRIVATE SERVER
|
||||
IF YOU'RE NOT WHO I THINK YOU ARE THEN FOCK OFF!
|
||||
'';
|
||||
|
||||
hostKeys = [
|
||||
{
|
||||
bits = 4096;
|
||||
path = "/etc/ssh/ssh_host_rsa_key";
|
||||
type = "rsa";
|
||||
}
|
||||
{
|
||||
path = "/etc/ssh/ssh_host_ed25519_key";
|
||||
type = "ed25519";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue