diff --git a/README.md b/README.md index a6e4cee..6caf191 100644 --- a/README.md +++ b/README.md @@ -6,22 +6,30 @@ <br> ## 🚧 State of development -Version 2.0 is still very much an experiment and not ready to be used in a production -environment. If you must, try running it within a VM using the provided deployment -instructions. +All the basic functionality of v2 should be working correctly, including: + +- The custom lib implementation at self.lib, recursively built from the contents of the `lib` directory. +- Loading of systems from the `systems` directory, using easy-hosts. + - A basic workstation archetype for desktop systems. +- Creating users in your systems through ${self.namespace}.users, +automatically maps home-manager configurations from the `homes` directory to their corresponding users. + +Nonetheless, one should still consider this implementation experimental, +once I start using this on my laptop, +I'll aim for production grade stability. ## 🚀 Deployment To deploy a system run the following command in your terminal of choice. ```sh -sudo nixos-rebuild switch --flake .#hostname +sudo nixos-rebuild switch --flake .#hostname --accept-flake-config ``` If you're interested in a quick way to experiment with this configuration, you may use the following command to build a VM. ```sh -sudo nixos-rebuild build-vm --flake .#hostname +sudo nixos-rebuild build-vm --flake .#hostname --accept-flake-config ``` ## 📝 Goals and improvements diff --git a/homes/x86_64-linux/jo/default.nix b/homes/x86_64-linux/jo/default.nix index 21cf78b..bd62c1a 100644 --- a/homes/x86_64-linux/jo/default.nix +++ b/homes/x86_64-linux/jo/default.nix @@ -1,10 +1,7 @@ -{ - pkgs, - ... -}: { +{pkgs, ...}: { home.packages = with pkgs; [ - vscodium - cmatrix + zed-editor + firefox ]; home.stateVersion = "25.05"; diff --git a/modules/nixos/archetypes/workstation/default.nix b/modules/nixos/archetypes/workstation/default.nix new file mode 100644 index 0000000..32b3c1a --- /dev/null +++ b/modules/nixos/archetypes/workstation/default.nix @@ -0,0 +1,32 @@ +{ + lib, + self, + config, + ... +}: let + inherit (lib) mkEnableOption mkIf mkDefault; + inherit (self) namespace; + + cfg = config.${namespace}.archetypes.workstation; +in { + options.${namespace}.archetypes.workstation = { + enable = mkEnableOption "the workstation archetype."; + }; + + config = mkIf cfg.enable { + ${namespace} = { + # Basic system functionality + system.grub.enable = true; + system.networking.enable = true; + system.kernel.enable = true; + + # Services + services.docker.enable = true; + + # Desktop environment + desktop.gnome.enable = true; + }; + + time.timeZone = mkDefault "Europe/Berlin"; + }; +} diff --git a/modules/nixos/services/docker/default.nix b/modules/nixos/services/docker/default.nix new file mode 100644 index 0000000..bb3f805 --- /dev/null +++ b/modules/nixos/services/docker/default.nix @@ -0,0 +1,20 @@ +{ + lib, + self, + config, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (self) namespace; + + cfg = config.${namespace}.services.docker; +in { + options.${namespace}.services.docker = { + enable = mkEnableOption "the docker service."; + }; + + config = mkIf cfg.enable { + # Enable docker + virtualisation.docker.enable = true; + }; +} diff --git a/modules/nixos/system/kernel/default.nix b/modules/nixos/system/kernel/default.nix new file mode 100644 index 0000000..521846d --- /dev/null +++ b/modules/nixos/system/kernel/default.nix @@ -0,0 +1,22 @@ +{ + lib, + pkgs, + self, + config, + ... +}: let + inherit (lib) mkEnableOption mkIf; + inherit (self) namespace; + inherit (self.lib) mkOpt; + + cfg = config.${namespace}.system.kernel; +in { + options.${namespace}.system.kernel = { + enable = mkEnableOption "Modify the standard kernel settings"; + version = mkOpt lib.types.str "linuxPackages_latest" "Set the kernel version to be used by your system"; + }; + + config = mkIf cfg.enable { + boot.kernelPackages = pkgs.${cfg.version}; + }; +} diff --git a/modules/nixos/system/networking/default.nix b/modules/nixos/system/networking/default.nix new file mode 100644 index 0000000..2130053 --- /dev/null +++ b/modules/nixos/system/networking/default.nix @@ -0,0 +1,19 @@ +{ + lib, + self, + config, + ... +}: let + inherit (lib) mkEnableOption mkIf; + inherit (self) namespace; + + cfg = config.${namespace}.system.networking; +in { + options.${namespace}.system.networking = { + enable = mkEnableOption "networking."; + }; + + config = mkIf cfg.enable { + networking.networkmanager.enable = true; + }; +} diff --git a/modules/nixos/users/default.nix b/modules/nixos/users/default.nix index 958f7b9..4d91d25 100644 --- a/modules/nixos/users/default.nix +++ b/modules/nixos/users/default.nix @@ -39,6 +39,9 @@ in { }; config = { + # TODO: fix this + #nix.settings.trusted-users = ["root" (lib.forEach cfg (username: toString username))]; + # Manage users declaratively and map userConfig to users.users by name; users.mutableUsers = false; users.users = lib.mapAttrs (username: userConfig: diff --git a/systems/x86_64-nixos/puzzlevision/default.nix b/systems/x86_64-nixos/puzzlevision/default.nix index 3855640..dcde7a3 100644 --- a/systems/x86_64-nixos/puzzlevision/default.nix +++ b/systems/x86_64-nixos/puzzlevision/default.nix @@ -10,14 +10,34 @@ extraGroups = ["wheel"]; }; - desktop.gnome.enable = true; - system.grub.enable = true; + users.jo = { + enable = true; + password = "jo"; # For testing only, replace with sops secret before production use + extraGroups = ["wheel"]; + }; + + archetypes.workstation.enable = true; }; - environment.systemPackages = with pkgs; [ - ghostty - firefox + # Configure 8GB SWAP partition + swapDevices = [ + { + device = "/swapfile"; + size = 8 * 1024; + } ]; + boot = { + # Configure additional kernel modules. + extraModulePackages = [ + pkgs.linuxPackages_latest.rtl8821ce # Use custom network-card driver. + ]; + + blacklistedKernelModules = [ + "rtw88_8821ce" # Block the default network-card driver. + ]; + }; + + networking.hostName = "puzzlevision"; system.stateVersion = "25.05"; }