From 688acfe889b01c6d6ad1d18b6153033dec710133 Mon Sep 17 00:00:00 2001 From: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com> Date: Mon, 23 Jun 2025 09:09:26 +0200 Subject: [PATCH] chore: add a new host and make a few adjustments --- flake.nix | 2 +- .../configuration.nix | 33 +++++++++++ hosts/thegeneralist-central-mbp/default.nix | 30 ++++++++++ .../hardware-configuration.nix | 11 ++++ hosts/thegeneralist-central/configuration.nix | 46 ++++++++++----- hosts/thegeneralist-central/default.nix | 8 +-- .../hardware-configuration.nix | 32 +++++++++- hosts/thegeneralist-central/hostkey.age | Bin 0 -> 631 bytes modules/common/custom-options.nix | 16 +++-- modules/common/ghostty.nix | 55 +++++++++--------- modules/common/packages.nix | 4 ++ modules/linux/networking.nix | 4 +- modules/linux/nvidia.nix | 2 +- modules/linux/packages.nix | 13 ++--- modules/linux/steam.nix | 2 +- secrets.nix | 2 + 16 files changed, 195 insertions(+), 65 deletions(-) create mode 100644 hosts/thegeneralist-central-mbp/configuration.nix create mode 100644 hosts/thegeneralist-central-mbp/default.nix create mode 100644 hosts/thegeneralist-central-mbp/hardware-configuration.nix create mode 100644 hosts/thegeneralist-central/hostkey.age diff --git a/flake.nix b/flake.nix index 21579dd..22b39b4 100644 --- a/flake.nix +++ b/flake.nix @@ -38,7 +38,7 @@ |> mapAttrs (name: const <| import ./hosts/${name} lib inputs self) |> attrsToList |> groupBy (host: - if host.name == "thegeneralist" then + if host.name == "thegeneralist" || host.name == "thegeneralist-central" then "nixosConfigurations" else "darwinConfigurations") diff --git a/hosts/thegeneralist-central-mbp/configuration.nix b/hosts/thegeneralist-central-mbp/configuration.nix new file mode 100644 index 0000000..260df04 --- /dev/null +++ b/hosts/thegeneralist-central-mbp/configuration.nix @@ -0,0 +1,33 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). + +{ self, config, pkgs, lib, inputs, ... }: + +{ + imports = [ ./hardware-configuration.nix ./jellyfin.nix ]; + + users.knownUsers = [ + "central" + ]; + + users.users.central = { + name = "central"; + home = "/Users/central"; + shell = pkgs.zsh; + uid = 502; + openssh.authorizedKeys.keys = let + inherit (import ../../keys.nix) thegeneralist; + in [ thegeneralist ]; + }; + + home-manager = { + backupFileExtension = "home.bak"; + users.central.home = { + stateVersion = "25.11"; + homeDirectory = "/Users/central"; + }; + }; + + system.stateVersion = 6; +} diff --git a/hosts/thegeneralist-central-mbp/default.nix b/hosts/thegeneralist-central-mbp/default.nix new file mode 100644 index 0000000..1d90efc --- /dev/null +++ b/hosts/thegeneralist-central-mbp/default.nix @@ -0,0 +1,30 @@ +lib: inputs: self: lib.darwinSystem { + specialArgs = inputs // { inherit inputs; inherit self; }; + modules = [ + # Extensions: nixosModules, darwinModules, overlays + ({ pkgs, lib, inputs, ... }: let + inherit (lib) attrValues hasAttrByPath getAttrFromPath filter; + + collect = packagePath: (attrValues inputs) + |> filter (hasAttrByPath packagePath) + |> map (getAttrFromPath packagePath); + + modules = collect [ "darwinModules" "default" ]; + extensions = { + nixpkgs.overlays = collect [ "overlays" "default" ]; + imports = modules; + }; + in extensions) + + ./configuration.nix + + # Modules + ({ pkgs, ... }: let + inherit (lib) filter hasSuffix; + commonModules = lib.filesystem.listFilesRecursive ../../modules/common |> filter (hasSuffix ".nix"); + darwinModules = lib.filesystem.listFilesRecursive ../../modules/darwin |> filter (hasSuffix ".nix"); + in { + imports = commonModules ++ darwinModules; + }) + ]; +} diff --git a/hosts/thegeneralist-central-mbp/hardware-configuration.nix b/hosts/thegeneralist-central-mbp/hardware-configuration.nix new file mode 100644 index 0000000..bdd1ed5 --- /dev/null +++ b/hosts/thegeneralist-central-mbp/hardware-configuration.nix @@ -0,0 +1,11 @@ +{ lib, ... }: + +{ + # 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..useDHCP`. + # networking.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "aarch64-darwin"; +} diff --git a/hosts/thegeneralist-central/configuration.nix b/hosts/thegeneralist-central/configuration.nix index 260df04..703a248 100644 --- a/hosts/thegeneralist-central/configuration.nix +++ b/hosts/thegeneralist-central/configuration.nix @@ -5,17 +5,14 @@ { self, config, pkgs, lib, inputs, ... }: { - imports = [ ./hardware-configuration.nix ./jellyfin.nix ]; + imports = [ ./hardware-configuration.nix ]; - users.knownUsers = [ - "central" - ]; - - users.users.central = { - name = "central"; - home = "/Users/central"; + users.users.thegeneralist = { + isNormalUser = true; + description = "thegeneralist"; + extraGroups = [ "wheel" "audio" "video" "input" "scanner" ]; shell = pkgs.zsh; - uid = 502; + home = "/home/thegeneralist"; openssh.authorizedKeys.keys = let inherit (import ../../keys.nix) thegeneralist; in [ thegeneralist ]; @@ -23,11 +20,34 @@ home-manager = { backupFileExtension = "home.bak"; - users.central.home = { - stateVersion = "25.11"; - homeDirectory = "/Users/central"; + extraSpecialArgs = { inherit inputs; }; + users = { + thegeneralist = import (self + /modules/home); }; }; - system.stateVersion = 6; + age.secrets.hostkey.file = ./hostkey.age; + services.openssh.hostKeys = [{ + type = "ed25519"; + path = config.age.secrets.hostkey.path; + }]; + + # Some programs + services.libinput.enable = true; + programs.firefox.enable = true; + programs.zsh.enable = true; + + # Set your time zone. + time.timeZone = "Europe/Berlin"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + # console = { + # font = "Lat2-Terminus16"; + # keyMap = "us"; + # useXkbConfig = true; # use xkb.options in tty. + # }; + + system.stateVersion = "24.11"; } + diff --git a/hosts/thegeneralist-central/default.nix b/hosts/thegeneralist-central/default.nix index 1d90efc..2fa7865 100644 --- a/hosts/thegeneralist-central/default.nix +++ b/hosts/thegeneralist-central/default.nix @@ -1,4 +1,4 @@ -lib: inputs: self: lib.darwinSystem { +lib: inputs: self: lib.nixosSystem { specialArgs = inputs // { inherit inputs; inherit self; }; modules = [ # Extensions: nixosModules, darwinModules, overlays @@ -9,7 +9,7 @@ lib: inputs: self: lib.darwinSystem { |> filter (hasAttrByPath packagePath) |> map (getAttrFromPath packagePath); - modules = collect [ "darwinModules" "default" ]; + modules = collect [ "nixosModules" "default" ]; extensions = { nixpkgs.overlays = collect [ "overlays" "default" ]; imports = modules; @@ -22,9 +22,9 @@ lib: inputs: self: lib.darwinSystem { ({ pkgs, ... }: let inherit (lib) filter hasSuffix; commonModules = lib.filesystem.listFilesRecursive ../../modules/common |> filter (hasSuffix ".nix"); - darwinModules = lib.filesystem.listFilesRecursive ../../modules/darwin |> filter (hasSuffix ".nix"); + linuxModules = lib.filesystem.listFilesRecursive ../../modules/linux |> filter (hasSuffix ".nix"); in { - imports = commonModules ++ darwinModules; + imports = commonModules ++ linuxModules; }) ]; } diff --git a/hosts/thegeneralist-central/hardware-configuration.nix b/hosts/thegeneralist-central/hardware-configuration.nix index bdd1ed5..ae40e94 100644 --- a/hosts/thegeneralist-central/hardware-configuration.nix +++ b/hosts/thegeneralist-central/hardware-configuration.nix @@ -1,11 +1,37 @@ -{ lib, ... }: +{ config, lib, pkgs, modulesPath, ... }: { + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + + # Wi-Fi stuff + nixpkgs.config.allowUnfree = true; + hardware.enableAllFirmware = true; + + fileSystems."/" = + { + device = "/dev/disk/by-label/NIXROOT"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { + device = "/dev/disk/by-label/NIXBOOT"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; + + swapDevices = [{ + device = "/dev/disk/by-label/swap"; + }]; + # 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..useDHCP`. - # networking.useDHCP = lib.mkDefault true; + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp4s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp0s20f0u5.useDHCP = lib.mkDefault true; - nixpkgs.hostPlatform = lib.mkDefault "aarch64-darwin"; + nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux"; } diff --git a/hosts/thegeneralist-central/hostkey.age b/hosts/thegeneralist-central/hostkey.age new file mode 100644 index 0000000000000000000000000000000000000000..093a311c62d1296bebd37b2575e10186536541a8 GIT binary patch literal 631 zcmYdHPt{G$OD?J`D9Oyv)5|YP*Do{V(zR14F3!+RO))YxHMCSHD6lL{2~;Td^>z2j zP4Y9>cFwCP2=Yu!Pt*=@4f6Lbba4p|2?;bXDex;!2`lh(G~x2}C`hs__mA>*Eln}Z zit!44)m11mEi-Tn@-;U0Ep#q*4T?-N z^U5v@&#Edm(k}P5h)T{0$p|YC$nmT24CHd%{);g*RMpAj&hFC+Cw%|4u(`$5$M&j7 zJ$v}iFwNx)e^RM#*9B*tGTmEyOrjH)e19nO+VJLPa|6#S&1Y|_)NEY%<|p$N4ufaM zf+ruCmbBKwB4nq@wP*VlwJKcCe*D%fTs`9Xr};-m9`){izyW5UG46_0xj?^2gN6 zwI9~1te>2!E_yus4x7yDYL)8a>8}ns3%Z(_mhL=sdzMp8+^$(nr}r&YVSjwvbRXZ_ z>cw2Mf8Oxh^Z)#&PP6lmkMrL1UA(3DwT6oE{F7{g;q2!w=kF>$r0eyv=JnjAIXC*4 zc5>$kxJI%S&H2rQT!yVz%aVRQj%6;W`b!=5+aec$W0KYp2&K45k^UBF|~^X&^Fw2%Iuwczx;r3POoUGy;UUvZ290QDCjVE_OC literal 0 HcmV?d00001 diff --git a/modules/common/custom-options.nix b/modules/common/custom-options.nix index 05b94b1..ba8252c 100644 --- a/modules/common/custom-options.nix +++ b/modules/common/custom-options.nix @@ -1,11 +1,17 @@ -{ lib, pkgs, ... }: - -{ +{ config, lib, pkgs, ... }: let + inherit (lib) mkOption types; +in { options = { - onLinux = lib.mkOption { - type = lib.types.bool; + onLinux = mkOption { + type = types.bool; default = pkgs.stdenv.isLinux; description = "Whether the system is running on Linux"; }; + + isServer = mkOption { + type = types.bool; + default = config.nixpkgs.hostPlatform.isAarch64; + description = "Whether the system is a server. Determined by the processor architecture."; + }; }; } diff --git a/modules/common/ghostty.nix b/modules/common/ghostty.nix index 358936a..f60fdb8 100644 --- a/modules/common/ghostty.nix +++ b/modules/common/ghostty.nix @@ -1,30 +1,29 @@ { pkgs, ... }: { -# TODO: this - # environment.variables = { - # TERMINAL = "ghostty"; - # }; - # - # home-manager.sharedModules = [{ - # programs.ghostty = { - # enable = true; - # package = pkgs.ghostty; - # - # clearDefaultKeybinds = false; - # settings = { - # theme = "tokyonight"; - # font-family = "JetBrainsMono NL NFM Medium"; - # font-size = 16; - # - # shell-integration-features = "no-cursor"; - # - # cursor-style = "block"; - # background-opacity = 1; - # - # background-blur-radius = 0; - # - # gtk-titlebar = false; - # mouse-hide-while-typing = true; - # }; - # }; - # }]; + environment.variables = { + TERMINAL = "ghostty"; + }; + + home-manager.sharedModules = [{ + programs.ghostty = { + enable = true; + package = pkgs.ghostty; + + clearDefaultKeybinds = false; + settings = { + theme = "tokyonight"; + font-family = "JetBrainsMono NL NFM Medium"; + font-size = 16; + + shell-integration-features = "no-cursor"; + + cursor-style = "block"; + background-opacity = 1; + + background-blur-radius = 0; + + gtk-titlebar = false; + mouse-hide-while-typing = true; + }; + }; + }]; } diff --git a/modules/common/packages.nix b/modules/common/packages.nix index ac02d54..a16e18c 100644 --- a/modules/common/packages.nix +++ b/modules/common/packages.nix @@ -8,6 +8,10 @@ in { neovim vim home-manager + + gcc + gnumake + automake ; }; } diff --git a/modules/linux/networking.nix b/modules/linux/networking.nix index ef47066..da804d8 100644 --- a/modules/linux/networking.nix +++ b/modules/linux/networking.nix @@ -1,5 +1,5 @@ -{ - networking.hostName = "thegeneralist"; +{ config, ... }: { + networking.hostName = if config.isServer then "thegeneralist-central" else "thegeneralist"; networking.networkmanager.enable = true; networking.networkmanager.wifi.powersave = false; } diff --git a/modules/linux/nvidia.nix b/modules/linux/nvidia.nix index 6f374ea..7258f8a 100644 --- a/modules/linux/nvidia.nix +++ b/modules/linux/nvidia.nix @@ -1,4 +1,4 @@ -{ +{ lib, config, ... }: lib.mkIf (!config.isServer) { hardware.nvidia = { open = true; modesetting.enable = true; diff --git a/modules/linux/packages.nix b/modules/linux/packages.nix index bb71e74..8a59d39 100644 --- a/modules/linux/packages.nix +++ b/modules/linux/packages.nix @@ -1,16 +1,15 @@ -{ pkgs, lib, ...}: let +{ pkgs, lib, config, ...}: let inherit (lib) attrValues; in { environment.systemPackages = attrValues { inherit (pkgs) - protonup-qt pipewire pwvucontrol wireplumber - playerctl - + playerctl; + } ++ (if (!config.isServer) then (attrValues { + inherit (pkgs) protonup-qt xsane - simple-scan - ; - }; + simple-scan; + }) else []); } diff --git a/modules/linux/steam.nix b/modules/linux/steam.nix index f81c5dc..b4473b9 100644 --- a/modules/linux/steam.nix +++ b/modules/linux/steam.nix @@ -1,4 +1,4 @@ -{ lib, ... }: { +{ lib, config, ... }: lib.mkIf (!config.isServer) { programs.steam = { enable = true; remotePlay.openFirewall = true; diff --git a/secrets.nix b/secrets.nix index 91b11f9..d5e0c37 100644 --- a/secrets.nix +++ b/secrets.nix @@ -2,5 +2,7 @@ let inherit (import ./keys.nix) thegeneralist; in { "hosts/thegeneralist/hostkey.age".publicKeys = [ thegeneralist ]; + "hosts/thegeneralist-central/hostkey.age".publicKeys = [ thegeneralist ]; + "modules/linux/tailscale-marshall.age".publicKeys = [ thegeneralist ]; }