From 57d067d501242f9bd15cae26e26a3909f69fb7d3 Mon Sep 17 00:00:00 2001 From: Jo Date: Wed, 18 Sep 2024 21:21:48 +0200 Subject: [PATCH] feat(modules): add server archetype feat: WIP add "absolutesolver" system and "cyn" user *wink wink* refactor: clean up some comments and remove empty lines --- .../cyn@absolutesolver/default.nix | 20 ++++++++ .../default.nix} | 2 +- .../{development => common}/ssh/default.nix | 2 +- modules/home/services/vaultwarden/default.nix | 5 ++ .../home/themes/catppuccin/global/default.nix | 12 ----- .../home/themes/catppuccin/gnome/default.nix | 12 ----- modules/nixos/archetypes/server/default.nix | 33 ++++++++++++ modules/nixos/common/hardware/default.nix | 1 - .../x86_64-linux/absolutesolver/default.nix | 50 +++++++++++++++++++ systems/x86_64-linux/puzzlevision/default.nix | 3 +- 10 files changed, 111 insertions(+), 29 deletions(-) create mode 100644 homes/x86_64-linux/cyn@absolutesolver/default.nix rename modules/home/apps/development/{zed-editor.nix => zed-editor/default.nix} (87%) rename modules/home/{development => common}/ssh/default.nix (98%) create mode 100644 modules/home/services/vaultwarden/default.nix create mode 100644 modules/nixos/archetypes/server/default.nix create mode 100644 systems/x86_64-linux/absolutesolver/default.nix diff --git a/homes/x86_64-linux/cyn@absolutesolver/default.nix b/homes/x86_64-linux/cyn@absolutesolver/default.nix new file mode 100644 index 0000000..6ecc69f --- /dev/null +++ b/homes/x86_64-linux/cyn@absolutesolver/default.nix @@ -0,0 +1,20 @@ +{ + lib, + pkgs, + inputs, + namespace, + ... +}: with lib; with lib.${namespace}; +{ + # Declare user packages. + home.packages = with pkgs; [ + ### Runtimes + nodejs_22 + bun + + ### Tools + git + ]; + + home.stateVersion = "24.05"; +} diff --git a/modules/home/apps/development/zed-editor.nix b/modules/home/apps/development/zed-editor/default.nix similarity index 87% rename from modules/home/apps/development/zed-editor.nix rename to modules/home/apps/development/zed-editor/default.nix index adca1ad..85b0f63 100644 --- a/modules/home/apps/development/zed-editor.nix +++ b/modules/home/apps/development/zed-editor/default.nix @@ -7,7 +7,7 @@ ... }: with lib; with lib.${namespace}; let - cfg = config.${namespace}.apps.zed-editor; + cfg = config.${namespace}.apps.development.zed-editor; zed-fhs = pkgs.buildFHSUserEnv { name = "zed"; diff --git a/modules/home/development/ssh/default.nix b/modules/home/common/ssh/default.nix similarity index 98% rename from modules/home/development/ssh/default.nix rename to modules/home/common/ssh/default.nix index fbc7642..153adc0 100644 --- a/modules/home/development/ssh/default.nix +++ b/modules/home/common/ssh/default.nix @@ -36,6 +36,6 @@ in { identitiesOnly = true; user = "git"; }; - }; + }; }; } diff --git a/modules/home/services/vaultwarden/default.nix b/modules/home/services/vaultwarden/default.nix new file mode 100644 index 0000000..00cdf7a --- /dev/null +++ b/modules/home/services/vaultwarden/default.nix @@ -0,0 +1,5 @@ +{ + ... +}: { + # Todo: implement example service structure which should be re-usable for any future services. +} \ No newline at end of file diff --git a/modules/home/themes/catppuccin/global/default.nix b/modules/home/themes/catppuccin/global/default.nix index 1fd74c4..189704d 100644 --- a/modules/home/themes/catppuccin/global/default.nix +++ b/modules/home/themes/catppuccin/global/default.nix @@ -1,16 +1,4 @@ { - lib, - pkgs, - inputs, - - namespace, # The flake namespace, set in flake.nix. If not set, defaults to "internal". - system, - target, # The Snowfall Lib target for this home (eg. `x86_64-home`). - format, # A normalized name for the home target (eg. `home`). - virtual, # A boolean to determine whether this home is a virtual target using nixos-generators. - host, # The host name for this home. - - config, ... }: { catppuccin = { diff --git a/modules/home/themes/catppuccin/gnome/default.nix b/modules/home/themes/catppuccin/gnome/default.nix index 84d91b9..dffdbc5 100644 --- a/modules/home/themes/catppuccin/gnome/default.nix +++ b/modules/home/themes/catppuccin/gnome/default.nix @@ -1,16 +1,4 @@ { - lib, - pkgs, - inputs, - - namespace, # The flake namespace, set in flake.nix. If not set, defaults to "internal". - system, - target, # The Snowfall Lib target for this home (eg. `x86_64-home`). - format, # A normalized name for the home target (eg. `home`). - virtual, # A boolean to determine whether this home is a virtual target using nixos-generators. - host, # The host name for this home. - - config, ... }: { gtk = { diff --git a/modules/nixos/archetypes/server/default.nix b/modules/nixos/archetypes/server/default.nix new file mode 100644 index 0000000..89843d5 --- /dev/null +++ b/modules/nixos/archetypes/server/default.nix @@ -0,0 +1,33 @@ +{ + lib, + pkgs, + namespace, + config, + ... +}: with lib; with lib.${namespace}; +let + cfg = config.${namespace}.archetypes.server; +in { + options.${namespace}.archetypes.server = { enable = mkEnableOption "Enable the server archetype for your current system"; }; + + config = mkIf cfg.enable { + # Enable modules + puzzlevision = { + common = { + nix = { + enable = true; + use-lix = true; + }; + grub.enable = true; + networking.enable = true; + kernel.enable = true; + shell.enable = true; + hardware.enable = true; + locale.enable = true; + }; + }; + }; + + # Enable SSH for remote login + services.openssh.enable = true; +} \ No newline at end of file diff --git a/modules/nixos/common/hardware/default.nix b/modules/nixos/common/hardware/default.nix index a7cb94a..bf98b51 100644 --- a/modules/nixos/common/hardware/default.nix +++ b/modules/nixos/common/hardware/default.nix @@ -12,7 +12,6 @@ in { config = mkIf cfg.enable { hardware.sensor.iio.enable = true; # Enable iio-sensor for automatic screen rotation and similar features. - hardware.flipperzero.enable = true; # Enable support for the flipperzero device. }; } diff --git a/systems/x86_64-linux/absolutesolver/default.nix b/systems/x86_64-linux/absolutesolver/default.nix new file mode 100644 index 0000000..f35b125 --- /dev/null +++ b/systems/x86_64-linux/absolutesolver/default.nix @@ -0,0 +1,50 @@ +{ + lib, + pkgs, + inputs, + namespace, + config, + ... +}: +with lib; +with lib.${namespace}; +{ + imports = [ + ./hardware-configuration.nix + inputs.hardware.nixosModules.common-pc-laptop + inputs.hardware.nixosModules.common-cpu-intel + inputs.hardware.nixosModules.common-pc-laptop-ssd + ]; + + # Set hostname + # Todo: move to common/networking module + networking.hostName = "absolutesolver"; + + # Set timezone. + time.timeZone = "Europe/Berlin"; + + # Enable docker + virtualisation.docker.enable = true; + + # Set system Type + puzzlevision.archetypes.server.enable = true; + + # Configure users. + snowfallorg.users.jo.admin = true; + users.users.jo.isNormalUser = true; + users.users.jo.extraGroups = [ "dialout" "docker" ]; + + # Configure home-manager + home-manager = { + backupFileExtension = "homeManagerBackup"; + }; + + # Provide users with some sane default packages. + environment.systemPackages = with pkgs; [ + ### General + nano + vim + ]; + + system.stateVersion = "24.05"; +} diff --git a/systems/x86_64-linux/puzzlevision/default.nix b/systems/x86_64-linux/puzzlevision/default.nix index 14b89d9..078d8e3 100644 --- a/systems/x86_64-linux/puzzlevision/default.nix +++ b/systems/x86_64-linux/puzzlevision/default.nix @@ -51,13 +51,12 @@ with lib.${namespace}; # Configure users. snowfallorg.users.jo.admin = true; - users.users.jo.isNormalUser = true; users.users.jo.extraGroups = [ "dialout" "docker" ]; # Configure home-manager home-manager = { - backupFileExtension = "homeManagerBackupFile"; + backupFileExtension = "homeManagerBackup"; }; # Provide users with some sane default packages.