From c473a8334c9ce0b04f97ed502ddc0b32c47ae160 Mon Sep 17 00:00:00 2001 From: death916 Date: Sun, 11 May 2025 04:37:15 -0700 Subject: [PATCH] added server configs --- flake.nix | 68 ++++++++++++++++++++++--------- flake.nix.b4serverconfig | 54 ++++++++++++++++++++++++ home-manager/death916-homelab.nix | 28 +++++++++++++ nixos/homelab.nix | 54 ++++++++++++++++++++++++ 4 files changed, 185 insertions(+), 19 deletions(-) create mode 100644 flake.nix.b4serverconfig create mode 100644 home-manager/death916-homelab.nix create mode 100644 nixos/homelab.nix diff --git a/flake.nix b/flake.nix index 2fdf787..5dc8110 100644 --- a/flake.nix +++ b/flake.nix @@ -1,54 +1,84 @@ +# flake.nix { - description = "Base NixOS flake"; + description = "NixOS configurations for laptop and homelab server"; inputs = { - # MODIFIED: Main Nixpkgs explicitly set to the nixos-24.11 branch - nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; + # Main Nixpkgs + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; # Or your preferred branch - # The nixos-cosmic flake input + # COSMIC Desktop for laptop nixos-cosmic = { url = "github:lilyinstarlight/nixos-cosmic"; - # MODIFIED: nixos-cosmic will now use the nixpkgs defined above (nixos-24.11) inputs.nixpkgs.follows = "nixpkgs"; }; - # home manager + # Home Manager home-manager = { - # MODIFIED: Explicitly set to release-24.11 - url = "github:nix-community/home-manager/release-24.11"; - # The `follows` keyword in inputs is used for inheritance. - # Home Manager will use the nixpkgs defined above (nixos-24.11) + url = "github:nix-community/home-manager/release-24.11"; # Or your preferred branch inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = inputs@{ nixpkgs, home-manager, nixos-cosmic, ... }: { + outputs = inputs@{ nixpkgs, home-manager, nixos-cosmic, ... }: + let + # Common arguments to pass to all system configurations + commonSpecialArgs = { + inherit inputs; + }; + in + { nixosConfigurations = { + # Laptop configuration (assuming it's named 'nixos' or your laptop's actual hostname) nixos = nixpkgs.lib.nixosSystem { - system = [ - "x86_64-linux" - "aarch64-linux" - ]; + system = "x86_64-linux"; # Specify your laptop's architecture + specialArgs = commonSpecialArgs; modules = [ - { + { # COSMIC-specific Cachix settings for the laptop nix.settings = { substituters = [ "https://cosmic.cachix.org/" ]; trusted-public-keys = [ "cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE=" ]; }; } + nixos-cosmic.nixosModules.default # COSMIC Desktop Environment for laptop + ./nixos/configuration.nix # Your existing laptop NixOS configuration + # Add any custom modules from ./modules for the laptop here + # e.g., ./modules/laptop-specific.nix - nixos-cosmic.nixosModules.default - ./nixos/configuration.nix home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.users.death916 = { - imports = [ ./home-manager/home.nix ]; + imports = [ ./home-manager/home.nix ]; # Laptop Home Manager config for death916 + }; + } + ]; + }; + + # Homelab Server configuration + homelab = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; # Specify your server's architecture + specialArgs = commonSpecialArgs; + modules = [ + ./nixos/homelab.nix # Homelab server's main NixOS configuration + # Add any custom modules from ./modules for the homelab server here + # e.g., ./modules/server-common.nix + + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.death916 = { + imports = [ ./home-manager/death916-homelab.nix ]; # Homelab Home Manager config for death916 }; } ]; }; }; + + # If you have global overlays from ./overlays: + # nixpkgs.overlays = [ + # (import ./overlays/my-global-overlay.nix) + # ]; }; } diff --git a/flake.nix.b4serverconfig b/flake.nix.b4serverconfig new file mode 100644 index 0000000..2fdf787 --- /dev/null +++ b/flake.nix.b4serverconfig @@ -0,0 +1,54 @@ +{ + description = "Base NixOS flake"; + + inputs = { + # MODIFIED: Main Nixpkgs explicitly set to the nixos-24.11 branch + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; + + # The nixos-cosmic flake input + nixos-cosmic = { + url = "github:lilyinstarlight/nixos-cosmic"; + # MODIFIED: nixos-cosmic will now use the nixpkgs defined above (nixos-24.11) + inputs.nixpkgs.follows = "nixpkgs"; + }; + + # home manager + home-manager = { + # MODIFIED: Explicitly set to release-24.11 + url = "github:nix-community/home-manager/release-24.11"; + # The `follows` keyword in inputs is used for inheritance. + # Home Manager will use the nixpkgs defined above (nixos-24.11) + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = inputs@{ nixpkgs, home-manager, nixos-cosmic, ... }: { + nixosConfigurations = { + nixos = nixpkgs.lib.nixosSystem { + system = [ + "x86_64-linux" + "aarch64-linux" + ]; + modules = [ + { + nix.settings = { + substituters = [ "https://cosmic.cachix.org/" ]; + trusted-public-keys = [ "cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE=" ]; + }; + } + + nixos-cosmic.nixosModules.default + ./nixos/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.death916 = { + imports = [ ./home-manager/home.nix ]; + }; + } + ]; + }; + }; + }; +} diff --git a/home-manager/death916-homelab.nix b/home-manager/death916-homelab.nix new file mode 100644 index 0000000..a29e96e --- /dev/null +++ b/home-manager/death916-homelab.nix @@ -0,0 +1,28 @@ +# ./home-manager/death916-homelab.nix +{ config, pkgs, lib, inputs, ... }: + +{ + home.username = "death916"; + home.homeDirectory = "/home/death916"; + + # Basic shell configuration (can be more elaborate) + programs.bash.enable = true; + programs.git.enable = true; + + # Server-specific tools or dotfiles for death916 + programs.tmux.enable = true; # Example from your repo image + + # Example: Different shell prompt or aliases for server environment + # programs.bash.shellAliases = { + # ll = "ls -alh"; + # update-system = "sudo nixos-rebuild switch --flake /etc/nixos#homelab"; + # }; + + home.packages = with pkgs; [ + # Any user-specific packages for death916 on the server + fastetch + ]; + + # Keep this consistent with your system's state version + home.stateVersion = "24.11"; +} diff --git a/nixos/homelab.nix b/nixos/homelab.nix new file mode 100644 index 0000000..ef056e3 --- /dev/null +++ b/nixos/homelab.nix @@ -0,0 +1,54 @@ +# ./nixos/homelab.nix +{ config, pkgs, lib, inputs, ... }: + +{ + imports = [ + # Import any shared modules from your ./modules directory if applicable + # e.g., (../modules/common-settings.nix) + ]; + + boot.loader.systemd-boot.enable = true; # Or grub, as appropriate for your server + boot.loader.efi.canTouchEfiVariables = true; + + networking.hostName = "homelab"; # Set the server's hostname + + # Basic firewall + networking.firewall.enable = true; + networking.firewall.allowedTCPPorts = [ 22 ]; # Allow SSH + + # SSH Server configuration + services.openssh = { + enable = true; + settings.PasswordAuthentication = false; # Recommended: use SSH keys + settings.PermitRootLogin = "no"; # Recommended + }; + + # Define the 'death916' user for the server + users.users.death916 = { + isNormalUser = true; + extraGroups = [ "wheel" ]; # For sudo access + openssh.authorizedKeys.keys = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCte9KjJUSn4xBPEKCk9QER6+jF+C0uBatVl27zIamYsryyHdFrmqK2DAg7OhqTHqzjxID6sp6d57MsJqOUAtwXbUDMLffqBSerUxfTm+1SPDrhL0GSvo0QVjMLVseOEq8d2qXgW1R7dIk412VbO5e9SAump5aJOHI/SzT6VLoUczalmqrjnDacWQMeLu/TSOZHcfrhjYSg+b1xbc1vHp6C4obOb8JIj/anAieT/1P36MhlNW79ow6PWenLemBYeeezFrKtESF1oMc8jmcxogzgLamlqhKYAHlKhOuBF6u0nRneI5IPDbbMF5zwEv5szCEKj8XZJVYUk8uUg7ARyppjcA7yAXuaNKBNxa7tfjqWrDWOACn97ufE5FFJt0XH5JzkXcDh96K8ZSZaWxMRu2s+GlIu/1F415xtVfe1d79HYkWke/ewaQ4NqgOt8f7wRvyzabpQZDzkaXO0UoK65O2HyUur33XWCEmV+1pB6BrS8pD+1I4Tvbnc+rOgtHTTRfKqezKqZmaErEOxClBwvWjvn0PzhGSoClTGXPjhl239/sH0JGY09dTBh8GtAVbfv+jFO6nm6aR7O/OwSaohY3uOdRo8XyxJr4XyGAaBNRdm6BUJRnB4W51J49IQBZzIe2NUkNMHeUT4jkxFpfhkujnSFw2ZnOLkERpwkltAlbwuLw== tavn1992@gmail.com" # <<-- REPLACE THIS WITH YOUR SSH PUBLIC KEY for death916 + # Add more keys if needed + ]; + # If 'death916' needs a password on the server (less secure than key-only) + # initialPassword = "yoursecurepassword"; # Or use hashed password + }; + + # Sudo access for the wheel group (which death916 is part of) + security.sudo.wheelNeedsPassword = true; # Or false if you prefer passwordless sudo for wheel + + # Essential server packages + environment.systemPackages = with pkgs; [ + git + vim + htop + tmux + # Add other common server utilities + ]; + + # If you use custom overlays specific to this server: + # nixpkgs.overlays = [(import ../overlays/homelab-overlay.nix)]; + + system.stateVersion = "24.11"; # Set to your NixOS version +}