Watch
0
1
Fork
You've already forked nixos-configuration
0

split server desktop, move stuff

This commit is contained in:
Vinzenz Schroeter 2023-09-11 19:16:26 +02:00
commit 5e9a74280e
19 changed files with 107 additions and 127 deletions

View file

@ -1,7 +0,0 @@
{lib, ...}: {
mkIfElse = p: yes: no:
lib.mkMerge [
(lib.mkIf p yes)
(lib.mkIf (!p) no)
];
}

View file

@ -1,14 +1,14 @@
{...}: {
imports = [
./modules
(import ./hardware "hetzner-vpn1")
./modules/server
(import ./modules/hardware "hetzner-vpn1")
];
config = {
my = {
desktop.enable = false;
server.enable = true;
};
users.users.root.openssh.authorizedKeys.keys = [
''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICdYqY3Y1/f1bsAi5Qfyr/UWuX9ixu96IeAlhoQaJkbf''
];

View file

@ -1,55 +0,0 @@
{
config,
pkgs,
...
}: let
cfg = config.my;
helpers = import ../helpers;
in {
imports = [
./home
./desktop
./i18n.nix
./nixpkgs.nix
];
config = {
networking = {
networkmanager.enable = true;
firewall.enable = true;
};
# Enable the OpenSSH daemon.
services.openssh = {
enable = true;
settings = {
# PermitRootLogin = "no"; # this is managed through authorized keys
PasswordAuthentication = false;
KbdInteractiveAuthentication = false;
};
};
systemd.extraConfig = ''
DefaultTimeoutStopSec=12s
'';
programs = {
zsh.enable = true;
git = {
enable = true;
package = pkgs.gitFull;
};
};
environment = {
pathsToLink = ["/share/zsh"];
systemPackages = with pkgs; [
lm_sensors
tldr
ncdu
];
};
};
}

View file

@ -7,8 +7,13 @@
cfg = config.my.desktop;
in {
imports = [
<home-manager/nixos>
./gnome.nix
./kde.nix
./i18n.nix
./nixpkgs.nix
./vinzenz.nix
./ronja.nix
];
options.my.desktop = {
@ -16,6 +21,9 @@ in {
};
config = lib.mkIf cfg.enable {
home-manager.useUserPackages = true;
home-manager.useGlobalPkgs = true;
services = {
# Enable the X11 windowing system / wayland depending on DE
xserver.enable = true;
@ -23,7 +31,15 @@ in {
# Enable CUPS to print documents.
printing.enable = true;
openssh.settings.PermitRootLogin = "no";
# Enable the OpenSSH daemon.
openssh = {
enable = true;
settings = {
PermitRootLogin = "no";
PasswordAuthentication = false;
KbdInteractiveAuthentication = false;
};
};
};
# Enable sound with pipewire.
@ -46,20 +62,48 @@ in {
};
# unblock kde connect / gsconnect
networking.firewall = {
allowedTCPPortRanges = [
{
# KDE Connect
from = 1714;
to = 1764;
}
];
allowedUDPPortRanges = [
{
# KDE Connect
from = 1714;
to = 1764;
}
networking = {
networkmanager.enable = true;
firewall.enable = true;
firewall = {
allowedTCPPortRanges = [
{
# KDE Connect
from = 1714;
to = 1764;
}
];
allowedUDPPortRanges = [
{
# KDE Connect
from = 1714;
to = 1764;
}
];
};
};
systemd.extraConfig = ''
DefaultTimeoutStopSec=12s
'';
programs = {
zsh.enable = true;
git = {
enable = true;
package = pkgs.gitFull;
};
};
environment = {
pathsToLink = ["/share/zsh"];
systemPackages = with pkgs; [
lm_sensors
tldr
ncdu
];
};
};

View file

@ -4,7 +4,9 @@
lib,
...
}: let
cfg = config.my.gnome;
desktopCfg = config.my.desktop;
cfg = desktopCfg.gnome;
applyGnomeUserSettings = {
home.packages = with pkgs; [
gnome.gpaste
@ -17,7 +19,7 @@
};
};
in {
options.my.gnome = {
options.my.desktop.gnome = {
enable = lib.mkEnableOption "gnome desktop";
};
@ -56,8 +58,8 @@ in {
];
home-manager.users = {
vinzenz = lib.mkIf config.my.home.vinzenz.enable applyGnomeUserSettings;
ronja = lib.mkIf config.my.home.ronja.enable applyGnomeUserSettings;
vinzenz = lib.mkIf desktopCfg.vinzenz.enable applyGnomeUserSettings;
ronja = lib.mkIf desktopCfg.ronja.enable applyGnomeUserSettings;
};
};
}

28
modules/desktop/i18n.nix Normal file
View file

@ -0,0 +1,28 @@
{...}: {
config = {
time.timeZone = "Europe/Berlin";
i18n = {
defaultLocale = "en_US.UTF-8";
extraLocaleSettings = {
LC_ADDRESS = "de_DE.UTF-8";
LC_IDENTIFICATION = "de_DE.UTF-8";
LC_MEASUREMENT = "de_DE.UTF-8";
LC_MONETARY = "de_DE.UTF-8";
LC_NAME = "de_DE.UTF-8";
LC_NUMERIC = "de_DE.UTF-8";
LC_PAPER = "de_DE.UTF-8";
LC_TELEPHONE = "de_DE.UTF-8";
LC_TIME = "de_DE.UTF-8";
};
};
services.xserver = {
# Configure keymap in X11
layout = "de";
xkbVariant = "";
};
# Configure console keymap
console.keyMap = "de";
};
}

View file

@ -4,7 +4,8 @@
lib,
...
}: let
cfg = config.my.kde;
desktopCfg = config.my.desktop;
cfg = desktopCfg.kde;
applyKdeUserSettings = {
home = {
@ -17,7 +18,7 @@
};
};
in {
options.my.kde = {
options.my.desktop.kde = {
enable = lib.mkEnableOption "KDE desktop";
};
@ -56,8 +57,8 @@ in {
};
home-manager.users = {
vinzenz = lib.mkIf config.my.home.vinzenz.enable applyKdeUserSettings;
ronja = lib.mkIf config.my.home.ronja.enable applyKdeUserSettings;
vinzenz = lib.mkIf desktopCfg.vinzenz.enable applyKdeUserSettings;
ronja = lib.mkIf desktopCfg.ronja.enable applyKdeUserSettings;
};
};
}

View file

@ -0,0 +1,21 @@
{...}: {
config = {
nixpkgs.config = {
allowUnfree = true;
permittedInsecurePackages = [
"electron-12.2.3"
];
};
system = {
stateVersion = "22.11";
# enable auto updates
autoUpgrade.enable = true;
};
nix.gc = {
automatic = true;
dates = "00:30";
};
};
}

127
modules/desktop/ronja.nix Normal file
View file

@ -0,0 +1,127 @@
{
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.my.desktop.ronja;
in {
options.my.desktop.ronja = {
enable = lib.mkEnableOption "user ronja";
};
config = lib.mkIf cfg.enable {
# Define user account
users.users.ronja = {
isNormalUser = true;
description = "Ronja Spiegelberg";
extraGroups = ["networkmanager" "wheel"];
shell = pkgs.zsh;
};
# home manager
home-manager.users.ronja = {
config,
pkgs,
...
}: {
home = {
username = "ronja";
homeDirectory = "/home/ronja";
stateVersion = "22.11";
sessionVariables = {
EDITOR = "nano";
};
packages = with pkgs; [
## Apps
steam
telegram-desktop
powerline
powerline-fonts
lutris
kdiff3
wineWowPackages.stagingFull
wineWowPackages.fonts
winetricks
(lutris.override {
extraPkgs = pkgs: [
# List package dependencies here
];
extraLibraries = pkgs: [
# List library dependencies here
];
})
];
file.".nanorc".text = ''
set linenumbers
set mouse
'';
};
programs = {
home-manager.enable = true;
firefox.enable = true;
command-not-found.enable = true;
dircolors.enable = true;
htop.enable = true;
zsh = {
enable = true;
enableSyntaxHighlighting = true;
enableAutosuggestions = true;
enableVteIntegration = true;
history = {
size = 10000;
path = "${config.xdg.dataHome}/zsh/history";
expireDuplicatesFirst = true;
};
oh-my-zsh = {
enable = true;
theme = "agnoster";
plugins = ["git" "sudo" "systemadmin"];
};
};
git = {
enable = true;
userName = "Ronja Spiegelberg";
userEmail = "ronja.spiegelberg@gmail.com";
extraConfig = {
pull.ff = "only";
init.defaultBranch = "main";
merge.tool = "kdiff3";
};
};
gh = {
enable = true;
enableGitCredentialHelper = true;
};
chromium = {
enable = true;
extensions = [
{
# ublock origin
id = "cjpalhdlnbpafiamejdnhcphjbkeiagm";
}
{
id = "dcpihecpambacapedldabdbpakmachpb";
updateUrl = "https://raw.githubusercontent.com/iamadamdev/bypass-paywalls-chrome/master/updates.xml";
}
];
};
};
};
};
}

232
modules/desktop/vinzenz.nix Normal file
View file

@ -0,0 +1,232 @@
{
config,
pkgs,
lib,
...
}: let
cfg = config.my.desktop.vinzenz;
in {
options.my.desktop.vinzenz = {
enable = lib.mkEnableOption "user vinzenz";
};
config = lib.mkIf cfg.enable {
# Define user account
users.users.vinzenz = {
isNormalUser = true;
description = "Vinzenz Schroeter";
extraGroups = ["networkmanager" "wheel"];
shell = pkgs.zsh;
};
# home manager
home-manager.users.vinzenz = {
config,
pkgs,
...
}: {
home = {
username = "vinzenz";
homeDirectory = "/home/vinzenz";
stateVersion = "22.11";
sessionVariables = {
EDITOR = "nano";
};
packages = with pkgs; [
keepassxc
steam
insync
telegram-desktop
simple-scan
wireguard-tools
element-desktop
etcher
iotop
radeontop
lsof
wirelesstools
powerline
powerline-fonts
thefuck
dotnet-sdk_7
jetbrains.rider
alejandra
arduino
uucp
screen
jetbrains.pycharm-professional
kdiff3
docker
wineWowPackages.stagingFull
wineWowPackages.fonts
winetricks
(lutris.override {
extraPkgs = pkgs: [
# List package dependencies here
];
extraLibraries = pkgs: [
# List library dependencies here
];
})
];
file.".nanorc".text = ''
set linenumbers
set mouse
'';
};
programs = {
home-manager.enable = true;
firefox.enable = true;
command-not-found.enable = true;
dircolors.enable = true;
fzf.enable = true;
htop.enable = true;
zsh = {
enable = true;
enableSyntaxHighlighting = true;
enableAutosuggestions = true;
enableVteIntegration = true;
initExtra = ''
eval "$(direnv hook zsh)";
eval $(thefuck --alias);
'';
shellAliases = {
my-apply = "sudo nixos-rebuild boot";
my-switch = "sudo nixos-rebuild switch";
my-update = "sudo nixos-rebuild boot --upgrade";
my-fmt = "alejandra .";
};
history = {
size = 10000;
path = "${config.xdg.dataHome}/zsh/history";
expireDuplicatesFirst = true;
};
oh-my-zsh = {
enable = true;
theme = "agnoster";
plugins = ["git" "sudo" "docker" "systemadmin" "thefuck"];
};
};
git = {
enable = true;
userName = "Vinzenz Schroeter";
userEmail = "vinzenz.f.s@gmail.com";
aliases = {
prettylog = "log --pretty=oneline --graph";
};
extraConfig = {
pull.ff = "only";
init.defaultBranch = "main";
merge.tool = "kdiff3";
push.autoSetupRemote = "true";
};
};
gh = {
enable = true;
enableGitCredentialHelper = true;
};
vscode = {
enable = true;
package = pkgs.vscodium;
enableUpdateCheck = false;
extensions = with pkgs; [
vscode-extensions.bbenoist.nix
vscode-extensions.ms-python.python
vscode-extensions.kamadorueda.alejandra
];
userSettings = {
"git.autofetch" = true;
"update.mode" = "none";
"editor.fontFamily" = "'Fira Code', 'Droid Sans Mono', 'monospace', monospace";
"editor.fontLigatures" = true;
"editor.formatOnSave" = true;
"editor.formatOnSaveMode" = "modificationsIfAvailable";
"editor.minimap.autohide" = true;
"diffEditor.diffAlgorithm" = "advanced";
"explorer.excludeGitIgnore" = true;
"workbench.startupEditor" = "readme";
"markdown.extension.tableFormatter.normalizeIndentation" = true;
"markdown.extension.toc.orderedList" = false;
"telemetry.telemetryLevel" = "off";
"redhat.telemetry.enabled" = false;
"workbench.enableExperiments" = false;
};
};
direnv = {
enable = true;
nix-direnv.enable = true;
};
chromium = {
enable = true;
extensions = [
{
# ublock origin
id = "cjpalhdlnbpafiamejdnhcphjbkeiagm";
}
{
id = "dcpihecpambacapedldabdbpakmachpb";
updateUrl = "https://raw.githubusercontent.com/iamadamdev/bypass-paywalls-chrome/master/updates.xml";
}
];
};
bottom = {
enable = true;
settings = {
# https://github.com/ClementTsang/bottom/blob/master/sample_configs/default_config.toml
};
};
exa = {
enable = true;
git = true;
icons = true;
enableAliases = true;
extraOptions = [
"--group-directories-first"
"--header"
];
};
# checked https://rycee.gitlab.io/home-manager/options.html until "programs.jq"
};
editorconfig = {
enable = true;
settings = {
"*" = {
charset = "utf-8";
end_of_line = "lf";
trim_trailing_whitespace = true;
insert_final_newline = true;
max_line_width = 120;
indent_style = "space";
indent_size = 4;
};
"*.nix" = {
indent_size = 2;
};
};
};
};
};
}

View file

@ -0,0 +1,33 @@
{
lib,
config,
...
}: let
isEnabled = config.my.hardware.common-desktop.enable;
in {
imports = [
];
options.my.hardware.common-desktop = {
enable = lib.mkEnableOption "common desktop hardware settings";
};
config = lib.mkIf isEnabled {
boot.loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.eno1.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp5s0.useDHCP = lib.mkDefault true;
hardware.enableRedistributableFirmware = true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
};
}

View file

@ -0,0 +1,32 @@
hostName: {
modulesPath,
lib,
...
}: {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
(builtins.toString ./. + "/${hostName}.nix")
./common-desktop.nix
];
config = {
networking.hostName = hostName;
boot.loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.eno1.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp5s0.useDHCP = lib.mkDefault true;
hardware.enableRedistributableFirmware = true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
};
}

View file

@ -0,0 +1,80 @@
{
lib,
modulesPath,
...
}: {
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.cleanTmpDir = true;
zramSwap.enable = true;
networking.domain = "";
boot.loader.grub = {
efiSupport = true;
efiInstallAsRemovable = true;
device = "nodev";
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/77CF-345D";
fsType = "vfat";
};
boot.initrd.availableKernelModules = ["ata_piix" "uhci_hcd" "xen_blkfront"];
boot.initrd.kernelModules = ["nvme"];
fileSystems."/" = {
device = "/dev/sda1";
fsType = "ext4";
};
# This file was populated at runtime with the networking
# details gathered from the active system.
networking = {
nameservers = [
"8.8.8.8"
];
defaultGateway = "172.31.1.1";
defaultGateway6 = {
address = "fe80::1";
interface = "eth0";
};
dhcpcd.enable = false;
usePredictableInterfaceNames = lib.mkForce false;
interfaces = {
eth0 = {
ipv4.addresses = [
{
address = "157.90.146.125";
prefixLength = 32;
}
];
ipv6.addresses = [
{
address = "2a01:4f8:c012:7137::1";
prefixLength = 64;
}
{
address = "fe80::9400:2ff:fe87:7fc9";
prefixLength = 64;
}
];
ipv4.routes = [
{
address = "172.31.1.1";
prefixLength = 32;
}
];
ipv6.routes = [
{
address = "fe80::1";
prefixLength = 128;
}
];
};
};
};
services.udev.extraRules = ''
ATTR{address}=="96:00:02:87:7f:c9", NAME="eth0"
'';
}

View file

@ -0,0 +1,32 @@
{...}: {
config = {
my.hardware.common-desktop.enable = true;
boot = {
initrd.availableKernelModules = ["xhci_pci" "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" "sdhci_pci"];
initrd.kernelModules = [];
kernelModules = ["kvm-intel"];
extraModulePackages = [];
loader.efi.efiSysMountPoint = "/boot/efi";
};
fileSystems = {
"/" = {
device = "/dev/disk/by-uuid/34cb86c4-8823-4785-9672-92ef0bcd5eaf";
fsType = "btrfs";
options = ["subvol=@"];
};
"/boot/efi" = {
device = "/dev/disk/by-uuid/2381-1CD2";
fsType = "vfat";
};
};
swapDevices = [
{device = "/dev/disk/by-uuid/f5932f70-60e4-4abe-b23d-2cab3c095c7d";}
];
hardware.cpu.intel.updateMicrocode = true;
};
}

View file

@ -0,0 +1,55 @@
{...}: {
config = {
my.hardware.common-desktop.enable = true;
boot = {
initrd.availableKernelModules = ["nvme" "xhci_pci" "ahci" "usbhid" "sd_mod"]; # "usb_storage"
initrd.kernelModules = [];
kernelModules = ["kvm-amd"];
extraModulePackages = [];
loader.efi.efiSysMountPoint = "/boot";
};
fileSystems = {
"/" = {
device = "/dev/disk/by-uuid/0e9c983a-e733-447e-8181-f41d6670c4b8";
fsType = "btrfs";
options = ["subvol=@"];
};
"/home" = {
device = "/dev/disk/by-uuid/0e9c983a-e733-447e-8181-f41d6670c4b8";
fsType = "btrfs";
options = ["subvol=@home"];
};
"/games" = {
device = "/dev/disk/by-uuid/0e9c983a-e733-447e-8181-f41d6670c4b8";
fsType = "btrfs";
options = ["subvol=@games"];
};
"/boot" = {
device = "/dev/disk/by-uuid/AF67-8F16";
fsType = "vfat";
};
"/mnt/nixos_btrfs_root" = {
# subvolume with id 5 is always the root volume
# this is convenient for managing the flat subvolume hierarchy
device = "/dev/disk/by-uuid/0e9c983a-e733-447e-8181-f41d6670c4b8";
fsType = "btrfs";
options = ["subvolid=5"];
};
"/mnt/ssd2" = {
device = "/dev/disk/by-uuid/6b2a647d-c68e-4c07-85bf-c9bfc5db7e8a";
fsType = "ext4";
};
};
swapDevices = [];
hardware.cpu.amd.updateMicrocode = true;
};
}

View file

@ -1,25 +0,0 @@
{
config,
pkgs,
lib,
...
}: let
cfg = config.my.home;
in {
imports =
[
./vinzenz.nix
./ronja.nix
# enable home manager
]
++ lib.optional (builtins.pathExists <home-manager/nixos>) <home-manager/nixos>;
options.my.home = {
enable = lib.mkEnableOption "my home management";
};
config = lib.mkIf cfg.enable {
home-manager.useUserPackages = true;
home-manager.useGlobalPkgs = true;
};
}

View file

@ -14,13 +14,25 @@ in {
config = lib.mkIf cfg.enable {
services = {
services.openssh.enable = true;
# Enable the OpenSSH daemon.
services.openssh = {
enable = true;
settings = {
# PermitRootLogin = "no"; # this is managed through authorized keys
PasswordAuthentication = false;
KbdInteractiveAuthentication = false;
};
};
};
programs = {
git.enable = true;
zsh.enable = true;
};
networking.firewall = {
enable = true;
allowedTCPPortRanges = [
{
# ssh
@ -29,5 +41,11 @@ in {
}
];
};
environment = {
systemPackages = with pkgs; [
ncdu
];
};
};
}

View file

@ -1,13 +1,16 @@
{...}: {
imports = [
./modules
(import ./hardware "vinzenz-lpt")
./modules/desktop
(import ./modules/hardware "vinzenz-lpt")
];
config = {
my = {
gnome.enable = true;
home.vinzenz.enable = true;
desktop = {
enable = true;
gnome.enable = true;
vinzenz.enable = true;
};
};
services.flatpak.enable = true;

View file

@ -1,13 +1,14 @@
{...}: {
imports = [
./modules
(import ./hardware "vinzenz-pc2")
(import ./modules/hardware "vinzenz-pc2")
];
config = {
my = {
kde.enable = true;
home = {
desktop = {
enable = true;
kde.enable = true;
vinzenz.enable = true;
ronja.enable = true;
};