diff --git a/hosts/server/configuration.nix b/hosts/server/configuration.nix new file mode 100644 index 0000000..f747c03 --- /dev/null +++ b/hosts/server/configuration.nix @@ -0,0 +1,21 @@ +{ config, ... }: { + imports = [ + ../../nixos/home-manager.nix + ../../nixos/nix.nix + ../../nixos/systemd-boot.nix + ../../nixos/users.nix + ../../nixos/utils.nix + ../../nixos/docker.nix + + ../../server-modules/ssh.nix + + # You should let those lines as is + ./hardware-configuration.nix + ./variables.nix + ]; + + home-manager.users."${config.var.username}" = import ./home.nix; + + # Don't touch this + system.stateVersion = "24.05"; +} diff --git a/hosts/server/home.nix b/hosts/server/home.nix new file mode 100644 index 0000000..8411ac3 --- /dev/null +++ b/hosts/server/home.nix @@ -0,0 +1,45 @@ +{ pkgs, config, ... }: { + + imports = [ + # Mostly user-specific configuration + ./variables.nix + + # Programs + ../../home/programs/nvim + ../../home/programs/shell + ../../home/programs/fetch + ../../home/programs/git + ../../home/programs/lazygit + + # Scripts + ../../home/scripts # All scripts + ]; + + home = { + inherit (config.var) username; + homeDirectory = "/home/" + config.var.username; + + packages = with pkgs; [ + # Dev + go + nodejs + python3 + jq + just + pnpm + + # Utils + zip + unzip + optipng + pfetch + btop + fastfetch + ]; + + # Don't touch this + stateVersion = "24.05"; + }; + + programs.home-manager.enable = true; +} diff --git a/hosts/server/variables.nix b/hosts/server/variables.nix new file mode 100644 index 0000000..802d9f2 --- /dev/null +++ b/hosts/server/variables.nix @@ -0,0 +1,36 @@ +{ config, lib, ... }: { + imports = [ + # Choose your theme here: + ../../themes/nixy.nix + ]; + + config.var = { + hostname = "jack"; + username = "hadi"; + configDirectory = "/home/" + config.var.username + + "/.config/nixos"; # The path of the nixos configuration directory + + keyboardLayout = "fr"; + + location = "Paris"; + timeZone = "Europe/Paris"; + defaultLocale = "en_US.UTF-8"; + extraLocale = "fr_FR.UTF-8"; + + git = { + username = "Hadi"; + email = "112569860+anotherhadi@users.noreply.github.com"; + }; + + autoUpgrade = false; + autoGarbageCollector = true; + }; + + # Let this here + options = { + var = lib.mkOption { + type = lib.types.attrs; + default = { }; + }; + }; +} diff --git a/server-modules/ssh.nix b/server-modules/ssh.nix new file mode 100644 index 0000000..c9f97a4 --- /dev/null +++ b/server-modules/ssh.nix @@ -0,0 +1,16 @@ +{ config, ... }: { + services.openssh = { + enable = true; + permitRootLogin = "no"; + passwordAuthentication = false; + openFirewall = true; + ports = [ 22 ]; + settings.AllowUsers = [ config.var.username ]; + }; + + users.users."${config.var.username}" = { + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPG9SE80ZyBcXZK/f5ypSKudaM5Jo3XtQikCnGo0jI5E hadi@nixy" + ]; + }; +}