1
0
Fork 0

General: turn templates into actual templates

This commit is contained in:
Aires 2024-12-08 11:12:00 -05:00
parent 992a479496
commit d47f242103
5 changed files with 22 additions and 20 deletions

View file

@ -73,7 +73,7 @@
}; };
in in
lib.mkFlake { lib.mkFlake {
# Configure Nix channels # Allow unfree packages in Nix config
channels-config.allowUnfree = true; channels-config.allowUnfree = true;
# Define systems # Define systems
@ -103,10 +103,6 @@
# Individual host configurations # Individual host configurations
hosts = { hosts = {
Dimaga.modules = with inputs; [
nixos-hardware.nixosModules.common-cpu-intel
];
Hevana.modules = with inputs; [ Hevana.modules = with inputs; [
nixos-hardware.nixosModules.common-cpu-amd-pstate nixos-hardware.nixosModules.common-cpu-amd-pstate
nixos-hardware.nixosModules.common-gpu-amd nixos-hardware.nixosModules.common-gpu-amd
@ -126,6 +122,12 @@
}; };
}; };
# Define .nix file templates
templates = {
module.description = "Template for creating a new module.";
systems.description = "Template for defining a new system.";
};
# Use treefmt to format project repo # Use treefmt to format project repo
outputs-builder = outputs-builder =
channels: channels:

View file

@ -1,3 +1,4 @@
# Extra utility functions
{ {
lib, lib,
}: }:

View file

@ -1,5 +1,10 @@
# This is an example of a blank module. # This is an example of a blank module.
{ config, lib, ... }: {
config,
lib,
namespace,
...
}:
let let
cfg = config.${namespace}.services.myModule; cfg = config.${namespace}.services.myModule;
@ -23,9 +28,9 @@ in
type = lib.types.listOf lib.types.int; type = lib.types.listOf lib.types.int;
description = "An example of a list (of integers) option."; description = "An example of a list (of integers) option.";
}; };
enum = mkOption { enum = lib.mkOption {
default = "one"; default = "one";
type = types.enum [ type = lib.types.enum [
"one" "one"
"two" "two"
]; ];
@ -36,14 +41,14 @@ in
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
# Add changes applied by this module here. # Define the changes applied by this module here.
}; };
systemd.services = { systemd.services = {
# Forces systemd to wait for the module's configuration directory to be available before starting the service. # Tell systemd to wait for the module's configuration directory to be available before starting the service.
myModule.unitConfig.RequiresMountsFor = cfg.home; myModule.unitConfig.RequiresMountsFor = cfg.home;
# Tells Nginx to wait for the service to be available before coming online. # Tell Nginx to wait for the service to be available before coming online.
nginx.wants = [ config.systemd.services.myModule.name ]; nginx.wants = [ config.systemd.services.myModule.name ];
}; };
} }

View file

@ -1,16 +1,11 @@
# Template file for configuring a new host # Template file for configuring a new host
{ {
pkgs,
home-manager,
lib,
config,
namespace, namespace,
... ...
}: }:
let let
# Do not change this value! This tracks when NixOS was installed on your system. # Do not change this value! This tracks when NixOS was installed on your system.
stateVersion = "24.11"; stateVersion = "24.11";
# The hostname for this system. # The hostname for this system.
hostName = "myHost"; hostName = "myHost";
in in
@ -22,7 +17,7 @@ in
system.stateVersion = stateVersion; system.stateVersion = stateVersion;
networking.hostName = hostName; networking.hostName = hostName;
# Configure the system here. # Main system configuration happens here.
config.${namespace} = { config.${namespace} = {
apps = { apps = {
# Define applications here # Define applications here
@ -39,5 +34,5 @@ in
}; };
}; };
# Additional host-specific configuration options go here # Additional configuration options go here
} }

View file

@ -1,8 +1,7 @@
# Template for setting a new host's hardware configuration # Template for setting a new host's hardware configuration
{ {
config,
lib,
modulesPath, modulesPath,
namespace,
... ...
}: }:
let let