refactor: split systems into archetypes
refactor(module): move kernel config to module refactor(module): move nix config to module refactor(module): move networking config to module refactor(module): move nix config to module refactor(module): move grub config to module
This commit is contained in:
parent
067bc992b6
commit
b43660c227
9 changed files with 228 additions and 66 deletions
|
@ -18,7 +18,18 @@
|
|||
# All other arguments come from the home home.
|
||||
config,
|
||||
...
|
||||
}: with lib; with lib.${namespace}; {
|
||||
}: with lib; with lib.${namespace};
|
||||
let
|
||||
zed-fhs = pkgs.buildFHSUserEnv {
|
||||
name = "zed";
|
||||
targetPkgs = pkgs:
|
||||
with pkgs; [
|
||||
zed-editor
|
||||
];
|
||||
runScript = "zed";
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./apps/gnome.nix
|
||||
];
|
||||
|
@ -54,7 +65,7 @@
|
|||
nodejs_22
|
||||
bun
|
||||
devenv
|
||||
zed-editor
|
||||
zed-fhs
|
||||
|
||||
### Rust development specific
|
||||
rustup
|
||||
|
@ -71,7 +82,7 @@
|
|||
sidequest
|
||||
];
|
||||
|
||||
puzzlevision.apps.zed-editor.enable = true;
|
||||
#lib.puzzlevision.apps.zed-editor.enable = true;
|
||||
|
||||
home.stateVersion = "24.05";
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@ let
|
|||
in {
|
||||
options.${namespace}.apps.zed-editor = { enable = mkEnableOption "zed-editor"; };
|
||||
|
||||
home.packages = [zed-fhs];
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [zed-fhs];
|
||||
};
|
||||
|
|
40
modules/nixos/archetypes/workstation/default.nix
Normal file
40
modules/nixos/archetypes/workstation/default.nix
Normal file
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
|
||||
namespace, # The flake namespace, set in flake.nix. If not set, defaults to "internal".
|
||||
system, # The system architecture for this host (eg. `x86_64-linux`).
|
||||
target, # The Snowfall Lib target for this system (eg. `x86_64-iso`).
|
||||
format, # A normalized name for the system target (eg. `iso`).
|
||||
virtual, # A boolean to determine whether this system is a virtual target using nixos-generators.
|
||||
systems, # An attribute map of your defined hosts.
|
||||
|
||||
config,
|
||||
...
|
||||
}: with lib; with lib.${namespace};
|
||||
let
|
||||
cfg = config.${namespace}.archetypes.workstation;
|
||||
in {
|
||||
options.${namespace}.archetypes.workstation = { enable = mkEnableOption "Enable the workstation archetype for your current system"; };
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.sessionVariables = {
|
||||
NIXOS_OZONE_WL = "1"; # Chromium/Electron native Wayland support
|
||||
MOZ_ENABLE_WAYLAND = "1"; # Firefox native Wayland support
|
||||
};
|
||||
|
||||
# Enable modules
|
||||
puzzlevision = {
|
||||
common = {
|
||||
nix.enable = true; # Standard Nix configuration
|
||||
grub.enable = true; # Bootloader grub
|
||||
networking.enable = true; # Networkmanager configuration
|
||||
kernel.enable = true; # Kernel modifications
|
||||
bluetooth.enable = true; # Bluetooth support
|
||||
};
|
||||
|
||||
desktop.gnome.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
37
modules/nixos/common/bluetooth/default.nix
Normal file
37
modules/nixos/common/bluetooth/default.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
|
||||
namespace, # The flake namespace, set in flake.nix. If not set, defaults to "internal".
|
||||
system, # The system architecture for this host (eg. `x86_64-linux`).
|
||||
target, # The Snowfall Lib target for this system (eg. `x86_64-iso`).
|
||||
format, # A normalized name for the system target (eg. `iso`).
|
||||
virtual, # A boolean to determine whether this system is a virtual target using nixos-generators.
|
||||
systems, # An attribute map of your defined hosts.
|
||||
|
||||
config,
|
||||
...
|
||||
}: with lib; with lib.${namespace};
|
||||
let
|
||||
cfg = config.${namespace}.common.bluetooth;
|
||||
in {
|
||||
options.${namespace}.common.bluetooth = { enable = mkEnableOption "Enable bluetooth support on your current system"; };
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
hardware.bluetooth = {
|
||||
enable = true;
|
||||
powerOnBoot = true;
|
||||
package = pkgs.bluez;
|
||||
|
||||
settings = {
|
||||
General = {
|
||||
ControllerMode = "dual";
|
||||
FastConnectable = "true";
|
||||
Experimental = "true";
|
||||
KernelExperimental = "true";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
38
modules/nixos/common/grub/default.nix
Normal file
38
modules/nixos/common/grub/default.nix
Normal file
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
|
||||
namespace, # The flake namespace, set in flake.nix. If not set, defaults to "internal".
|
||||
system, # The system architecture for this host (eg. `x86_64-linux`).
|
||||
target, # The Snowfall Lib target for this system (eg. `x86_64-iso`).
|
||||
format, # A normalized name for the system target (eg. `iso`).
|
||||
virtual, # A boolean to determine whether this system is a virtual target using nixos-generators.
|
||||
systems, # An attribute map of your defined hosts.
|
||||
|
||||
config,
|
||||
...
|
||||
}: with lib; with lib.${namespace};
|
||||
let
|
||||
cfg = config.${namespace}.common.grub;
|
||||
in {
|
||||
options.${namespace}.common.grub = { enable = mkEnableOption "grub"; };
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
boot.loader.grub = {
|
||||
enable = true;
|
||||
devices = [ "nodev" ];
|
||||
efiInstallAsRemovable = true;
|
||||
efiSupport = true;
|
||||
|
||||
extraEntries = ''
|
||||
menuentry "Reboot" {
|
||||
reboot
|
||||
}
|
||||
menuentry "Poweroff" {
|
||||
halt
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
}
|
32
modules/nixos/common/kernel/default.nix
Normal file
32
modules/nixos/common/kernel/default.nix
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
|
||||
namespace, # The flake namespace, set in flake.nix. If not set, defaults to "internal".
|
||||
system, # The system architecture for this host (eg. `x86_64-linux`).
|
||||
target, # The Snowfall Lib target for this system (eg. `x86_64-iso`).
|
||||
format, # A normalized name for the system target (eg. `iso`).
|
||||
virtual, # A boolean to determine whether this system is a virtual target using nixos-generators.
|
||||
systems, # An attribute map of your defined hosts.
|
||||
|
||||
config,
|
||||
...
|
||||
}: with lib; with lib.${namespace};
|
||||
let
|
||||
cfg = config.${namespace}.common.kernel;
|
||||
in {
|
||||
options.${namespace}.common.kernel = {
|
||||
enable = mkEnableOption "Modify the standard kernel settings";
|
||||
version = mkOption {
|
||||
type = lib.types.str;
|
||||
default = "latest";
|
||||
example = "latest";
|
||||
description = "Set the kernel version to be used by your system"
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
kernelPackages = pkgs.linuxPackages_${cfg.version};
|
||||
};
|
||||
}
|
24
modules/nixos/common/networking/default.nix
Normal file
24
modules/nixos/common/networking/default.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
|
||||
namespace, # The flake namespace, set in flake.nix. If not set, defaults to "internal".
|
||||
system, # The system architecture for this host (eg. `x86_64-linux`).
|
||||
target, # The Snowfall Lib target for this system (eg. `x86_64-iso`).
|
||||
format, # A normalized name for the system target (eg. `iso`).
|
||||
virtual, # A boolean to determine whether this system is a virtual target using nixos-generators.
|
||||
systems, # An attribute map of your defined hosts.
|
||||
|
||||
config,
|
||||
...
|
||||
}: with lib; with lib.${namespace};
|
||||
let
|
||||
cfg = config.${namespace}.common.networking;
|
||||
in {
|
||||
options.${namespace}.common.networking = { enable = mkEnableOption "networking"; };
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
networking.networkmanager.enable = true;
|
||||
};
|
||||
}
|
40
modules/nixos/common/nix/default.nix
Normal file
40
modules/nixos/common/nix/default.nix
Normal file
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
|
||||
namespace, # The flake namespace, set in flake.nix. If not set, defaults to "internal".
|
||||
system, # The system architecture for this host (eg. `x86_64-linux`).
|
||||
target, # The Snowfall Lib target for this system (eg. `x86_64-iso`).
|
||||
format, # A normalized name for the system target (eg. `iso`).
|
||||
virtual, # A boolean to determine whether this system is a virtual target using nixos-generators.
|
||||
systems, # An attribute map of your defined hosts.
|
||||
|
||||
config,
|
||||
...
|
||||
}: with lib; with lib.${namespace};
|
||||
let
|
||||
cfg = config.${namespace}.common.nix;
|
||||
in {
|
||||
options.${namespace}.common.nix = { enable = mkEnableOption "nix"; };
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
nix = {
|
||||
settings = {
|
||||
auto-optimise-store = true;
|
||||
builders-use-substitutes = true;
|
||||
experimental-features = [ "nix-command" "flakes" ];
|
||||
keep-derivations = true;
|
||||
keep-outputs = true;
|
||||
max-jobs = "auto";
|
||||
};
|
||||
|
||||
# Garbage collection configuration.
|
||||
gc = {
|
||||
automatic = true;
|
||||
dates = "daily";
|
||||
options = "--delete-older-than 3d";
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
|
@ -29,35 +29,11 @@ with lib.${namespace};
|
|||
inputs.hardware.nixosModules.common-pc-laptop-ssd
|
||||
];
|
||||
|
||||
nix = {
|
||||
settings = {
|
||||
auto-optimise-store = true;
|
||||
builders-use-substitutes = true;
|
||||
experimental-features = [ "nix-command" "flakes" ];
|
||||
keep-derivations = true;
|
||||
keep-outputs = true;
|
||||
max-jobs = "auto";
|
||||
warn-dirty = false;
|
||||
};
|
||||
|
||||
# Garbage collection configuration.
|
||||
gc = {
|
||||
automatic = true;
|
||||
dates = "daily";
|
||||
options = "--delete-older-than 3d";
|
||||
};
|
||||
};
|
||||
|
||||
# Set hostname
|
||||
# Todo: move to common/networking module
|
||||
networking.hostName = "puzzlevision";
|
||||
|
||||
# Enable networking through networkmanager (required for most desktop environments).
|
||||
networking.networkmanager.enable = true;
|
||||
|
||||
boot = {
|
||||
# Always run the latest kernel.
|
||||
kernelPackages = pkgs.linuxPackages_latest;
|
||||
|
||||
# Configure additional kernel modules.
|
||||
extraModulePackages = [
|
||||
pkgs.linuxPackages_latest.rtl8821ce # Use custom network-card driver.
|
||||
|
@ -66,23 +42,6 @@ with lib.${namespace};
|
|||
blacklistedKernelModules = [
|
||||
"rtw88_8821ce" # Block the default network-card driver.
|
||||
];
|
||||
|
||||
# Grub configuration.
|
||||
loader.grub = {
|
||||
enable = true;
|
||||
devices = [ "nodev" ];
|
||||
efiInstallAsRemovable = true;
|
||||
efiSupport = true;
|
||||
|
||||
extraEntries = ''
|
||||
menuentry "Reboot" {
|
||||
reboot
|
||||
}
|
||||
menuentry "Poweroff" {
|
||||
halt
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
# Set timezone.
|
||||
|
@ -127,24 +86,8 @@ with lib.${namespace};
|
|||
pulse.enable = true;
|
||||
};
|
||||
|
||||
# Bluetooth configuration.
|
||||
hardware.bluetooth = {
|
||||
enable = true;
|
||||
powerOnBoot = true;
|
||||
package = pkgs.bluez;
|
||||
|
||||
settings = {
|
||||
General = {
|
||||
ControllerMode = "dual";
|
||||
FastConnectable = "true";
|
||||
Experimental = "true";
|
||||
KernelExperimental = "true";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Enable Gnome
|
||||
puzzlevision.desktop.gnome.enable = true;
|
||||
# Set system Type
|
||||
puzzlevision.archetypes.workstation.enable = true;
|
||||
|
||||
# Enable flatpak support.
|
||||
services.flatpak.enable = true;
|
||||
|
@ -177,7 +120,6 @@ with lib.${namespace};
|
|||
nano
|
||||
firefox
|
||||
chromium
|
||||
lutris
|
||||
vlc
|
||||
spotify
|
||||
|
||||
|
|
Loading…
Reference in a new issue