chore: Change template namespace to 'aux.system'
Some checks are pending
Code Check / Run nixfmt and statix (push) Waiting to run

This commit is contained in:
Andre 2024-06-16 12:52:46 -04:00
parent 2cf855bfae
commit 54f4de49f4
15 changed files with 125 additions and 60 deletions

View file

@ -7,8 +7,10 @@ A ready-to-run NixOS template with sane defaults.
1. Install a fresh copy of NixOS and boot into your new system. 1. Install a fresh copy of NixOS and boot into your new system.
2. Download, copy, or clone this repository onto your new system. 2. Download, copy, or clone this repository onto your new system.
3. Run `nixos-generate-config --show-hardware-config` to generate your system's `hardware-configuration.nix` file. Copy this file into the `host` folder, overwriting the existing file. 3. Run `nixos-generate-config --show-hardware-config` to generate your system's `hardware-configuration.nix` file. Copy this file into the `host` folder, overwriting the existing file.
4. Edit `flake.nix` and set the value of `hostName` to the host name you want to use for this system. 4. Edit `flake.nix` and set the following variables:
4. Edit the `host/configuration.nix` file to suit your needs. This file contains all of the available options and is fully documented. 1. Change `hostName` to the hostname you want to give this system.
2. If your system is running on an architecture other than 64-bit Linux, change `platform` to the architecture that you're using. Details on the various options are documented in `flake.nix`.
4. Edit the `host/configuration.nix` file to suit your needs. This file documents all of the different options available.
5. Run `nixos-rebuild boot --flake .#<your hostname>` and restart. 5. Run `nixos-rebuild boot --flake .#<your hostname>` and restart.
6. Enjoy your new NixOS system! 6. Enjoy your new NixOS system!
@ -48,7 +50,7 @@ To enable Secure Boot support:
... ...
``` ```
2. Generate a set of Secure Boot keys by running the following command: `sudo sbctl create-keys`. This creates a set of keys in `/etc/secureboot`. 2. Generate a set of Secure Boot keys by running the following command: `sudo sbctl create-keys`. This creates a set of keys in `/etc/secureboot`.
3. Enable Secure Boot in your system configuration by setting `aux.bootloader.secureboot.enable = true;`. 3. Enable Secure Boot in your system configuration by setting `aux.system.bootloader.secureboot.enable = true;`.
4. Rebuild your system using `nixos-rebuild switch --flake .`. 4. Rebuild your system using `nixos-rebuild switch --flake .`.
5. Confirm that Secure Boot has been set up properly by running `sudo sbctl verify`: 5. Confirm that Secure Boot has been set up properly by running `sudo sbctl verify`:
```sh ```sh
@ -79,4 +81,4 @@ To enable Secure Boot support:
#### Disabling Secure Boot #### Disabling Secure Boot
To disable Secure Boot, just set `aux.bootloader.secureboot.enable = false;` and rebuild the system. To disable Secure Boot, just set `aux.system.bootloader.secureboot.enable = false;` and rebuild the system.

View file

@ -36,14 +36,21 @@
... ...
}: }:
let let
forAllSystems = ###*** IMPORTANT: Please set your system's hostname here ***###
function: #hostName = builtins.abort "Please set the 'hostName' variable in flake.nix";
nixpkgs.lib.genAttrs [ hostName = "myHost";
"x86_64-linux"
"aarch64-linux" /*
"x86_64-darwin" What kind of system are you running NixOS on?
"aarch64-darwin" If you're not sure, leave this as the default.
] (system: function nixpkgs.legacyPackages.${system});
Options are:
x86_64-linux - (Default) 64-bit PCs.
aarch64-linux - 64-bit ARM PCs.
x86_64-darwin - Intel Macs.
aarch64-darwin - M-series Macs.
*/
platform = "x86_64-linux";
baseModules = [ baseModules = [
./modules/autoimport.nix ./modules/autoimport.nix
@ -64,8 +71,6 @@
}; };
} }
]; ];
###*** IMPORTANT: Please set your system's hostname here ***###
hostName = builtins.abort "Please set the hostName variable in flake.nix";
in in
{ {
nixosConfigurations."${hostName}" = nixpkgs.lib.nixosSystem { nixosConfigurations."${hostName}" = nixpkgs.lib.nixosSystem {
@ -73,7 +78,10 @@
inherit inputs; inherit inputs;
}; };
modules = baseModules ++ [ modules = baseModules ++ [
{ networking.hostName = hostName; } {
networking.hostName = hostName;
nixpkgs.hostPlatform = platform;
}
./host/configuration.nix ./host/configuration.nix
# NixOS-Hardware # NixOS-Hardware
@ -82,6 +90,6 @@
]; ];
}; };
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style); formatter.${platform} = nixpkgs.legacyPackages.${platform}.nixfmt-rfc-style;
}; };
} }

View file

@ -15,18 +15,6 @@ in
system.stateVersion = stateVersion; system.stateVersion = stateVersion;
###*** Configure your system below this line. ***### ###*** Configure your system below this line. ***###
/*
What kind of system are you running NixOS on?
If you're not sure, leave this as the default.
Options are:
x86_64-linux - (Default) 64-bit PCs.
aarch64-linux - 64-bit ARM PCs.
x86_64-darwin - Intel Macs.
aarch64-darwin - M-series Macs.
*/
nixpkgs.hostPlatform = "x86_64-linux";
# Set your time zone. # Set your time zone.
# To see all available timezones, run `timedatectl list-timezones`. # To see all available timezones, run `timedatectl list-timezones`.
time.timeZone = "Europe/Amsterdam"; time.timeZone = "Europe/Amsterdam";
@ -48,10 +36,15 @@ in
home-manager.users.axol = { home-manager.users.axol = {
# The state version is required and should stay at the version you originally installed. # The state version is required and should stay at the version you originally installed.
home.stateVersion = stateVersion; home.stateVersion = stateVersion;
programs = {
# Let home Manager install and manage itself.
home-manager.enable = true;
};
}; };
# Configure the system. # Configure the system.
aux = { aux.system = {
# Enable to allow unfree (e.g. closed source) packages. # Enable to allow unfree (e.g. closed source) packages.
# https://nixos.org/manual/nixpkgs/stable/#sec-allow-unfree # https://nixos.org/manual/nixpkgs/stable/#sec-allow-unfree
allowUnfree = false; allowUnfree = false;

View file

@ -1 +1,63 @@
builtins.abort "Please run 'nixos-generate-config --show-hardware-config' and copy the output into hardware-configuration.nix" #builtins.abort "Please run 'nixos-generate-config --show-hardware-config' and copy the output into hardware-configuration.nix"
# Surface Laptop Go 1st gen
{
config,
lib,
pkgs,
modulesPath,
...
}:
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot = {
initrd = {
availableKernelModules = [
"xhci_pci"
"nvme"
"usb_storage"
"usbhid"
"sd_mod"
];
kernelModules = [ ];
luks.devices."luks-5a91100b-8ed9-4090-b1d8-d8291000fe38".device = "/dev/disk/by-uuid/5a91100b-8ed9-4090-b1d8-d8291000fe38";
};
kernelModules = [ "kvm-intel" ];
extraModulePackages = [ ];
};
fileSystems = {
"/" = {
device = "/dev/disk/by-uuid/76d67291-5aed-4f2a-b71f-1c2871cefe24";
fsType = "btrfs";
options = [ "subvol=@,compress=zstd,discard" ];
};
"/boot" = {
device = "/dev/disk/by-uuid/0C53-A645";
fsType = "vfat";
};
};
swapDevices = [
{
device = "/swapfile";
size = 4096;
}
];
networking = {
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
useDHCP = lib.mkDefault true;
# networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true;
# Set the hostname.
#hostName = "Dimaga";
};
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View file

@ -7,12 +7,12 @@
}: }:
let let
cfg = config.aux.bluetooth; cfg = config.aux.system.bluetooth;
in in
{ {
options = { options = {
aux.bluetooth = { aux.system.bluetooth = {
enable = lib.mkEnableOption (lib.mdDoc "Enables bluetooth"); enable = lib.mkEnableOption (lib.mdDoc "Enables bluetooth");
}; };
}; };

View file

@ -9,12 +9,12 @@
# Bootloader # Bootloader
let let
cfg = config.aux.bootloader; cfg = config.aux.system.bootloader;
in in
{ {
options = { options = {
aux.bootloader = { aux.system.bootloader = {
enable = lib.mkOption { enable = lib.mkOption {
description = "Automatically configures the bootloader. Set to false to configure manually."; description = "Automatically configures the bootloader. Set to false to configure manually.";
type = lib.types.bool; type = lib.types.bool;

View file

@ -8,11 +8,11 @@
}: }:
let let
cfg = config.aux.editor; cfg = config.aux.system.editor;
in in
{ {
options = { options = {
aux.editor = lib.mkOption { aux.system.editor = lib.mkOption {
description = "Selects the default text editor."; description = "Selects the default text editor.";
default = "nano"; default = "nano";
type = lib.types.enum [ type = lib.types.enum [

View file

@ -8,12 +8,12 @@
}: }:
let let
cfg = config.aux; cfg = config.aux.system;
in in
{ {
options = { options = {
aux.allowUnfree = lib.mkEnableOption (lib.mdDoc "Allow unfree packages to install."); aux.system.allowUnfree = lib.mkEnableOption (lib.mdDoc "Allow unfree packages to install.");
aux.retentionPeriod = lib.mkOption { aux.system.retentionPeriod = lib.mkOption {
description = "How long to retain NixOS generations. Defaults to 30 days (30d)."; description = "How long to retain NixOS generations. Defaults to 30 days (30d).";
type = lib.types.str; type = lib.types.str;
default = "30d"; default = "30d";

View file

@ -7,11 +7,11 @@
}: }:
let let
cfg = config.aux.ui.audio; cfg = config.aux.system.ui.audio;
in in
{ {
options = { options = {
aux.ui.audio = { aux.system.ui.audio = {
enable = lib.mkEnableOption (lib.mdDoc "Enables audio."); enable = lib.mkEnableOption (lib.mdDoc "Enables audio.");
enableLowLatency = lib.mkEnableOption ( enableLowLatency = lib.mkEnableOption (
lib.mdDoc "Enables low-latency audio (may cause crackling) per https://nixos.wiki/wiki/PipeWire#Low-latency_setup." lib.mdDoc "Enables low-latency audio (may cause crackling) per https://nixos.wiki/wiki/PipeWire#Low-latency_setup."

View file

@ -6,17 +6,17 @@
... ...
}: }:
let let
cfg = config.aux.ui.desktops.budgie; cfg = config.aux.system.ui.desktops.budgie;
in in
{ {
options = { options = {
aux.ui.desktops.budgie.enable = lib.mkEnableOption ( aux.system.ui.desktops.budgie.enable = lib.mkEnableOption (
lib.mdDoc "Enables the Budgie desktop environment." lib.mdDoc "Enables the Budgie desktop environment."
); );
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
aux.ui.desktops.enable = true; aux.system.ui.desktops.enable = true;
services.xserver = { services.xserver = {
enable = true; enable = true;

View file

@ -7,11 +7,11 @@
}: }:
let let
cfg = config.aux.ui.desktops; cfg = config.aux.system.ui.desktops;
in in
{ {
options = { options = {
aux.ui.desktops = { aux.system.ui.desktops = {
enable = lib.mkEnableOption (lib.mdDoc "Enables base desktop environment support."); enable = lib.mkEnableOption (lib.mdDoc "Enables base desktop environment support.");
xkb = lib.mkOption { xkb = lib.mkOption {
description = "The keyboard layout to use by default. Defaults to us."; description = "The keyboard layout to use by default. Defaults to us.";
@ -25,7 +25,7 @@ in
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
aux.ui.audio.enable = true; aux.system.ui.audio.enable = true;
boot = { boot = {
# Enable Plymouth for graphical bootsplash. # Enable Plymouth for graphical bootsplash.
@ -48,7 +48,7 @@ in
libinput.enable = true; libinput.enable = true;
# Configure keymap in X11 # Configure keymap in X11
xkb = config.aux.ui.desktops.xkb; xkb = config.aux.system.ui.desktops.xkb;
}; };
}; };

View file

@ -6,17 +6,17 @@
... ...
}: }:
let let
cfg = config.aux.ui.desktops.gnome; cfg = config.aux.system.ui.desktops.gnome;
in in
{ {
options = { options = {
aux.ui.desktops.gnome.enable = lib.mkEnableOption ( aux.system.ui.desktops.gnome.enable = lib.mkEnableOption (
lib.mdDoc "Enables the Gnome Desktop Environment." lib.mdDoc "Enables the Gnome Desktop Environment."
); );
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
aux.ui.desktops.enable = true; aux.system.ui.desktops.enable = true;
# Enable Gnome # Enable Gnome
services.xserver = { services.xserver = {

View file

@ -6,17 +6,17 @@
... ...
}: }:
let let
cfg = config.aux.ui.desktops.hyprland; cfg = config.aux.system.ui.desktops.hyprland;
in in
{ {
options = { options = {
aux.ui.desktops.hyprland.enable = lib.mkEnableOption ( aux.system.ui.desktops.hyprland.enable = lib.mkEnableOption (
lib.mdDoc "Enables the Hyprland desktop environment." lib.mdDoc "Enables the Hyprland desktop environment."
); );
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
aux.ui.desktops.enable = true; aux.system.ui.desktops.enable = true;
programs.hyprland = { programs.hyprland = {
enable = true; enable = true;

View file

@ -7,18 +7,18 @@
}: }:
let let
cfg = config.aux.ui.desktops.kde; cfg = config.aux.system.ui.desktops.kde;
in in
{ {
options = { options = {
aux.ui.desktops.kde = { aux.system.ui.desktops.kde = {
enable = lib.mkEnableOption (lib.mdDoc "Enables the KDE Desktop Environment."); enable = lib.mkEnableOption (lib.mdDoc "Enables the KDE Desktop Environment.");
useX11 = lib.mkEnableOption (lib.mdDoc "Uses X11 instead of Wayland."); useX11 = lib.mkEnableOption (lib.mdDoc "Uses X11 instead of Wayland.");
}; };
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
aux.ui.desktops.enable = true; aux.system.ui.desktops.enable = true;
services = { services = {
displayManager.sddm.enable = true; displayManager.sddm.enable = true;

View file

@ -6,17 +6,17 @@
... ...
}: }:
let let
cfg = config.aux.ui.desktops.xfce; cfg = config.aux.system.ui.desktops.xfce;
in in
{ {
options = { options = {
aux.ui.desktops.xfce.enable = lib.mkEnableOption ( aux.system.ui.desktops.xfce.enable = lib.mkEnableOption (
lib.mdDoc "Enables the XFCE desktop environment." lib.mdDoc "Enables the XFCE desktop environment."
); );
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
aux.ui.desktops.enable = true; aux.system.ui.desktops.enable = true;
services.xserver = { services.xserver = {
enable = true; enable = true;