From 87367dfc5f8d9992aaa156b9e894d16f4f42cfef Mon Sep 17 00:00:00 2001 From: thiloho <123883702+thiloho@users.noreply.github.com> Date: Sun, 2 Jul 2023 00:18:17 +0200 Subject: [PATCH] Add server configuration host --- flake.nix | 1 + nixos-configurations/laptop/default.nix | 3 + nixos-configurations/pc/default.nix | 1 + nixos-configurations/server/default.nix | 16 ++ nixos-configurations/shared-desktop.nix | 225 +++++++++++++++++++++++ nixos-configurations/shared.nix | 226 +----------------------- 6 files changed, 249 insertions(+), 223 deletions(-) create mode 100644 nixos-configurations/server/default.nix create mode 100644 nixos-configurations/shared-desktop.nix diff --git a/flake.nix b/flake.nix index 3e237ef..1bc4fde 100644 --- a/flake.nix +++ b/flake.nix @@ -25,6 +25,7 @@ in { pc = mkSystem ./nixos-configurations/pc; laptop = mkSystem ./nixos-configurations/laptop; + server = mkSystem ./nixos-configurations/server; }; }; } diff --git a/nixos-configurations/laptop/default.nix b/nixos-configurations/laptop/default.nix index 206f4f5..c17f8fb 100644 --- a/nixos-configurations/laptop/default.nix +++ b/nixos-configurations/laptop/default.nix @@ -3,6 +3,7 @@ { imports = [ ./hardware-configuration.nix + ../shared-desktop.nix ../shared.nix ]; @@ -24,5 +25,7 @@ key = "11BA77C2BDCEBF6A"; }; }; + home.stateVersion = "23.05"; }; + system.stateVersion = "23.05"; } diff --git a/nixos-configurations/pc/default.nix b/nixos-configurations/pc/default.nix index 5cb8098..28a53c8 100644 --- a/nixos-configurations/pc/default.nix +++ b/nixos-configurations/pc/default.nix @@ -3,6 +3,7 @@ { imports = [ ./hardware-configuration.nix + ../shared-desktop.nix ../shared.nix ]; diff --git a/nixos-configurations/server/default.nix b/nixos-configurations/server/default.nix new file mode 100644 index 0000000..9a6d340 --- /dev/null +++ b/nixos-configurations/server/default.nix @@ -0,0 +1,16 @@ +{ ... }: + +{ + imports = [ + ./hardware-configuration.nix + ../shared.nix + ]; + + networking.hostName = "server"; + + home-manager.users.thiloho = { pkgs, lib, ... }: { + home.stateVersion = "23.05"; + }; + system.stateVersion = "23.05"; +} + diff --git a/nixos-configurations/shared-desktop.nix b/nixos-configurations/shared-desktop.nix new file mode 100644 index 0000000..dcf5577 --- /dev/null +++ b/nixos-configurations/shared-desktop.nix @@ -0,0 +1,225 @@ +{ pkgs, ... }: + +{ + virtualisation.docker.enable = true; + + services = { + pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + jack.enable = true; + }; + }; + + hardware.opengl.enable = true; + + # Make swaylock work + security.pam.services.swaylock = {}; + + xdg.portal = { + enable = true; + extraPortals = with pkgs; [ + xdg-desktop-portal-wlr + xdg-desktop-portal-gtk + ]; + }; + + fonts = { + enableDefaultFonts = true; + fonts = with pkgs; [ + noto-fonts-cjk-sans + nerdfonts + ]; + }; + + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + pinentryFlavor = "gtk2"; + }; + + # Home manager configuration + home-manager.users.thiloho = { pkgs, lib, config, ... }: { + wayland.windowManager.sway = { + enable = true; + wrapperFeatures.gtk = true; + config = { + modifier = "Mod4"; + terminal = "alacritty"; + menu = '' + tofi-run --width "100%" --height "100%" --border-width 0 --outline-width 0 --padding-left "35%" --padding-top "35%" --result-spacing 25 --num-results 5 --font "monospace" --background-color "#000A" | xargs swaymsg exec -- + ''; + bars = [ + { command = "waybar"; } + ]; + keybindings = let + modifier = config.wayland.windowManager.sway.config.modifier; + in lib.mkOptionDefault { + "${modifier}+Shift+S" = ''exec grim -g "$(slurp)" - | swappy -f -''; + }; + }; + xwayland = false; + extraConfig = '' + default_border pixel 2 + default_floating_border pixel 2 + ''; + }; + programs = { + waybar = { + enable = true; + settings = [ + { + modules-left = [ "sway/workspaces" ]; + modules-center = [ "sway/window" ]; + modules-right = [ "user" "memory" "disk" "cpu" "clock" ]; + + user = { + format = "{user} - Uptime: {work_H}:{work_M}h"; + }; + + memory = { + format = "Memory: {used}GiB"; + }; + + disk = { + format = "Disk: {free}"; + }; + + cpu = { + format = "CPU: {usage}%"; + }; + + clock = { + interval = 60; + format = "{:%Y-%m-%d - %H:%M}"; + }; + } + ]; + style = '' + * { + border: none; + border-radius: 0; + font-size: 0.875rem; + } + + window#waybar { + background-color: #1a1a1a; + color: #e6e6e6; + } + + #workspaces button, #user, #memory, #disk, #cpu, #clock { + padding-top: 0.125rem; + padding-bottom: 0.125rem; + padding-left: 0.5rem; + padding-right: 0.5rem; + background-color: #262626; + border: 0.0625rem solid #404040; + } + ''; + }; + swaylock = { + enable = true; + settings = let + wallpaper = pkgs.callPackage ./wallpaper.nix {}; + in { + image = "${wallpaper}"; + }; + }; + bash = { + enable = true; + shellAliases = { + rbs = "sudo nixos-rebuild switch --flake ."; + off = "sudo systemctl poweroff"; + cleanup = "nix store optimise && nix-collect-garbage -d && sudo nix store optimise && sudo nix-collect-garbage -d"; + listboots = "nix profile history --profile /nix/var/nix/profiles/system"; + }; + }; + helix = { + enable = true; + settings = { + theme = "gruvbox_transparent"; + editor = { + line-number = "relative"; + cursorline = true; + cursor-shape = { + normal = "block"; + insert = "bar"; + select = "underline"; + }; + }; + editor.file-picker = { + hidden = false; + }; + }; + themes = { + gruvbox_transparent = { + "inherits" = "gruvbox"; + "ui.background" = "{}"; + }; + }; + }; + alacritty = { + enable = true; + settings = { + window.opacity = 0.75; + font.size = 11.00; + }; + }; + firefox.enable = true; + chromium = { + enable = true; + extensions = [ + { id = "mmbiohbmijkiimgcgijfomelgpmdiigb"; } + { id = "dhdgffkkebhmkfjojejmpbldmpobfkfo"; } + { id = "cjpalhdlnbpafiamejdnhcphjbkeiagm"; } + ]; + }; + git = { + enable = true; + userName = "thiloho"; + userEmail = "123883702+thiloho@users.noreply.github.com"; + signing = { + signByDefault = true; + }; + }; + }; + gtk = { + enable = true; + theme = { + package = pkgs.gnome.gnome-themes-extra; + name = "Adwaita-dark"; + }; + }; + home = { + sessionVariables = { + NIXOS_OZONE_WL = "1"; + EDITOR = "hx"; + }; + packages = with pkgs; [ + libreoffice + airshipper + prismlauncher + nil + rust-analyzer + marksman + nodePackages.typescript-language-server + nodePackages.svelte-language-server + nodePackages.vscode-langservers-extracted + postgresqlJitPackages.plpgsql_check + dconf + tofi + wl-clipboard + xdg-utils + slurp + grim + swappy + kooha + ventoy + lapce + tldr + ]; + }; + }; +} diff --git a/nixos-configurations/shared.nix b/nixos-configurations/shared.nix index c15e5c2..d74ae24 100644 --- a/nixos-configurations/shared.nix +++ b/nixos-configurations/shared.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ ... }: { boot.loader.systemd-boot.enable = true; @@ -12,230 +12,10 @@ networking.networkmanager.enable = true; - virtualisation.docker.enable = true; - - services = { - pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - jack.enable = true; - }; - }; - - hardware.opengl.enable = true; - - # Make swaylock work - security.pam.services.swaylock = {}; - - xdg.portal = { - enable = true; - extraPortals = with pkgs; [ - xdg-desktop-portal-wlr - xdg-desktop-portal-gtk - ]; - }; - - fonts = { - enableDefaultFonts = true; - fonts = with pkgs; [ - noto-fonts-cjk-sans - nerdfonts - ]; - }; - users.users.thiloho = { isNormalUser = true; extraGroups = [ "wheel" "networkmanager" "docker" ]; }; - - programs.gnupg.agent = { - enable = true; - enableSSHSupport = true; - pinentryFlavor = "gtk2"; - }; - - # Home manager configuration - home-manager.users.thiloho = { pkgs, lib, config, ... }: { - wayland.windowManager.sway = { - enable = true; - wrapperFeatures.gtk = true; - config = { - modifier = "Mod4"; - terminal = "alacritty"; - menu = '' - tofi-run --width "100%" --height "100%" --border-width 0 --outline-width 0 --padding-left "35%" --padding-top "35%" --result-spacing 25 --num-results 5 --font "monospace" --background-color "#000A" | xargs swaymsg exec -- - ''; - bars = [ - { command = "waybar"; } - ]; - keybindings = let - modifier = config.wayland.windowManager.sway.config.modifier; - in lib.mkOptionDefault { - "${modifier}+Shift+S" = ''exec grim -g "$(slurp)" - | swappy -f -''; - }; - }; - xwayland = false; - extraConfig = '' - default_border pixel 2 - default_floating_border pixel 2 - ''; - }; - programs = { - waybar = { - enable = true; - settings = [ - { - modules-left = [ "sway/workspaces" ]; - modules-center = [ "sway/window" ]; - modules-right = [ "user" "memory" "disk" "cpu" "clock" ]; - - user = { - format = "{user} - Uptime: {work_H}:{work_M}h"; - }; - - memory = { - format = "Memory: {used}GiB"; - }; - - disk = { - format = "Disk: {free}"; - }; - - cpu = { - format = "CPU: {usage}%"; - }; - - clock = { - interval = 60; - format = "{:%Y-%m-%d - %H:%M}"; - }; - } - ]; - style = '' - * { - border: none; - border-radius: 0; - font-size: 0.875rem; - } - - window#waybar { - background-color: #1a1a1a; - color: #e6e6e6; - } - - #workspaces button, #user, #memory, #disk, #cpu, #clock { - padding-top: 0.125rem; - padding-bottom: 0.125rem; - padding-left: 0.5rem; - padding-right: 0.5rem; - background-color: #262626; - border: 0.0625rem solid #404040; - } - ''; - }; - swaylock = { - enable = true; - settings = let - wallpaper = pkgs.callPackage ./wallpaper.nix {}; - in { - image = "${wallpaper}"; - }; - }; - bash = { - enable = true; - shellAliases = { - rbs = "sudo nixos-rebuild switch --flake ."; - off = "sudo systemctl poweroff"; - cleanup = "nix store optimise && nix-collect-garbage -d && sudo nix store optimise && sudo nix-collect-garbage -d"; - listboots = "nix profile history --profile /nix/var/nix/profiles/system"; - }; - }; - helix = { - enable = true; - settings = { - theme = "gruvbox_transparent"; - editor = { - line-number = "relative"; - cursorline = true; - cursor-shape = { - normal = "block"; - insert = "bar"; - select = "underline"; - }; - }; - editor.file-picker = { - hidden = false; - }; - }; - themes = { - gruvbox_transparent = { - "inherits" = "gruvbox"; - "ui.background" = "{}"; - }; - }; - }; - alacritty = { - enable = true; - settings = { - window.opacity = 0.75; - font.size = 11.00; - }; - }; - firefox.enable = true; - chromium = { - enable = true; - extensions = [ - { id = "mmbiohbmijkiimgcgijfomelgpmdiigb"; } - { id = "dhdgffkkebhmkfjojejmpbldmpobfkfo"; } - { id = "cjpalhdlnbpafiamejdnhcphjbkeiagm"; } - ]; - }; - git = { - enable = true; - userName = "thiloho"; - userEmail = "123883702+thiloho@users.noreply.github.com"; - signing = { - signByDefault = true; - }; - }; - }; - gtk = { - enable = true; - theme = { - package = pkgs.gnome.gnome-themes-extra; - name = "Adwaita-dark"; - }; - }; - home = { - sessionVariables = { - NIXOS_OZONE_WL = "1"; - EDITOR = "hx"; - }; - packages = with pkgs; [ - libreoffice - airshipper - prismlauncher - nil - rust-analyzer - marksman - nodePackages.typescript-language-server - nodePackages.svelte-language-server - nodePackages.vscode-langservers-extracted - postgresqlJitPackages.plpgsql_check - dconf - tofi - wl-clipboard - xdg-utils - slurp - grim - swappy - kooha - ventoy - lapce - tldr - ]; - }; - }; } + +