Compare commits

...

14 commits

Author SHA1 Message Date
Andre 4eb943d047 refactor(system): fix conflicts between desktop environment login managers
Some checks failed
Code Check / Run nixfmt and statix (push) Waiting to run
Code Check / Run nixfmt and statix (pull_request) Has been cancelled
2024-06-29 13:01:44 -04:00
Andre 64b2ff8d77 fix(system): fix namespacing in various modules 2024-06-29 13:01:44 -04:00
Andre dd04cac4ba fix(system): add initrd settings for tpm2 2024-06-29 13:01:44 -04:00
Andre 08ae068c37 chore: update video driver syntax to match upstream 2024-06-29 13:01:44 -04:00
Andre 73e33a1d95 chore: Simplify Nix config file in template 2024-06-29 13:01:44 -04:00
Andre cf3847efa3 bugfix: Remove lingering reference to auxlibs; Leave Totem in Gnome installs 2024-06-29 13:01:44 -04:00
Andre 6874673edf feat: Add Lix to new user template 2024-06-29 13:01:44 -04:00
Andre 8f94796401 chore: Cleanup template readme and options 2024-06-29 13:01:44 -04:00
Andre 6f3a935780 Fix funky unicode quotes 2024-06-29 13:01:44 -04:00
Andre 1873af7524 chore: Remove Aux Libs input 2024-06-29 13:01:44 -04:00
Andre f1df1a35bf feat: Add Flatpak support
chore: Prep for PR
2024-06-29 13:01:44 -04:00
Andre a2b1a8af4f feat(system): Add Nvidia, Intel, and AMD GPU support to new user template
chore(system): update top-level Readme file
2024-06-29 12:56:03 -04:00
Andre 4648af5704 chore: Change template namespace to 'aux.system' 2024-06-29 12:56:03 -04:00
Andre 79a9fda6b7 feat(system): add modules for bluetooth, networking, system config, Budgie, Hyprland, and XFCE to system template
fix(system): re-enable abort conditions in new user template
2024-06-29 12:54:47 -04:00
22 changed files with 840 additions and 155 deletions

View file

@ -17,7 +17,7 @@
There are 3 main templates in this repository:
- `darwin` - The system configuration for the Darwin operating system (macOS)
- `system` - The system configuration for the Linux operating system
- `system` - A complete NixOS system configuration template for the Linux operating system
- `home-manager` - The configuration for the home-manager
#### With Darwin (macOS)
@ -30,13 +30,15 @@ There are 3 main templates in this repository:
#### With NixOS
1. Run `nix --extra-experimental-features nix-command --extra-experimental-features flakes flake new -t github:auxolotl/templates#system NixFiles`
2. Move into your new system with `cd NixFiles`
3. Fill in your `hostName` in `flake.nix`
4. Run `nixos-generate-config --show-hardware-config > hardware-configuration.nix` to generate configuration based on your filesystems and drivers
5. Run `nixos-rebuild build --flake .#hostName`, replacing hostName with your new hostName
1. Install a base NixOS system
2. Run `nix --extra-experimental-features nix-command --extra-experimental-features flakes flake new -t github:auxolotl/templates#system NixFiles`
3. Move into your new system with `cd NixFiles`
4. Fill in your `hostName` in `flake.nix`
5. Run `nixos-generate-config --show-hardware-config > host/hardware-configuration.nix` to generate configuration based on your filesystems and drivers
6. Edit the `host/configuration.nix` file with your desired system configuration
7. Run `nixos-rebuild build --flake .#hostName`, replacing hostName with your new hostName
Congratulations, you are now using Aux!
Congratulations, you are now using NixOS!
#### With Home-manager

View file

@ -1,12 +1,93 @@
# Auxolotl System Template
# Auxolotl New User System Configuration
A (nearly) complete and ready-to-run NixOS template.
A ready-to-run NixOS configuration with opinionated defaults.
The goal of this config is to make it as easy as possible to build a NixOS system for an out-of-the-box experience similar to user-friendly distributions like Ubuntu, Fedora, or Mint. Nearly all configuration is done by editing `host/configuration.nix`. Where possible, we provided simple boolean (true/false) flags for enabling things like GPU drivers and desktop environments. These options are made available under the `aux.system` namespace. You can, of course, extend this template however you'd like.
## Getting Started
1. Install a fresh copy of NixOS and boot into your new system.
2. Run [command] to generate your system's `hardware-configuration.nix` file.
3. Copy `hardware-configuration.nix` into the `hosts/myHost` folder.
4. Edit the `hosts/myHost/configuration.nix` file to suit your needs. This file is fully documented with all of the different options available in this template.
5. Run `nixos-rebuild boot --flake .` and restart.
6. Enjoy your new NixOS system!
1. [Install a fresh copy of NixOS and boot into your new system](https://nixos.org/manual/nixos/stable/index.html#ch-installation).
2. Open a terminal and create a new copy of this template by running `nix --extra-experimental-features nix-command --extra-experimental-features flakes flake new -t github:auxolotl/templates#system nixos-config`.
3. Change into the new folder using `cd nixos-config`.
4. 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 `hardware-configuration.nix` file.
5. Edit `flake.nix` and set the following variables:
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`.
6. Edit the `host/configuration.nix` file to suit your needs. This file documents all of the different options available. In most cases, you can enable an option by changing `false` to `true`.
1. Change the `username` variable. If you installed NixOS using the standard install medium, you can change this to match the username you chose during installation. Otherwise, it will create a new user account.
2. If you're creating a new user account, don't forget to set its password by running `sudo passwd <username>`.
7. Run `sudo nixos-rebuild boot --flake .#<your hostname>` and restart.
8. Enjoy your new NixOS system!
## Additional options
This section is for options that require additional information or setup.
### Hardware-specific options
NixOS-Hardware is a community library of NixOS modules to work around quirks with specific kinds of hardware, especially laptops and SBCs like Raspberry Pis. If you know your system's model, you can see if it's available in [NixOS-Hardware by checking the project's flake.nix](https://github.com/NixOS/nixos-hardware/blob/master/flake.nix). If so, add its module to your host's `flake.nix` like so:
```nix
modules = [
...
nixos-hardware.nixosModules.framework-13th-gen-intel
...
]
```
#### Nvidia GPU support
For users with a hybrid Nvidia GPU setup (e.g. laptop users), there's some additional setup you need to do. This setup requires you to find the PCI bus IDs for your Nvidia GPU and your secondary GPU (usually an integrated Intel or AMD GPU). [The NixOS wiki has instructions on how to find these](https://nixos.wiki/wiki/Nvidia#Laptop_Configuration:_Hybrid_Graphics_.28Nvidia_Optimus_PRIME.29). Once you have the bus IDs, you can set `aux.system.gpu.nvidia.hybrid.busIDs.intel` or `aux.system.gpu.nvidia.hybrid.busIDs.amd`.
### Secure Boot support
This configuration supports [Secure Boot](https://wiki.archlinux.org/title/Unified_Extensible_Firmware_Interface/Secure_Boot) systems, but with some additional setup required. Secure Boot is a UEFI standard meant to prevent tampering with the pre-boot process, e.g. by a malicious third-party replacing your kernel image with a compromised image. In NixOS, Secure Boot support is provided by the [Lanzaboote](https://github.com/nix-community/lanzaboote) project.
To enable Secure Boot support:
1. Install NixOS using the default `systemd-boot` bootloader, and with Secure Boot disabled via UEFI. To confirm this, run `bootctl status` on a fresh NixOS installation and look for output similar to the following:
```sh
$ bootctl status
System:
Firmware: UEFI 2.70 (Lenovo 0.4720)
Secure Boot: disabled (disabled)
TPM2 Support: yes
Boot into FW: supported
Current Boot Loader:
Product: systemd-boot 251.7
...
```
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.system.bootloader.secureboot.enable = true;`.
4. Rebuild your system using `nixos-rebuild switch --flake .`.
5. Confirm that Secure Boot has been set up properly by running `sudo sbctl verify`:
```sh
Verifying file database and EFI images in /boot...
✓ /boot/EFI/BOOT/BOOTX64.EFI is signed
✓ /boot/EFI/Linux/nixos-generation-355.efi is signed
✓ /boot/EFI/Linux/nixos-generation-356.efi is signed
✗ /boot/EFI/nixos/0n01vj3mq06pc31i2yhxndvhv4kwl2vp-linux-6.1.3-bzImage.efi is not signed
✓ /boot/EFI/systemd/systemd-bootx64.efi is signed
```
6. Reboot into your system's UEFI firmware. An easy way to do this from a running system is to run `systemctl reboot --firmware-setup`. In UEFI, set Secure Boot to setup mode. This will vary by system and UEFI vendor. On a ThinkPad, you can find these settings by selecting the "Security" tab, then the "Secure Boot" entry. Set "Secure Boot" to enabled, then select "Reset to Setup Mode". Save your changes and exit.
- On systems where there is no setup mode, choose the option to erase the existing Platform key, and/or to allow third-party keys.
7. Once you've rebooted into NixOS, run this command to enroll your keys: `sudo sbctl enroll-keys --microsoft`. You should see the following output:
```sh
Enrolling keys to EFI variables...
With vendor keys from microsoft...✓
Enrolled keys to the EFI variables!
```
8. Reboot your system, then verify your keys were installed correctly using `bootctl status`:
```sh
System:
Firmware: UEFI 2.70 (Lenovo 0.4720)
Firmware Arch: x64
Secure Boot: enabled (user)
TPM2 Support: yes
Boot into FW: supported
```
#### Disabling Secure Boot
To disable Secure Boot, just set `aux.system.bootloader.secureboot.enable = false;` and rebuild the system.

View file

@ -1,58 +1,97 @@
{
description = "A system flake with various options for bootstrapping a complete Aux install.";
description = "A system flake with various options for bootstrapping a complete NixOS install.";
inputs = {
# Import Auxolotl libs
auxlib.url = "https://git.auxolotl.org/auxolotl/labs/archive/main.tar.gz?dir=lib";
# Import the desired Nixpkgs repo. Defaults to unstable.
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
# Import the desired Nix channel. Defaults to unstable, which uses a fully tested rolling release model.
# You can find a list of channels at https://nixos.wiki/wiki/Nix_channels
# To follow a different channel, replace `nixos-unstable` with the channel name, e.g. `nixos-24.05`.
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# Use Lix in place of Nix.
# If you'd rather use regular Nix, remove `lix-module.nixosModules.default` from the `modules` section below.
# To learn more about Lix, see https://lix.systems/
lix-module = {
url = "https://git.lix.systems/lix-project/nixos-module/archive/2.90.0-rc1.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
};
# Flatpak support
nix-flatpak.url = "github:gmodena/nix-flatpak/v0.4.1";
# SecureBoot support
lanzaboote.url = "github:nix-community/lanzaboote/v0.4.0";
# NixOS hardware quirks
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
# Home-manager support
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{
self,
nixpkgs,
home-manager,
lanzaboote,
auxlib,
lix-module,
nix-flatpak,
nixos-hardware,
nixpkgs,
...
}:
let
forAllSystems =
function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
] (system: function nixpkgs.legacyPackages.${system});
###*** IMPORTANT: Please set your system's hostname here ***###
hostName = builtins.abort "Please set the 'hostName' variable in flake.nix";
baseModules = [
./modules/autoimport.nix
lanzaboote.nixosModules.lanzaboote
];
/*
What kind of system are you running NixOS on?
If you're not sure, leave this as the default.
system = "x86_64-linux";
hostName = builtins.abort "You need to fill in your hostName"; # Set this variable equal to your hostName
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";
in
{
nixosConfigurations."myHost" = nixpkgs.lib.nixosSystem {
nixosConfigurations."${hostName}" = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs;
};
system = "x86_64-linux";
modules = baseModules ++ [
./host/configuration.nix
modules = [
{
networking.hostName = hostName;
nixpkgs.hostPlatform = system;
nixpkgs.hostPlatform = platform;
home-manager = {
/*
When running, Home Manager will use the global package cache.
It will also back up any files that it would otherwise overwrite.
The originals will have the extension ".home-manager_backup".
*/
useGlobalPkgs = true;
useUserPackages = true;
backupFileExtension = "home-manager_backup";
};
}
./modules/autoimport.nix
home-manager.nixosModules.home-manager
lanzaboote.nixosModules.lanzaboote
lix-module.nixosModules.default
nix-flatpak.nixosModules.nix-flatpak
./host/configuration.nix
# NixOS-Hardware
# Add your model from this list: https://github.com/NixOS/nixos-hardware/blob/master/flake.nix
# nixos-hardware.nixosModules.framework-13th-gen-intel
];
};
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
formatter.${platform} = nixpkgs.legacyPackages.${platform}.nixfmt-rfc-style;
};
}

View file

@ -5,38 +5,125 @@
...
}:
let
# Do not change this value! This tracks when NixOS was installed on your system.
stateVersion = "24.11";
# Set the username for the initial user.
username = builtins.abort "Please set your username via the 'username' variable in configuration.nix";
in
{
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
];
imports = [ ./hardware-configuration.nix ];
###*** Please set these variables first. ***###
nixpkgs.hostPlatform = "x86_64-linux"; # This assumes this is a standard 64-bit Linux system.
system.stateVersion = stateVersion;
###*** Configure your system below this line. ***###
# Set your time zone.
# To see all available timezones, run `timedatectl list-timezones`.
time.timeZone = "Europe/Amsterdam";
# Define a user account. Don't forget to set a password with passwd.
users.users.axol = {
# Define your user account(s). If this user doesn't already have a password, don't forget to set one using `passwd`.
users.users.${username} = {
isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable sudo for the user.
packages = with pkgs; [ ]; # Enter any additional packages specific to this user here.
extraGroups = [ "wheel" ];
# Enter any additional packages specific to this user here.
packages = with pkgs; [ ];
};
###*** This is where you toggle options. ***###
###*** To enable an option, set its value to "true". ***###
aux = {
editor = "nano"; # Change the default text editor. Options are "emacs", "nano", or "vim".
# Configure home-manager for your user.
# For configuration options, see https://nix-community.github.io/home-manager/#using-home-manager
home-manager.users.${username} = {
# The state version is required and should stay at the version you originally installed.
home.stateVersion = stateVersion;
programs = {
# Let home Manager install and manage itself.
home-manager.enable = true;
};
};
# Configure the system.
aux.system = {
# Enable to allow unfree (e.g. closed source) packages.
# Some settings may override this (e.g. enabling Nvidia GPU support).
# https://nixos.org/manual/nixpkgs/stable/#sec-allow-unfree
allowUnfree = false;
# Enable Secure Boot support.
# IMPORTANT: Read the README before enabling this option!
bootloader.secureboot.enable = false;
# Change the default text editor. Options are "emacs", "nano", or "vim".
editor = "nano";
ui.flatpak = {
# Enable Flatpak support.
enable = false;
# Define Flatpak packages to install.
packages = [ ];
};
# Additional system packages to install.
packages = [ ];
# Change how long old generations are kept for.
retentionPeriod = "30d";
# Enable GPU support.
gpu = {
# Enable AMD GPU support.
amd.enable = false;
# Enable Intel GPU support.
intel.enable = false;
nvidia = {
# Enable Nvidia GPU support.
enable = false;
hybrid = {
# Enables support for hybrid GPUs (e.g. for laptops and systems with integrated GPUs).
enable = false;
# Define the bus IDs for your GPUs.
# For more info on where to find bus IDs, see https://nixos.wiki/wiki/Nvidia#Configuring_Optimus_PRIME:_Bus_ID_Values_.28Mandatory.29
busIDs = {
nvidia = "";
intel = "";
amd = "";
};
# Enable sync mode for faster performance at the cost of higher battery usage.
# If sync is disabled, you'll need to run GPU-accelerated applications using 'nvidia-offload <command>'.
sync = false;
};
};
};
ui.desktops = {
gnome.enable = false; # Enable the Gnome desktop environment.
kde.enable = false; # Enable the KDE desktop environment.
# Enable the Budgie desktop environment.
# https://buddiesofbudgie.org/
budgie.enable = false;
# Enable the Hyprland desktop environment.
# https://hyprland.org/
hyprland.enable = false;
# Enable the Gnome desktop environment.
# https://www.gnome.org/
gnome.enable = false;
# Enable the KDE desktop environment.
# https://kde.org/
kde.useX11 = false;
# Enable the XFCE desktop environment.
# https://xfce.org/
xfce.enable = false;
};
};
# Enable printing via CUPS
services.printing.enable = false;
# Do not change this value!
system.stateVersion = "24.11";
}

View file

@ -1,39 +1 @@
#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,
hostName,
...
}:
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot = {
initrd = {
availableKernelModules = [ ];
kernelModules = [ ];
};
kernelModules = [ ];
extraModulePackages = [ ];
};
fileSystems = {
"/" = {
device = "/dev/sda2";
fsType = "btrfs";
options = [ "subvol=@,compress=zstd,discard" ];
};
"/boot" = {
device = "/dev/sda1";
fsType = "vfat";
};
};
networking.useDHCP = lib.mkDefault true;
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}
builtins.abort "Please run 'nixos-generate-config --show-hardware-config' and copy the output into hardware-configuration.nix"

View file

@ -0,0 +1,37 @@
# Configures bluetooth.
{
lib,
config,
pkgs,
...
}:
let
cfg = config.aux.system.bluetooth;
in
{
options = {
aux.system.bluetooth = {
enable = lib.mkEnableOption (lib.mdDoc "Enables bluetooth");
};
};
config = lib.mkIf cfg.enable {
# Set up Bluetooth
hardware.bluetooth = {
enable = true;
powerOnBoot = true;
settings = {
General = {
Enable = "Source,Sink,Media,Socket";
Experimental = true;
KernelExperimental = true;
};
};
};
# Add Bluetooth LE audio support
environment.systemPackages = with pkgs; [ liblc3 ];
};
}

View file

@ -9,12 +9,12 @@
# Bootloader
let
cfg = config.aux.bootloader;
cfg = config.aux.system.bootloader;
in
{
options = {
aux.bootloader = {
aux.system.bootloader = {
enable = lib.mkOption {
description = "Automatically configures the bootloader. Set to false to configure manually.";
type = lib.types.bool;
@ -45,6 +45,13 @@ in
# Set up TPM if enabled. See https://nixos.wiki/wiki/TPM
(lib.mkIf (cfg.tpm2.enable) {
boot.initrd = {
# Enable systemd for TPM auto-unlocking
systemd.enable = true;
availableKernelModules = [ "tpm_crb" ];
kernelModules = [ "tpm_crb" ];
};
# After installing and rebooting, set it up via https://wiki.archlinux.org/title/Systemd-cryptenroll#Trusted_Platform_Module
environment.systemPackages = with pkgs; [ tpm2-tss ];
security.tpm2 = {

View file

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

View file

@ -0,0 +1,27 @@
# Enables AMD GPU support.
{
pkgs,
config,
lib,
...
}:
let
cfg = config.aux.system.gpu.amd;
in
{
options = {
aux.system.gpu.amd.enable = lib.mkEnableOption (lib.mdDoc "Enables AMD GPU support.");
};
config = lib.mkIf cfg.enable {
boot.initrd.kernelModules = [ "amdgpu" ];
services.xserver.videoDrivers = [ "amdgpu" ];
hardware.graphics = {
extraPackages = [ pkgs.amdvlk ];
# 32-bit application compatibility
enable32Bit = true;
extraPackages32 = with pkgs; [ driversi686Linux.amdvlk ];
};
};
}

View file

@ -0,0 +1,44 @@
# Enables Intel GPU support.
{
pkgs,
config,
lib,
...
}:
let
cfg = config.aux.system.gpu.intel;
in
{
options = {
aux.system.gpu.intel.enable = lib.mkEnableOption (lib.mdDoc "Enables Intel GPU support.");
};
config = lib.mkIf cfg.enable {
# Configuration options from NixOS-Hardware: https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/intel/default.nix
boot.initrd.kernelModules = [ "i915" ];
environment.variables.VDPAU_DRIVER = "va_gl";
hardware.graphics.extraPackages = with pkgs; [
(
if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") then
vaapiIntel
else
intel-vaapi-driver
)
libvdpau-va-gl
intel-media-driver
];
hardware.graphics.extraPackages32 = with pkgs.driversi686Linux; [
(
if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") then
vaapiIntel
else
intel-vaapi-driver
)
libvdpau-va-gl
intel-media-driver
];
};
}

View file

@ -0,0 +1,81 @@
# Enables Nvidia GPU support.
{
pkgs,
config,
lib,
...
}:
let
cfg = config.aux.system.gpu.nvidia;
in
{
options = {
aux.system.gpu.nvidia = {
enable = lib.mkEnableOption (lib.mdDoc "Enables Nvidia GPU support.");
hybrid = {
enable = lib.mkEnableOption (lib.mdDoc "Enables hybrid GPU support.");
sync = lib.mkEnableOption (
lib.mdDoc "Enables sync mode for faster performance at the cost of higher battery usage."
);
busIDs = {
nvidia = lib.mkOption {
description = "The bus ID for your Nvidia GPU.";
type = lib.types.str;
example = "PCI:0:2:0";
default = "";
};
intel = lib.mkOption {
description = "The bus ID for your integrated Intel GPU. If you don't have an Intel GPU, you can leave this blank.";
type = lib.types.str;
example = "PCI:14:0:0";
default = "";
};
amd = lib.mkOption {
description = "The bus ID for your integrated AMD GPU. If you don't have an AMD GPU, you can leave this blank.";
type = lib.types.str;
example = "PCI:54:0:0";
default = "";
};
};
};
};
};
config = lib.mkIf cfg.enable {
assertions = [
{
assertion = (cfg.busIDs.nvidia == "");
message = "You need to define a bus ID for your Nvidia GPU. To learn how to find the bus ID, see https://nixos.wiki/wiki/Nvidia#Configuring_Optimus_PRIME:_Bus_ID_Values_.28Mandatory.29.";
}
{
assertion = (cfg.busIDs.intel == "" && cfg.busIDs.amd == "");
message = "You need to define a bus ID for your non-Nvidia GPU. To learn how to find your bus ID, see https://nixos.wiki/wiki/Nvidia#Configuring_Optimus_PRIME:_Bus_ID_Values_.28Mandatory.29.";
}
];
aux.system.allowUnfree = true;
services.xserver.videoDrivers = lib.mkDefault [ "nvidia" ];
hardware.opengl.extraPackages = with pkgs; [ vaapiVdpau ];
hardware.nvidia = {
modesetting.enable = true;
nvidiaSettings = lib.mkIf (config.aux.system.ui.desktops.enable) true;
package = config.boot.kernelPackages.nvidiaPackages.stable;
prime = lib.mkIf cfg.hybrid.enable {
offload = lib.mkIf (!cfg.hybrid.sync) {
enable = true;
enableOffloadCmd = true; # Provides `nvidia-offload` command.
};
sync.enable = lib.mkIf cfg.hybrid.sync true;
nvidiaBusId = cfg.hybrid.busIDs.nvidia;
intelBusId = lib.mkIf (cfg.hybrid.busIDs.intel != "") cfg.hybrid.busIDs.intel;
amdgpuBusId = lib.mkIf (cfg.hybrid.busIDs.amd != "") cfg.hybrid.busIDs.amd;
};
};
};
}

View file

@ -0,0 +1,11 @@
# Configure basic networking options.
_: {
networking = {
# Enable networking via NetworkManager
networkmanager.enable = true;
# Enable firewall
nftables.enable = true;
firewall.enable = true;
};
}

View file

@ -6,19 +6,45 @@
inputs,
...
}:
let
cfg = config.aux.system;
in
{
nix = {
# Enable Flakes
settings.experimental-features = [
"nix-command"
"flakes"
];
options = {
aux.system.allowUnfree = lib.mkEnableOption (lib.mdDoc "Allow unfree packages to install.");
aux.system.retentionPeriod = lib.mkOption {
description = "How long to retain NixOS generations. Defaults to 30 days (30d).";
type = lib.types.str;
default = "30d";
};
};
config = {
nixpkgs.config.allowUnfree = cfg.allowUnfree;
# Enable periodic nix store optimization
optimise.automatic = true;
nix = {
# Enable Flakes
settings.experimental-features = [
"nix-command"
"flakes"
];
# Configure NixOS to use the same software channel as Flakes
registry = lib.mapAttrs (_: value: { flake = value; }) inputs;
nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry;
# Enable periodic nix store optimization
optimise.automatic = true;
# Enable weekly garbage collection. Delete generations that are older than two weeks.
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than ${cfg.retentionPeriod}";
};
# Configure NixOS to use the same software channel as Flakes
registry = lib.mapAttrs (_: value: { flake = value; }) inputs;
nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry;
};
# Support for standard, dynamically-linked executables
programs.nix-ld.enable = true;
};
}

View file

@ -0,0 +1,52 @@
# Base system settings and options
{
pkgs,
config,
lib,
...
}:
let
cfg = config.aux.system;
in
{
options = {
aux.system.packages = lib.mkOption {
description = "Additional system packages to install. This is just a wrapper for environment.systemPackages.";
type = lib.types.listOf lib.types.package;
default = [ ];
example = lib.literalExpression "[ pkgs.firefox pkgs.thunderbird ]";
};
};
config = {
# Install the latest kernel
boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest;
# Set up the environment
environment = {
# Install base packages
systemPackages =
config.aux.system.packages
++ (with pkgs; [
bash
dconf # Needed to fix an issue with Home-manager. See https://github.com/nix-community/home-manager/issues/3113
direnv
git
home-manager
p7zip
]);
};
services = {
# Enable fwupd (firmware updater)
fwupd.enable = true;
# Enable trim on supported drives
fstrim.enable = true;
# Enable disk monitoring
smartd = {
enable = true;
autodetect = true;
};
};
};
}

View file

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

View file

@ -0,0 +1,33 @@
# Enables the Budgie desktop environment.
{
pkgs,
config,
lib,
...
}:
let
cfg = config.aux.system.ui.desktops.budgie;
in
{
options = {
aux.system.ui.desktops.budgie.enable = lib.mkEnableOption (
lib.mdDoc "Enables the Budgie desktop environment."
);
};
config = lib.mkIf cfg.enable {
aux.system.ui.desktops = {
enable = true;
displayManager = lib.mkOptionDefault "lightdm";
};
services.xserver = {
enable = true;
desktopManager.budgie.enable =
if config.services.xserver.desktopManager.gnome.enable then
builtins.abort "Budgie and Gnome cannot be enabled at the same time due to a bug. For details and a possible workaround, please see https://discourse.nixos.org/t/help-i-cant-have-pantheon-gnome-and-plasma-installed-on-my-system-at-the-same-time/47346"
else
true;
};
};
}

View file

@ -7,11 +7,11 @@
}:
let
cfg = config.aux.ui.desktops;
cfg = config.aux.system.ui.desktops;
in
{
options = {
aux.ui.desktops = {
aux.system.ui.desktops = {
enable = lib.mkEnableOption (lib.mdDoc "Enables base desktop environment support.");
xkb = lib.mkOption {
description = "The keyboard layout to use by default. Defaults to us.";
@ -21,11 +21,34 @@ in
variant = "";
};
};
displayManager = lib.mkOption {
description = "The display manager to use to start a desktop session.";
type = lib.types.enum [
"gdm"
"lightdm"
"sddm"
"sddm_wayland"
];
};
};
};
config = lib.mkIf cfg.enable {
aux.ui.audio.enable = true;
aux.system = {
bluetooth.enable = true;
ui.audio.enable = true;
};
boot = {
# Enable Plymouth for graphical bootsplash.
plymouth = {
enable = true;
theme = "bgrt";
};
# Add kernel parameters
kernelParams = [ "quiet" ];
};
services = {
# Configure the xserver
@ -33,12 +56,23 @@ in
# Enable the X11 windowing system.
enable = true;
# Enable touchpad support (enabled by default in most desktop managers, buuuut just in case).
libinput.enable = true;
# Configure keymap in X11
xkb = config.aux.ui.desktops.xkb;
xkb = config.aux.system.ui.desktops.xkb;
# Set the display manager
displayManager = {
gdm.enable = (cfg.displayManager == "gdm");
lightdm.enable = (cfg.displayManager == "lightdm");
};
};
displayManager = {
sddm.enable = (cfg.displayManager == "sddm");
sddm.wayland.enable = (cfg.displayManager == "sddm_wayland");
};
# Enable touchpad support (enabled by default in most desktop managers, buuuut just in case).
libinput.enable = true;
};
# Support for AppImage files
@ -46,5 +80,24 @@ in
enable = true;
binfmt = true;
};
# Install full GStreamer capabilities.
# References:
# https://wiki.nixos.org/wiki/GStreamer
# https://github.com/NixOS/nixpkgs/issues/195936
environment = {
sessionVariables.GST_PLUGIN_SYSTEM_PATH_1_0 = lib.makeSearchPathOutput "lib" "lib/gstreamer-1.0" (
with pkgs.gst_all_1;
[
gstreamer
gst-plugins-base
gst-plugins-good
gst-plugins-bad
gst-plugins-ugly
gst-libav
gst-vaapi
]
);
};
};
}

View file

@ -6,32 +6,33 @@
...
}:
let
cfg = config.aux.ui.desktops.gnome;
cfg = config.aux.system.ui.desktops.gnome;
in
{
options = {
aux.ui.desktops.gnome.enable = lib.mkEnableOption (
aux.system.ui.desktops.gnome.enable = lib.mkEnableOption (
lib.mdDoc "Enables the Gnome Desktop Environment."
);
};
config = lib.mkIf cfg.enable {
aux.ui.desktops.enable = true;
aux.system.ui.desktops = {
enable = true;
displayManager = lib.mkOverride 500 "gdm";
};
# Enable Gnome
services.xserver = {
# Remove default packages that came with the install
excludePackages = [ pkgs.xterm ];
desktopManager.gnome.enable = true;
displayManager.gdm.enable = true;
desktopManager.gnome.enable = lib.mkDefault true;
};
environment = {
# Remove extraneous Gnome packages
gnome.excludePackages = with pkgs.gnome; [
gnome-software # Built-in software manager
totem # video player
tali # poker game
iagno # go game
hitori # sudoku game
@ -43,25 +44,11 @@ in
gnome.gnome-tweaks # Gnome tweak tool
gnome.gnome-themes-extra # Additional themes
];
# Install GStreamer plugins
# References:
# https://wiki.nixos.org/wiki/GStreamer
# https://github.com/NixOS/nixpkgs/issues/195936
sessionVariables.GST_PLUGIN_SYSTEM_PATH_1_0 = lib.makeSearchPathOutput "lib" "lib/gstreamer-1.0" (
with pkgs.gst_all_1;
[
gstreamer
gst-plugins-base
gst-plugins-good
gst-plugins-bad
gst-plugins-ugly
gst-libav
gst-vaapi
]
);
};
# Manually set askPassword to avoid a conflict with KDE
programs.ssh.askPassword = "${pkgs.gnome.seahorse}/libexec/seahorse/ssh-askpass";
# Gnome UI integration for KDE apps
qt = {
enable = true;

View file

@ -0,0 +1,28 @@
# Enables the Hyprland desktop environment.
{
pkgs,
config,
lib,
...
}:
let
cfg = config.aux.system.ui.desktops.hyprland;
in
{
options = {
aux.system.ui.desktops.hyprland.enable = lib.mkEnableOption (
lib.mdDoc "Enables the Hyprland desktop environment."
);
};
config = lib.mkIf cfg.enable {
aux.system.ui.desktops.enable = true;
programs.hyprland = {
enable = true;
xwayland.enable = true;
};
# Optional: hint Electron apps to use Wayland:
environment.sessionVariables.NIXOS_OZONE_WL = "1";
};
}

View file

@ -7,27 +7,35 @@
}:
let
cfg = config.aux.ui.desktops.kde;
cfg = config.aux.system.ui.desktops.kde;
in
{
options = {
aux.ui.desktops.kde = {
aux.system.ui.desktops.kde = {
enable = lib.mkEnableOption (lib.mdDoc "Enables the KDE Desktop Environment.");
useX11 = lib.mkEnableOption (lib.mdDoc "Uses X11 instead of Wayland.");
};
};
config = lib.mkIf cfg.enable {
aux.ui.desktops.enable = true;
aux.system.ui.desktops = {
enable = true;
displayManager = if cfg.useX11 then lib.mkDefault "sddm" else lib.mkDefault "sddm_wayland";
};
programs.dconf.enable = true;
# Fix blank messages in KMail. See https://nixos.wiki/wiki/KDE#KMail_Renders_Blank_Messages
environment.sessionVariables = {
NIX_PROFILES = "${pkgs.lib.concatStringsSep " " (
pkgs.lib.reverseList config.environment.profiles
)}";
};
services = {
displayManager.sddm.enable = true;
desktopManager.plasma6.enable = true;
xserver.displayManager = lib.mkIf cfg.useX11 {
defaultSession = "plasmaX11";
sddm.wayland.enable = true;
};
xserver.displayManager = lib.mkIf cfg.useX11 { defaultSession = "plasmaX11"; };
};
# Enable Gnome integration

View file

@ -0,0 +1,35 @@
# Enables the XFCE desktop environment.
{
pkgs,
config,
lib,
...
}:
let
cfg = config.aux.system.ui.desktops.xfce;
in
{
options = {
aux.system.ui.desktops.xfce.enable = lib.mkEnableOption (
lib.mdDoc "Enables the XFCE desktop environment."
);
};
config = lib.mkIf cfg.enable {
aux.system.ui.desktops = {
enable = true;
displayManager = lib.mkOptionDefault "lightdm";
};
services = {
displayManager.defaultSession = "xfce";
xserver = {
enable = true;
desktopManager = {
xterm.enable = false;
xfce.enable = true;
};
};
};
};
}

View file

@ -0,0 +1,85 @@
# Enable support for Flatpak applications
{
nix-flatpak,
pkgs,
config,
lib,
...
}:
let
cfg = config.aux.system.ui.flatpak;
in
with lib;
{
options = {
aux.system.ui.flatpak = {
enable = mkEnableOption (mdDoc "Enables Flatpak support.");
packages = lib.mkOption {
description = "Flatpak packages to install.";
type = lib.types.listOf lib.types.str;
default = [ ];
example = lib.literalExpression "[ \"com.valvesoftware.Steam\" ]";
};
};
};
config = mkIf cfg.enable {
# Enable Flatpak
services.flatpak = {
enable = true;
# Manage all Flatpak packages and remotes
uninstallUnmanaged = true;
# Enable automatic updates alongside nixos-rebuild
update.onActivation = true;
# Add remote(s)
remotes = [
{
name = "flathub";
location = "https://dl.flathub.org/repo/flathub.flatpakrepo";
}
];
# Install base Flatpaks. For details, see https://github.com/gmodena/nix-flatpak
packages = cfg.packages;
};
# Workaround for getting Flatpak apps to use system fonts, icons, and cursors
# For details (and source), see https://github.com/NixOS/nixpkgs/issues/119433#issuecomment-1767513263
# NOTE: If fonts in Flatpaks appear incorrect (like squares), run this command to regenerate the font cache:
# flatpak list --columns=application | xargs -I %s -- flatpak run --command=fc-cache %s -f -v
system.fsPackages = [ pkgs.bindfs ];
fileSystems =
let
mkRoSymBind = path: {
device = path;
fsType = "fuse.bindfs";
options = [
"ro"
"resolve-symlinks"
"x-gvfs-hide"
];
};
aggregatedIcons = pkgs.buildEnv {
name = "system-icons";
paths = with pkgs; [
(lib.mkIf config.aux.system.ui.desktops.gnome.enable gnome.gnome-themes-extra)
(lib.mkIf config.aux.system.ui.desktops.kde.enable kdePackages.breeze-icons)
];
pathsToLink = [ "/share/icons" ];
};
aggregatedFonts = pkgs.buildEnv {
name = "system-fonts";
paths = config.fonts.packages;
pathsToLink = [ "/share/fonts" ];
};
in
{
"/usr/share/icons" = mkRoSymBind "${aggregatedIcons}/share/icons";
"/usr/local/share/fonts" = mkRoSymBind "${aggregatedFonts}/share/fonts";
};
};
}