[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, ... }: { pkgs, ... }:
{ {
options = {
};
config = {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
android-udev-rules android-udev-rules
]; ];
nixpkgs.config.android_sdk.accept_license = true; nixpkgs.config.android_sdk.accept_license = true;
programs.adb.enable = true; programs.adb.enable = true;
};
} }

View File

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

View File

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

View File

@ -1,5 +1,5 @@
{ config, pkgs, ... }: { config, pkgs, makeEnable, ... }:
{ makeEnable config "modules.extra" false {
services.expressvpn.enable = true; services.expressvpn.enable = true;
programs.hyprland.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 # Enable the gtk icon cache
gtk.iconCache.enable = true; 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; [ environment.systemPackages = with pkgs; [
steam steam
heroic heroic

View File

@ -37,6 +37,10 @@
uri = "ssh://gitea@1896Folsom.duckdns.org:1123/kkathuang/org.git"; uri = "ssh://gitea@1896Folsom.duckdns.org:1123/kkathuang/org.git";
interval = 45; 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 = { xsession = {
enable = true; enable = true;

View File

@ -1,12 +1,8 @@
{ pkgs, inputs, ... }: { pkgs, inputs, config, makeEnable, ... }:
{ makeEnable config "modules.kat" false {
imports = [
inputs.home-manager.nixosModule
];
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
bitwarden bitwarden
obsidian obsidian
vlc
obs-studio obs-studio
ffmpeg ffmpeg
]; ];
@ -14,36 +10,4 @@
environment.extraInit = '' environment.extraInit = ''
export PAGER=cat 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 = [ imports = [
../laptop.nix ../configuration.nix
inputs.nixos-hardware.nixosModules.dell-xps-17-9700-intel 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; hardware.enableRedistributableFirmware = true;
boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];

View File

@ -1,14 +1,21 @@
{ {
imports = [ imports = [
../internet-computer.nix ../configuration.nix
../raspberry-pi.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 = { services.plex = {
enable = true; 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, ... }: { config, lib, pkgs, ... }:
{ {
imports = [ 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; hardware.enableRedistributableFirmware = true;
# disable card with bbswitch by default since we turn it on only on demand! # disable card with bbswitch by default since we turn it on only on demand!

View File

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

View File

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

View File

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

View File

@ -2,10 +2,10 @@
{ {
imports = [ imports = [
../full.nix ../configuration.nix
]; ];
modules.nixified-ai.enable = true; features.full.enable = true;
boot.loader.systemd-boot.configurationLimit = 5; 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 # Extract 'imports' from configAttrs, if it exists
importsAttr = if configAttrs ? imports then configAttrs.imports else []; 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 = [ imports = [
inputs.nixos-hardware.nixosModules.raspberry-pi-4 inputs.nixos-hardware.nixosModules.raspberry-pi-4
]; ];

View File

@ -1,4 +1,4 @@
{ pkgs, ... }: { pkgs, makeEnable, config, ... }:
let let
devices = { devices = {
biskcomp = { biskcomp = {
@ -13,7 +13,7 @@ let
}; };
allDevices = builtins.attrNames devices; allDevices = builtins.attrNames devices;
in in
{ makeEnable config "modules.syncthing" true {
system.activationScripts.syncthingPermissions = { system.activationScripts.syncthingPermissions = {
text = '' text = ''
chown -R syncthing:syncthing /var/lib/syncthing 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 = [ imports = [
inputs.nixos-wsl.nixosModules.wsl 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; }; modules.base.enable = false;
modules.desktop.enable = false;
environment.variables = { modules.xmonad.enable = false;
SHELL = "${pkgs.zsh}/bin/zsh";
};
wsl = { wsl = {
enable = true; enable = true;
automountPath = "/mnt"; automountPath = "/mnt";
startMenuLaunchers = true; startMenuLaunchers = true;
nativeSystemd = true; nativeSystemd = true;
docker-native.enable = true; docker-native.enable = true;
# Enable integration with Docker Desktop (needs to be installed)
# docker-desktop.enable = true;
}; };
} }