[NixOS] Control what is enabled per machine with module options

This commit is contained in:
Ivan Malison 2023-08-20 04:25:58 -06:00
parent a50a05640f
commit 8638d05595
26 changed files with 126 additions and 271 deletions

View File

@ -1,8 +1,12 @@
{ pkgs, ... }:
{
options = {
};
config = {
environment.systemPackages = with pkgs; [
android-udev-rules
];
nixpkgs.config.android_sdk.accept_license = true;
programs.adb.enable = true;
};
}

View File

@ -1,13 +1,5 @@
{ config, pkgs, options, inputs, ... }:
{
imports = [
./environment.nix
./essential.nix
./nix.nix
./ssh.nix
./users.nix
];
{ config, pkgs, options, inputs, makeEnable, ... }:
makeEnable config "modules.base" true {
nixpkgs.config.permittedInsecurePackages = [
"openssl-1.0.2u"
"electron-12.2.3"
@ -67,10 +59,6 @@
services.tzupdate.enable = true;
# TODO: Add a comment explaining what this does.
services.gnome.at-spi2-core.enable = true;
services.gnome.gnome-keyring.enable = true;
services.locate.enable = true;
virtualisation.docker.enable = true;

View File

@ -1,5 +1,5 @@
{ pkgs, config, ... }:
{
{ pkgs, config, makeEnable, ... }:
makeEnable config "modules.code" true {
programs.direnv = {
enable = true;
nix-direnv.enable = true;

39
nixos/configuration.nix Normal file
View File

@ -0,0 +1,39 @@
{ config, lib, ... }:
{
imports = [
./android.nix
./base.nix
./code.nix
./desktop.nix
./environment.nix
./essential.nix
./extra.nix
./games.nix
./git-sync.nix
./internet-computer.nix
./keybase.nix
./nix.nix
./nixified.ai.nix
./ssh.nix
./syncthing.nix
./users.nix
./wsl.nix
./xmonad.nix
];
options = {
features.full.enable = lib.mkEnableOption "Do everything";
};
config = lib.mkIf config.features.full.enable {
modules.base.enable = true;
modules.desktop.enable = true;
modules.xmonad.enable = true;
modules.extra.enable = true;
modules.code.enable = true;
modules.games.enable = true;
modules.syncthing.enable = true;
modules.fonts.enable = true;
modules.nixified-ai.enable = true;
};
}

View File

@ -1,5 +1,5 @@
{ config, pkgs, options, inputs, ... }:
{
{ config, pkgs, options, inputs, makeEnable, ... }:
makeEnable config "modules.desktop" true {
imports = [
./fonts.nix
];
@ -43,6 +43,10 @@
# This is for the benefit of VSCODE running natively in wayland
environment.sessionVariables.NIXOS_OZONE_WL = "1";
services.gnome.at-spi2-core.enable = true;
services.gnome.gnome-keyring.enable = true;
environment.systemPackages = with pkgs; [
# Appearance
gnome.adwaita-icon-theme

View File

@ -1,5 +1,5 @@
{ config, pkgs, ... }:
{
{ config, pkgs, makeEnable, ... }:
makeEnable config "modules.extra" false {
services.expressvpn.enable = true;
programs.hyprland.enable = true;

View File

@ -1,5 +1,5 @@
{ pkgs, ... }:
{
{ pkgs, makeEnable, config, ... }:
makeEnable config "modules.fonts" true {
# Enable the gtk icon cache
gtk.iconCache.enable = true;

View File

@ -1,17 +0,0 @@
{ pkgs, ... }:
{
imports = [
./android.nix
./base.nix
./code.nix
./desktop.nix
./extra.nix
./games.nix
./git-sync.nix
./internet-computer.nix
./keybase.nix
./nixified.ai.nix
./syncthing.nix
./xmonad.nix
];
}

View File

@ -1,5 +1,5 @@
{ config, pkgs, ... }:
{
{ config, pkgs, makeEnable, ... }:
makeEnable config "modules.games" false {
environment.systemPackages = with pkgs; [
steam
heroic

View File

@ -37,6 +37,10 @@
uri = "ssh://gitea@1896Folsom.duckdns.org:1123/kkathuang/org.git";
interval = 45;
};
katnivan = {
path = config.home.homeDirectory + "/katnivan";
uri = "ssh://gitea@1896Folsom.duckdns.org:1123/colonelpanic/katnivan.git";
};
};
};
});

View File

@ -1,4 +1,4 @@
username: { pkgs, config, specialArgs, ... }:
{ pkgs, config, specialArgs, ... }:
{
xsession = {
enable = true;

View File

@ -1,12 +1,8 @@
{ pkgs, inputs, ... }:
{
imports = [
inputs.home-manager.nixosModule
];
{ pkgs, inputs, config, makeEnable, ... }:
makeEnable config "modules.kat" false {
environment.systemPackages = with pkgs; [
bitwarden
obsidian
vlc
obs-studio
ffmpeg
];
@ -14,36 +10,4 @@
environment.extraInit = ''
export PAGER=cat
'';
home-manager.users.kat = { pkgs, config, ... }: {
services.gpg-agent = {
enable = true;
defaultCacheTtl = 8 * 60 * 60;
maxCacheTtl = 8 * 60 * 60;
enableSshSupport = true;
pinentryFlavor = "qt";
};
services.kdeconnect = {
enable = true;
indicator = true;
};
services.git-sync = {
enable = true;
repositories = {
obsidian = {
path = config.home.homeDirectory + "/obsidian";
uri = "git@github.com:katandtonic/obsidian.git";
interval = 60;
};
org = {
path = config.home.homeDirectory + "/org";
uri = "ssh://gitea@1896Folsom.duckdns.org:1123/kkathuang/org.git";
interval = 45;
};
};
};
home.stateVersion = "23.11";
};
}

View File

@ -1,11 +0,0 @@
{ pkgs, ... }:
{
imports = [
./base.nix
./code.nix
./desktop.nix
./internet-computer.nix
./syncthing.nix
./xmonad.nix
];
}

View File

@ -2,10 +2,20 @@
{
imports = [
../laptop.nix
../configuration.nix
inputs.nixos-hardware.nixosModules.dell-xps-17-9700-intel
];
modules.base.enable = true;
modules.desktop.enable = true;
modules.xmonad.enable = true;
modules.extra.enable = false;
modules.code.enable = true;
modules.games.enable = false;
modules.syncthing.enable = true;
modules.fonts.enable = true;
modules.nixified-ai.enable = false;
hardware.enableRedistributableFirmware = true;
boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];

View File

@ -1,14 +1,21 @@
{
imports = [
../internet-computer.nix
../configuration.nix
../raspberry-pi.nix
../base.nix
../syncthing.nix
../desktop.nix
../code.nix
# ../xmonad.nix
];
modules.raspberry-pi.enable = true;
modules.base.enable = true;
modules.desktop.enable = true;
modules.xmonad.enable = true;
modules.extra.enable = false;
modules.code.enable = true;
modules.games.enable = false;
modules.syncthing.enable = true;
modules.fonts.enable = true;
modules.nixified-ai.enable = false;
services.plex = {
enable = true;
};

View File

@ -1,13 +1,20 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, ... }:
{
imports = [
../full.nix
../configuration.nix
];
modules.base.enable = true;
modules.desktop.enable = true;
modules.xmonad.enable = true;
modules.extra.enable = false;
modules.code.enable = true;
modules.games.enable = false;
modules.syncthing.enable = true;
modules.fonts.enable = true;
modules.nixified-ai.enable = false;
hardware.enableRedistributableFirmware = true;
# disable card with bbswitch by default since we turn it on only on demand!

View File

@ -1,12 +1,10 @@
{ lib, pkgs, config, inputs, ... }:
{
imports = [
../syncthing.nix
../wsl.nix
../kat.nix
../configuration.nix
];
networking.hostName = "jay-lenovo-wsl";
modules.wls.enable = true;tworking.hostName = "jay-lenovo-wsl";
wsl.defaultUser = "kat";
system.stateVersion = "22.05";

View File

@ -2,10 +2,11 @@
{
imports = [
../full.nix
../kat.nix
../configuration.nix
];
features.full.enable = true;
environment.systemPackages = with pkgs; [
linuxPackages_latest.perf
zenmonitor

View File

@ -1,11 +1,11 @@
{ config, lib, pkgs, inputs, ... }:
{
imports = [
../full.nix
../kat.nix
../nixified.ai.nix
../configuration.nix
];
features.full.enable = true;
networking.hostName = "nixquick";
hardware.enableRedistributableFirmware = true;

View File

@ -2,10 +2,10 @@
{
imports = [
../full.nix
../configuration.nix
];
modules.nixified-ai.enable = true;
features.full.enable = true;
boot.loader.systemd-boot.configurationLimit = 5;

View File

@ -1,83 +0,0 @@
{ config, lib, pkgs, inputs, ... }:
{
imports = [
../full.nix
../base.nix
];
hardware.enableRedistributableFirmware = true;
boot.initrd.availableKernelModules = [
"xhci_pci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc"
];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = with config.boot.kernelPackages; [ ];
services.xserver = {
videoDrivers = [ "modesetting ""nvidia" ];
};
services.thermald.enable = true;
boot.kernelPackages = pkgs.linuxPackages_latest;
boot.kernelPatches = [{
name = "enable-soundwire-drivers";
patch = null;
extraConfig = ''
SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES y
SND_SOC_INTEL_SOUNDWIRE_SOF_MACH m
SND_SOC_RT1308 m
'';
ignoreConfigErrors = true;
}];
hardware.nvidia.prime = {
sync.enable = true;
# Bus ID of the NVIDIA GPU. You can find it using lspci, either under 3D or VGA
nvidiaBusId = "PCI:1:0:0";
# Bus ID of the Intel GPU. You can find it using lspci, either under 3D or VGA
intelBusId = "PCI:0:2:0";
};
services.xserver.screenSection = ''
Option "metamodes" "nvidia-auto-select +0+0 {ForceCompositionPipeline=On, ForceFullCompositionPipeline=On}"
Option "AllowIndirectGLXProtocol" "off"
Option "TripleBuffer" "on"
'';
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
services.xserver.libinput.enable = true;
fileSystems."/" =
{ device = "/dev/disk/by-uuid/7c999009-1ff1-42f7-a64a-3fa91fc777a8";
fsType = "ext4";
};
boot.initrd.luks.devices."cryptroot".device = "/dev/disk/by-uuid/97c1eee7-b161-4186-9c14-6b1771d49afb";
fileSystems."/boot" =
{ device = "/dev/disk/by-label/ESP";
fsType = "vfat";
};
swapDevices = [ ];
networking.hostName = "stevie-nixos";
nix.settings.maxJobs = lib.mkDefault 16;
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
hardware.video.hidpi.enable = true;
services.xserver.dpi = 180;
system.stateVersion = "21.05";
}

View File

@ -1,47 +0,0 @@
{ config, lib, pkgs, ... }:
{
imports = [
../full.nix
../games.nix
../extra.nix
];
hardware.enableRedistributableFirmware = true;
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "sd_mod" ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ pkgs.linuxPackages.rtl8814au ];
boot.loader.grub.efiSupport = true;
boot.loader.grub.device = "nodev";
boot.loader.grub.enable = true;
services.xserver = {
libinput.enable = true;
};
hardware.facetimehd.enable = true;
fileSystems."/boot" = {
device = "/dev/disk/by-label/EFI";
fsType = "vfat";
};
fileSystems."/" =
{ device = "/dev/disk/by-uuid/2958f04b-8387-4a0c-abc1-f12036c53581";
fsType = "ext4";
};
swapDevices =
[ { device = "/dev/disk/by-uuid/33c38b23-af1a-4bc4-913e-c774f1030817"; }
];
fileSystems."/tmp" =
{ device = "tmpfs";
fsType = "tmpfs";
};
networking.hostName = "uber-loaner";
nix.settings.maxJobs = lib.mkDefault 4;
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
users.extraUsers.root.initialHashedPassword = "";
}

View File

@ -17,7 +17,7 @@ let
};
};
cfg = lib.attrByPath (lib.splitString "." pathStr) { enable = false; defaulted = true; } config;
cfg = lib.attrByPath (lib.splitString "." pathStr) { enable = false; } config;
# Extract 'imports' from configAttrs, if it exists
importsAttr = if configAttrs ? imports then configAttrs.imports else [];

View File

@ -1,6 +1,6 @@
{ config, pkgs, inputs, ... }:
{ config, pkgs, inputs, makeEnable, ... }:
{
makeEnable config "modules.raspberry-pi" false {
imports = [
inputs.nixos-hardware.nixosModules.raspberry-pi-4
];

View File

@ -1,4 +1,4 @@
{ pkgs, ... }:
{ pkgs, makeEnable, config, ... }:
let
devices = {
biskcomp = {
@ -13,7 +13,7 @@ let
};
allDevices = builtins.attrNames devices;
in
{
makeEnable config "modules.syncthing" true {
system.activationScripts.syncthingPermissions = {
text = ''
chown -R syncthing:syncthing /var/lib/syncthing

View File

@ -1,31 +1,18 @@
{ inputs, pkgs, ... }:
{
{ config, inputs, pkgs, makeEnable, ... }:
makeEnable config "modules.wsl" false {
imports = [
inputs.nixos-wsl.nixosModules.wsl
./ssh.nix
./environment.nix
./essential.nix
./fonts.nix
./nix.nix
./users.nix
./code.nix
];
programs.gnupg.agent = { enable = true; enableSSHSupport = true; };
environment.variables = {
SHELL = "${pkgs.zsh}/bin/zsh";
};
modules.base.enable = false;
modules.desktop.enable = false;
modules.xmonad.enable = false;
wsl = {
enable = true;
automountPath = "/mnt";
startMenuLaunchers = true;
nativeSystemd = true;
docker-native.enable = true;
# Enable integration with Docker Desktop (needs to be installed)
# docker-desktop.enable = true;
};
}