From 73f883e6a41360db2a992649a7977574d6f77ef3 Mon Sep 17 00:00:00 2001 From: ringofstorms Date: Sun, 31 Mar 2024 19:39:48 -0500 Subject: [PATCH] attempt modularilty --- flake.nix | 44 ++++++++++---- secrets/secrets.nix | 4 ++ systems/_common/configuration.nix | 1 - systems/joe/configuration.nix | 81 ++++++++++++++++++++++++++ systems/joe/hardware-configuration.nix | 38 ++++++++++++ 5 files changed, 156 insertions(+), 12 deletions(-) create mode 100644 systems/joe/configuration.nix create mode 100644 systems/joe/hardware-configuration.nix diff --git a/flake.nix b/flake.nix index 82e72ad..bbbc868 100644 --- a/flake.nix +++ b/flake.nix @@ -26,13 +26,7 @@ nixosSystem = nixpkgs.lib.nixosSystem; mkMerge = nixpkgs.lib.mkMerge; - settings = { - system = { - hostname = "gpdPocket3"; - architecture = "x86_64-linux"; - timeZone = "America/Chicago"; - defaultLocale = "en_US.UTF-8"; - }; + sett = { user = { username = "josh"; git = { @@ -51,10 +45,38 @@ ylib = ypkgs.lib; in { - nixosConfigurations.${settings.system.hostname} = nixosSystem { - system = settings.system.architecture; - modules = [ ./systems/_common/configuration.nix ./systems/${settings.system.hostname}/configuration.nix ]; - specialArgs = inputs // { inherit settings; inherit ylib; }; + nixosConfigurations = { + gpdPocket3 = nixosSystem { + system = "x86_64-linux"; + modules = [ ./systems/_common/configuration.nix ./systems/gpdPocket3/configuration.nix ]; + specialArgs = inputs // { inherit ylib; + settings = sett // { + system = { + # TODO remove these probably not needed anymore with per machine specified here + hostname = "gpdPocket3"; + architecture = "x86_64-linux"; + timeZone = "America/Chicago"; # TODO roaming? + defaultLocale = "en_US.UTF-8"; + }; + }; + }; + }; + joe = nixosSystem { + system = "x86_64-linux"; + modules = [ ./systems/_common/configuration.nix ./systems/joe/configuration.nix ]; + specialArgs = inputs // { inherit ylib; + settings = sett // { + system = { + # TODO remove these probably not needed anymore with per machine specified here + hostname = "joe"; + architecture = "x86_64-linux"; + # TODO remove? + timeZone = "America/Chicago"; + defaultLocale = "en_US.UTF-8"; + }; + }; + }; + }; }; # homeConfigurations = { }; }; diff --git a/secrets/secrets.nix b/secrets/secrets.nix index 138ca24..f1d81ab 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -9,8 +9,12 @@ let publicKeys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBdG4tG18VeuEr/g4GM7HWUzHuUVcR9k6oS3TPBs4JRF ragenix authority key" + # gpdPocket3 "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMhgYzACsd0GPuF8bl9SFB5y9KDwv+pU9UihoInzhRok josh@gpdPocket3" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJnV4aVyKStFH1KySfnuqBq+DLvyvJhRfKtMs7PCKlIq root@nixos" + # joe + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG4PwrrOuZJWRjlc2dKBUKKE4ybqifJeVOn7x9J5IxIS josh@joe" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP+GYfPPKxR/18RdD736G7IQhImX/CYU3A+Gifud3CHg root@joe" ]; in { diff --git a/systems/_common/configuration.nix b/systems/_common/configuration.nix index d508b08..1a651b8 100644 --- a/systems/_common/configuration.nix +++ b/systems/_common/configuration.nix @@ -10,7 +10,6 @@ in imports = [ # Include the results of the hardware scan. - # Note we need to be in the /etc/nixos directory with this entire config repo for this relative path to work (/${settings.systemsDir}/${settings.system.hostname}/hardware-configuration.nix) # home manager import (import "${home-manager}/nixos") diff --git a/systems/joe/configuration.nix b/systems/joe/configuration.nix new file mode 100644 index 0000000..c1b1168 --- /dev/null +++ b/systems/joe/configuration.nix @@ -0,0 +1,81 @@ +{ config, lib, pkgs, settings, ... } @ args: +{ + imports = + [ + (settings.usersDir + "/root/configuration.nix") + (settings.usersDir + "/josh/configuration.nix") + ]; + + # Use the systemd-boot EFI boot loader. + boot.loader = { + systemd-boot = { + enable = true; + consoleMode = "keep"; + }; + timeout = 5; + efi = { + canTouchEfiVariables = true; + }; + }; + + # We want connectivity + networking.networkmanager.enable = true; + hardware.bluetooth.enable = true; + + # Enable sound. + sound.enable = true; + hardware.pulseaudio.enable = true; + hardware.pulseaudio.package = pkgs.pulseaudioFull; + + hardware.enableAllFirmware = true; + + # I want this globally even for root so doing it outside of home manager + services.xserver.xkbOptions = "caps:escape"; + console = { + earlySetup = true; + packages = with pkgs; [ terminus_font ]; + # We want to be able to read the screen so use a 32 sized font... + # font = "${pkgs.terminus_font}/share/consolefonts/ter-132n.psf.gz"; + useXkbConfig = true; # use xkb.options in tty. (caps -> escape) + }; + + # Enable the OpenSSH daemon. + services.openssh.enable = true; + services.openssh.settings.PermitRootLogin = "yes"; + + # Open ports in the firewall. + networking.firewall.allowedTCPPorts = [ + 22 # sshd + ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + + fonts.packages = with pkgs; [ + (nerdfonts.override { fonts = [ "JetBrainsMono" ]; }) + ]; + + services.xserver.enable = true; + services.xserver.displayManager.gdm = { + enable = true; + autoSuspend = false; + }; + services.xserver.desktopManager.gnome.enable = true; + services.gnome.core-utilities.enable = false; + + # List packages installed in system profile. To search, run: + # $ nix search wget + nixpkgs.config.allowUnfree = true; + environment.systemPackages = with pkgs; [ + # extras, more for my neovim setup TODO move these into a more isolated place for nvim setup? Should be its own flake probably + cargo + rustc + nodejs_21 + python313 + # ripgrep # now in common + nodePackages.cspell + ]; + + # does for all shells. Can use `programs.zsh.shellAliases` for specific ones + environment.shellAliases = { + wifi = "nmtui"; + }; +} diff --git a/systems/joe/hardware-configuration.nix b/systems/joe/hardware-configuration.nix new file mode 100644 index 0000000..9fd83c4 --- /dev/null +++ b/systems/joe/hardware-configuration.nix @@ -0,0 +1,38 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-label/NIXROOT"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-label/NIXBOOT"; + fsType = "vfat"; + }; + + swapDevices = [ ]; + + # 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.interfaces.enp2s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlo1.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +}