Merge branch 'main' of gh:greg-hellings/nixos-config

This commit is contained in:
Greg Hellings
2024-10-29 18:13:44 +00:00
142 changed files with 7017 additions and 5331 deletions
+99 -52
View File
@@ -1,60 +1,107 @@
{ pkgs, lib, ... }:
{
pkgs,
config,
lib,
self,
...
}:
let
notDarwin = (! pkgs.stdenv.isDarwin);
builderHosts = (
lib.attrNames (lib.filterAttrs (_: v: v.config.greg.remote-builder.enable) self.nixosConfigurations)
);
in
{
# Enable flakes
nix = {
gc = {
automatic = true;
# Scheduling of them is different in nixos vs nix-darwin, so check for
# the extra details there
options = "--delete-older-than 30d";
};
settings = {
experimental-features = "nix-command flakes";
keep-outputs = true;
keep-derivations = true;
min-free = (toString (1024 * 1024 * 1024) );
max-free = (toString (5 * 1024 * 1024 * 1024) );
substituters = [
"https://cache.garnix.io"
"https://ai.cachix.org"
];
trusted-public-keys = [
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
"ai.cachix.org-1:N9dzRK+alWwoKXQlnn0H6aUx0lU/mspIoz8hMvGvbbc="
];
};
# Enable flakes
nix = {
gc = {
automatic = true;
# Scheduling of them is different in nixos vs nix-darwin, so check for
# the extra details there
options = "--delete-older-than 30d";
};
nixpkgs.config = {
allowUnfree = true;
permittedInsecurePackages = [
"jitsi-meet-1.0.8043"
];
settings = {
experimental-features = "nix-command flakes";
keep-outputs = true;
keep-derivations = true;
min-free = (toString (1024 * 1024 * 1024));
max-free = (toString (5 * 1024 * 1024 * 1024));
trusted-users = [
"greg"
"gregory.hellings"
]; # For home and for work machines
substituters = [
"https://cache.garnix.io"
"https://ai.cachix.org"
"https://nixpkgs-python.cachix.org"
"https://greg-hellings.cachix.org"
"https://nix-community.cachix.org"
];
trusted-public-keys = [
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
"ai.cachix.org-1:N9dzRK+alWwoKXQlnn0H6aUx0lU/mspIoz8hMvGvbbc="
"nixpkgs-python.cachix.org-1:hxjI7pFxTyuTHn2NkvWCrAUcNZLNS3ZAvfYNuYifcEU="
"greg-hellings.cachix.org-1:y01Jl/L5evlhxdnUW6n56AiI1k8g1wxWhTxJCe7XSco="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
# Base packages that need to be in all my hosts
environment.systemPackages = with pkgs; [
agenix
bitwarden-cli
bmon
diffutils
git
gnupatch
gregpy
findutils
file
hms # My own home manager switcher
htop
iperf
killall
nano
pciutils
pwgen
unzip
wget
];
buildMachines = (
lib.map (host: {
hostName = "${host}-builder";
system = "x86_64-linux";
protocol = "ssh-ng";
maxJobs = 12;
speedFactor = 2;
supportedFeatures = [
"nixos-test"
"benchmark"
"big-parallel"
"kvm"
];
}) (lib.filter (x: x != config.networking.hostName) builderHosts)
);
distributedBuilds = true;
extraOptions = ''
builders-use-substitutes = true
'';
};
programs.ssh.extraConfig = (
builtins.concatStringsSep "\n" (
lib.map (x: ''
Host ${x}-builder
Hostname ${x}.home
User remote-builder-user
'') builderHosts
)
);
nixpkgs.config = {
allowUnfree = true;
permittedInsecurePackages = [ "jitsi-meet-1.0.8043" ];
};
# Base packages that need to be in all my hosts
environment.systemPackages = with pkgs; [
agenix
bitwarden-cli
bmon
cachix
diffutils
git
gnupatch
gregpy
findutils
file
hms # My own home manager switcher
htop
iperf
killall
nano
pciutils
pwgen
unzip
wget
];
}
+22 -24
View File
@@ -1,26 +1,24 @@
{...}:
{ ... }:
{
imports = [
../baseline.nix
];
system.stateVersion = 4;
home-manager = {
useGlobalPkgs = true;
users."gregory.hellings" = import ../../home/home.nix;
extraSpecialArgs = {
gnome = false;
gui = false;
home = "/Users/gregory.hellings";
};
imports = [ ../baseline.nix ];
system.stateVersion = 4;
home-manager = {
useGlobalPkgs = true;
users."gregory.hellings" = import ../../home/home.nix;
extraSpecialArgs = {
gnome = false;
gui = false;
home = "/Users/gregory.hellings";
};
users.users."gregory.hellings".home = "/Users/gregory.hellings";
programs = {
zsh.enable = true;
bash.enable = true;
};
services.nix-daemon.enable = true;
nix = {
gc.interval.Hour = 24;
settings.auto-optimise-store = false; # Darwin bugs?
};
}
};
users.users."gregory.hellings".home = "/Users/gregory.hellings";
programs = {
zsh.enable = true;
bash.enable = true;
};
services.nix-daemon.enable = true;
nix = {
gc.interval.Hour = 24;
settings.auto-optimise-store = false; # Darwin bugs?
};
}
+7 -6
View File
@@ -1,7 +1,8 @@
let
nixos = (import ./nixos);
darwin = (import ./darwin);
in {
nixosModule = nixos;
darwinModule = darwin;
}
nixos = (import ./nixos);
darwin = (import ./darwin);
in
{
nixosModule = nixos;
darwinModule = darwin;
}
+71 -60
View File
@@ -1,71 +1,82 @@
{ lib, config, pkgs, ... }:
{
lib,
config,
pkgs,
...
}:
let
cfg = config.greg.backup;
cfg = config.greg.backup;
where = j: "${config.services.syncthing.dataDir}/${j.dest}";
where = j: "${config.services.syncthing.dataDir}/${j.dest}";
makeSyncFolders = name: job: {
devices = [ "chronicles" ];
enable = true;
id = job.id;
label = job.dest;
path = where job;
type = "sendonly";
};
makeSyncFolders = _: job: {
devices = [ "chronicles" ];
enable = true;
id = job.id;
label = job.dest;
path = where job;
type = "sendonly";
};
makeRestic = name: job: let
who = "${config.services.syncthing.user}:${config.services.syncthing.group}";
in rec {
initialize = true;
passwordFile = config.age.secrets.restic-pw.path;
paths = [ job.src ];
repository = where job;
backupCleanupCommand = ''${pkgs.coreutils}/bin/chown -R ${who} "${repository}"'';
};
makeRestic =
_: job:
let
who = "${config.services.syncthing.user}:${config.services.syncthing.group}";
in
rec {
initialize = true;
passwordFile = config.age.secrets.restic-pw.path;
paths = [ job.src ];
repository = where job;
backupCleanupCommand = ''${pkgs.coreutils}/bin/chown -R ${who} "${repository}"'';
};
in with lib; {
options = {
greg.backup = {
jobs = mkOption {
default = {};
in
with lib;
{
options = {
greg.backup = {
jobs = mkOption {
default = { };
type = with types; attrsOf (submodule (
{ name, config, options, ... }:
{
options = {
src = mkOption {
type = types.str;
description = "Local path (string form) to backup from";
};
type =
with types;
attrsOf (
submodule (
{ ... }:
{
options = {
src = mkOption {
type = types.str;
description = "Local path (string form) to backup from";
};
dest = mkOption {
type = types.str;
};
dest = mkOption { type = types.str; };
id = mkOption {
type = types.str;
description = "The unique folder ID for this";
};
};
}
));
};
};
};
id = mkOption {
type = types.str;
description = "The unique folder ID for this";
};
};
}
)
);
};
};
};
config = mkIf ( ( attrValues cfg.jobs ) != [] )
{
age.secrets = {
restic-pw.file = ../../secrets/restic-pw.age;
restic-env.file = ../../secrets/restic-env.age;
};
greg.syncthing = {
enable = true;
};
services = {
syncthing.settings.folders = mapAttrs makeSyncFolders cfg.jobs;
restic.backups = mapAttrs makeRestic cfg.jobs;
};
};
config = mkIf ((attrValues cfg.jobs) != [ ]) {
age.secrets = {
restic-pw.file = ../../secrets/restic-pw.age;
restic-env.file = ../../secrets/restic-env.age;
};
greg.syncthing = {
enable = true;
};
services = {
syncthing.settings.folders = mapAttrs makeSyncFolders cfg.jobs;
restic.backups = mapAttrs makeRestic cfg.jobs;
};
};
}
+643 -563
View File
File diff suppressed because it is too large Load Diff
+77 -65
View File
@@ -1,76 +1,88 @@
{ config, lib, inputs, overlays, ... }:
{
config,
lib,
top,
overlays,
...
}:
let
cfg = config.greg.containers;
cfg = config.greg.containers;
# Create a container with all our default settings
# Create a container with all our default settings
makeContainer = name: container: let
agekey = "/etc/ssh/agenix_key";
in {
autoStart = true;
hostAddress = "192.168.${container.subnet}.1";
localAddress = "192.168.${container.subnet}.2";
privateNetwork = true;
bindMounts = {
"${agekey}".hostPath = "/etc/ssh/ssh_host_ed25519_key"; # This is needed for agenix to
};
enableTun = container.tailscale;
config = { config, pkgs, ... }: {
imports = [
inputs.agenix.nixosModules.default
inputs.self.modules.nixosModule
container.builder
];
makeContainer =
_: container:
let
agekey = "/etc/ssh/agenix_key";
in
{
autoStart = true;
hostAddress = "192.168.${container.subnet}.1";
localAddress = "192.168.${container.subnet}.2";
privateNetwork = true;
bindMounts = {
"${agekey}".hostPath = "/etc/ssh/ssh_host_ed25519_key"; # This is needed for agenix to
};
enableTun = container.tailscale;
config =
{ ... }:
{
imports = [
top.agenix.nixosModules.default
top.self.modules.nixosModule
container.builder
];
nixpkgs.overlays = overlays;
nixpkgs.overlays = overlays;
networking = {
firewall.enable = true;
useHostResolvConf = lib.mkForce false;
};
networking = {
firewall.enable = true;
useHostResolvConf = lib.mkForce false;
};
age.identityPaths = [ agekey ];
age.identityPaths = [ agekey ];
greg.tailscale.enable = container.tailscale;
};
};
in {
options.greg.containers = lib.mkOption {
default = {};
greg.tailscale.enable = container.tailscale;
};
};
in
{
options.greg.containers = lib.mkOption {
default = { };
type = with lib.types; attrsOf ( submodule (
{
options = {
tailscale = lib.mkOption {
type = bool;
default = false;
description = "Enable tailscale in the container";
};
subnet = lib.mkOption {
type = str;
default = "200";
};
builder = lib.mkOption {
default = { ... }: {};
description = ''
This needs to be a function, like the one for
a container's config. It will setup the core system above the
defaults set in this module.
'';
example = ''
{ pkgs, config, lib, ... } :
{
services.openssh.enable = true;
}
'';
};
};
}
));
};
type =
with lib.types;
attrsOf (submodule ({
options = {
tailscale = lib.mkOption {
type = bool;
default = false;
description = "Enable tailscale in the container";
};
subnet = lib.mkOption {
type = str;
default = "200";
};
builder = lib.mkOption {
default = { ... }: { };
description = ''
This needs to be a function, like the one for
a container's config. It will setup the core system above the
defaults set in this module.
'';
example = ''
{ pkgs, config, lib, ... } :
{
services.openssh.enable = true;
}
'';
};
};
}));
};
config = {
containers = builtins.mapAttrs makeContainer cfg;
};
config = {
containers = builtins.mapAttrs makeContainer cfg;
};
}
+69 -55
View File
@@ -1,63 +1,77 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.greg.databases;
dbs = (lib.attrNames cfg);
in {
options.greg.databases = lib.mkOption {
default = {};
type = with lib.types; attrsOf ( submodule (
{ name, config, options, ... }: {
# Options reserved for future expansion
options = {};
}
));
};
cfg = config.greg.databases;
dbs = (lib.attrNames cfg);
in
{
options.greg.databases = lib.mkOption {
default = { };
type =
with lib.types;
attrsOf (
submodule (
{ ... }:
{
# Options reserved for future expansion
options = { };
}
)
);
};
config = lib.mkIf ( dbs != [] ) {
services = {
postgresql = {
enable = true;
package = pkgs.postgresql_15;
checkConfig = true;
ensureDatabases = dbs;
ensureUsers = map (db: { name = db; ensureDBOwnership = true; }) dbs;
settings = {
log_connections = true;
log_statement = "all";
logging_collector = true;
log_filename = "postgresql.log";
};
identMap = "root root postgres";
};
config = lib.mkIf (dbs != [ ]) {
services = {
postgresql = {
enable = true;
package = pkgs.postgresql_15;
checkConfig = true;
ensureDatabases = dbs;
ensureUsers = map (db: {
name = db;
ensureDBOwnership = true;
}) dbs;
settings = {
log_connections = true;
log_statement = "all";
logging_collector = true;
log_filename = "postgresql.log";
};
identMap = "root root postgres";
};
postgresqlBackup = {
enable = true;
databases = dbs;
};
postgresqlBackup = {
enable = true;
databases = dbs;
};
logrotate = {
enable = true;
settings = {
postgresqlBackup = {
enable = true;
files = "${config.services.postgresqlBackup.location}/*.gz";
};
postgresLog = {
enable = true;
files = "/var/lib/postgresql/*/log/*.log";
compress = true;
compresscmd = "${pkgs.xz}/bin/xz";
};
};
};
logrotate = {
enable = true;
settings = {
postgresqlBackup = {
enable = true;
files = "${config.services.postgresqlBackup.location}/*.gz";
};
postgresLog = {
enable = true;
files = "/var/lib/postgresql/*/log/*.log";
compress = true;
compresscmd = "${pkgs.xz}/bin/xz";
};
};
};
};
};
greg.backup.jobs.greg-postgresql-backup = {
src = config.services.postgresqlBackup.location;
dest = "database-${config.networking.hostName}";
id = "${config.networking.hostName}-postgres-backup";
};
};
greg.backup.jobs.greg-postgresql-backup = {
src = config.services.postgresqlBackup.location;
dest = "database-${config.networking.hostName}";
id = "${config.networking.hostName}-postgres-backup";
};
};
}
+95 -80
View File
@@ -1,92 +1,107 @@
{ config, pkgs, inputs, lib, ... }:
{
config,
pkgs,
lib,
...
}:
let
x = if builtins.hasAttr "xonsh-unwrapped" pkgs then
pkgs.xonsh else
pkgs.xonsh.passthru.wrapper;
in {
imports = [
../baseline.nix
./backup.nix
./ceph.nix
./container.nix
./db.nix
./gnome.nix
./home.nix
./kde.nix
./kiwix-serve.nix
./linode.nix
./proxy.nix
./router.nix
./rpi4.nix
./sway.nix
./syncthing.nix
./tailscale.nix
./vmdev.nix
];
x = if builtins.hasAttr "xonsh-unwrapped" pkgs then pkgs.xonsh else pkgs.xonsh.passthru.wrapper;
in
{
imports = [
../baseline.nix
./backup.nix
./ceph.nix
./container.nix
./db.nix
./gnome.nix
./home.nix
./kde.nix
./kiwix-serve.nix
./linode.nix
./print.nix
./proxy.nix
./remote-builder.nix
./router.nix
./rpi4.nix
./sway.nix
./syncthing.nix
./tailscale.nix
./vmdev.nix
];
environment.sessionVariables.MOZ_ENABLE_WAYLAND = "0";
environment.systemPackages = with pkgs; [
coreutils-full
direnv # needed for xonsh-direnv
efibootmgr
psmisc
lshw
usbutils
];
environment.systemPackages = with pkgs; [
btrfs-progs
coreutils-full
efibootmgr
psmisc
lshw
usbutils
xfsprogs
];
system.stateVersion = "24.05";
system.stateVersion = "24.05";
nix = {
gc.dates = "weekly";
settings.auto-optimise-store = true;
};
nix = {
gc.dates = "weekly";
settings.auto-optimise-store = true;
};
# I am a fan of network manager, myself
networking = {
search = [
"thehellings.lan"
"home"
];
networkmanager.enable = true;
};
# I am a fan of network manager, myself
networking = {
search = [
"thehellings.lan"
"home"
];
networkmanager.enable = true;
};
programs.xonsh = {
enable = true;
package = (x.override {
extraPackages = (ps: with ps; [
(ps.toPythonModule pkgs.pipenv)
pyyaml
requests
ruamel-yaml
xonsh-apipenv
pkgs.nur.repos.xonsh-xontribs.xonsh-direnv
pkgs.nur.repos.xonsh-xontribs.xontrib-vox
]);
});
};
programs.xonsh = {
enable = true;
package = (
x.override {
extraPackages = (
ps: with ps; [
(ps.toPythonModule pkgs.pipenv)
pyyaml
requests
ruamel-yaml
xonsh-apipenv
pkgs.nur.repos.xonsh-xontribs.xonsh-direnv
pkgs.nur.repos.xonsh-xontribs.xontrib-vox
]
);
}
);
};
# Enable the OpenSSH daemon for remote control
services = {
openssh = {
enable = true;
settings.X11Forwarding = true;
};
};
# Enable the OpenSSH daemon for remote control
services = {
openssh = {
enable = true;
settings.X11Forwarding = true;
};
};
# Define a user account. Don't forget to set a password with passwd.
users.users.greg = {
isNormalUser = true;
createHome = true;
extraGroups = [ "wheel" "networkmanager" ]; # Enable sudo for the user.
shell = config.programs.xonsh.package;
openssh.authorizedKeys.keys = lib.strings.splitString "\n" (builtins.readFile ../../home/ssh/authorized_keys);
};
# Define a user account. Don't forget to set a password with passwd.
users.users.greg = {
isNormalUser = true;
createHome = true;
extraGroups = [
"wheel"
"networkmanager"
]; # Enable sudo for the user.
shell = config.programs.xonsh.package;
openssh.authorizedKeys.keys = lib.strings.splitString "\n" (
builtins.readFile ../../home/ssh/authorized_keys
);
};
i18n.defaultLocale = "en_US.UTF-8";
i18n.defaultLocale = "en_US.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "us";
};
console = {
font = "Lat2-Terminus16";
keyMap = "us";
};
}
+56 -51
View File
@@ -1,64 +1,69 @@
{ config, pkgs, lib, ... }:
{
config,
pkgs,
lib,
...
}:
let
cfg = config.greg.gnome;
cfg = config.greg.gnome;
in with lib; {
options = {
greg.gnome.enable = mkEnableOption "Enable my default Gnome3 setup";
};
in
with lib;
{
options = {
greg.gnome.enable = mkEnableOption "Enable my default Gnome3 setup";
};
config = mkIf cfg.enable {
# Sets up a basic Gnome installation
services = {
accounts-daemon.enable = true;
config = mkIf cfg.enable {
# Sets up a basic Gnome installation
services = {
accounts-daemon.enable = true;
# Trackpad support
libinput.enable = true;
# Trackpad support
libinput.enable = true;
xserver = {
enable = true;
displayManager.gdm.enable = true;
desktopManager.gnome.enable = true;
xkb.layout = "us";
};
xserver = {
enable = true;
displayManager.gdm.enable = true;
desktopManager.gnome.enable = true;
xkb.layout = "us";
};
udev.packages = with pkgs; [
gnome3.gnome-settings-daemon
];
udev.packages = with pkgs; [ gnome-settings-daemon ];
pipewire.enable = true;
pipewire.enable = true;
# Enablement for Firefox
gnome = {
gnome-browser-connector.enable = true;
#chrome-gnome-shell.enable = true;
sushi.enable = true;
gnome-online-accounts.enable = true;
};
};
# Enablement for Firefox
gnome = {
gnome-browser-connector.enable = true;
#chrome-gnome-shell.enable = true;
sushi.enable = true;
gnome-online-accounts.enable = true;
};
};
programs.dconf.enable = true;
xdg.portal = {
enable = true;
wlr.enable = true; # Enables screen sharing in Wayland
};
programs.dconf.enable = true;
xdg.portal = {
enable = true;
wlr.enable = true; # Enables screen sharing in Wayland
};
# Used by gsconnect
networking.firewall.allowedTCPPorts = [ 1716 ];
# Used by gsconnect
networking.firewall.allowedTCPPorts = [ 1716 ];
# Enable some Gnome plugins that I like
environment.systemPackages = with pkgs; [
adwaita-icon-theme
gnome-tweaks
dconf-editor
gnomeExtensions.appindicator
gnomeExtensions.clipboard-indicator
gnomeExtensions.dash-to-dock
gnomeExtensions.gsconnect
gnomeExtensions.stocks-extension
gnomeExtensions.tailscale-qs
gnomeExtensions.vitals
];
};
# Enable some Gnome plugins that I like
environment.systemPackages = with pkgs; [
adwaita-icon-theme
gnome-tweaks
dconf-editor
gnomeExtensions.appindicator
gnomeExtensions.clipboard-indicator
gnomeExtensions.dash-to-dock
gnomeExtensions.gsconnect
gnomeExtensions.stocks-extension
gnomeExtensions.tailscale-qs
gnomeExtensions.vitals
];
};
}
+12 -11
View File
@@ -1,18 +1,19 @@
{ config, lib, ... }:
let
cfg = config.greg.home;
cfg = config.greg.home;
in with lib;
in
with lib;
{
options.greg.home = mkOption {
type = types.bool;
default = true;
description = "Sets the device up to be part of my home network";
};
options.greg.home = mkOption {
type = types.bool;
default = true;
description = "Sets the device up to be part of my home network";
};
config = mkIf cfg {
time.timeZone = "America/Chicago";
networking.domain = "thehellings.lan";
};
config = mkIf cfg {
time.timeZone = "America/Chicago";
networking.domain = "thehellings.lan";
};
}
+55 -40
View File
@@ -1,48 +1,63 @@
{ config, pkgs, lib, options, ... }:
{
config,
pkgs,
lib,
options,
...
}:
let
cfg = config.greg.kde;
cfg = config.greg.kde;
in with lib; {
options = {
greg.kde.enable = mkEnableOption "Enable my default KDE setup";
};
in
with lib;
{
options = {
greg.kde.enable = mkEnableOption "Enable my default KDE setup";
};
config = mkIf cfg.enable {
# Sets up a basic KDE installation
services = {
xserver = {
enable = true;
xkb.layout = "us";
# Trackpad support
libinput.enable = true;
};
config = mkIf cfg.enable {
hardware = {
bluetooth.enable = true;
};
# Sets up a basic KDE installation
systemd.services.bluetooth.requiredBy = [ "multi-user.target" ];
services =
{
xserver = {
enable = true;
xkb.layout = "us";
# Trackpad support
};
pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
} // (optionalAttrs (builtins.hasAttr "plasma6" options.services.xserver.desktopManager) {
desktopManager.plasma6.enable = true;
displayManager = {
defaultSession = "plasma";
sddm.enable = true;
};
});
libinput.enable = true;
blueman.enable = true;
programs.dconf.enable = true;
programs.sway.enable = true; # Gives us Wayland
xdg.portal = {
enable = true;
wlr.enable = true; # Enables screen sharing in Wayland
};
pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
}
// (optionalAttrs (builtins.hasAttr "plasma6" options.services.xserver.desktopManager) {
desktopManager.plasma6.enable = true;
displayManager = {
defaultSession = "plasma";
sddm.enable = true;
};
});
environment.systemPackages = with pkgs; [
kalendar
korganizer
plasma-pa
];
};
programs.dconf.enable = true;
programs.sway.enable = true; # Gives us Wayland
xdg.portal = {
enable = true;
wlr.enable = true; # Enables screen sharing in Wayland
};
environment.systemPackages = with pkgs; [
kalendar
korganizer
];
};
}
+46 -40
View File
@@ -1,48 +1,54 @@
{ config, pkgs, lib, ... }:
{
config,
pkgs,
lib,
...
}:
let
cfg = config.services.kiwix-serve;
in with lib; {
options.services.kiwix-serve = {
enable = mkEnableOption "Enable the Kiwix web server";
cfg = config.services.kiwix-serve;
in
with lib;
{
options.services.kiwix-serve = {
enable = mkEnableOption "Enable the Kiwix web server";
port = mkOption {
type = types.int;
default = 8888;
description = "Port to serve the Kiwix HTTP service on";
};
port = mkOption {
type = types.int;
default = 8888;
description = "Port to serve the Kiwix HTTP service on";
};
path = mkOption {
type = types.str;
default = "/var/lib/kiwix-serve/";
description = "Path to Zim file(s) to serve";
};
path = mkOption {
type = types.str;
default = "/var/lib/kiwix-serve/";
description = "Path to Zim file(s) to serve";
};
proxy = mkOption {
type = types.str;
default = "";
description = ''Upstream proxy, if any, to configure with kiwix. Specify
host and port. E.g. "localhost:8080"
'';
};
};
proxy = mkOption {
type = types.str;
default = "";
description = ''
Upstream proxy, if any, to configure with kiwix. Specify
host and port. E.g. "localhost:8080"
'';
};
};
config = mkIf cfg.enable {
environment.systemPackages = [
pkgs.kiwix-tools
];
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.kiwix-tools ];
systemd.services.kiwix-serve = {
enable = true;
after = [ "network.service" ];
description = "Runs the kiwix-serve binary as a sysmted service";
restartTriggers = [ pkgs.kiwix-tools ];
wantedBy = [ "multi-user.target" ];
script = "${pkgs.kiwix-tools}/bin/kiwix-serve --port ${toString cfg.port} ${cfg.path}";
environment = {
UPSTREAM_HOST = mkIf (cfg.proxy != "") cfg.proxy;
UPSTREAM_WIKI = mkIf (cfg.proxy != "") cfg.proxy;
};
};
};
systemd.services.kiwix-serve = {
enable = true;
after = [ "network.service" ];
description = "Runs the kiwix-serve binary as a sysmted service";
restartTriggers = [ pkgs.kiwix-tools ];
wantedBy = [ "multi-user.target" ];
script = "${pkgs.kiwix-tools}/bin/kiwix-serve --port ${toString cfg.port} ${cfg.path}";
environment = {
UPSTREAM_HOST = mkIf (cfg.proxy != "") cfg.proxy;
UPSTREAM_WIKI = mkIf (cfg.proxy != "") cfg.proxy;
};
};
};
}
+40 -34
View File
@@ -1,44 +1,50 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.greg.linode;
cfg = config.greg.linode;
in with lib;
in
with lib;
{
options.greg.linode = {
enable = mkEnableOption "Set sensible defaults for a Linode host";
options.greg.linode = {
enable = mkEnableOption "Set sensible defaults for a Linode host";
bootTimeout = mkOption {
type = types.int;
default = 15;
description = "Set bootloader timeout in seconds.";
};
};
bootTimeout = mkOption {
type = types.int;
default = 15;
description = "Set bootloader timeout in seconds.";
};
};
config = mkIf cfg.enable {
# Enables connection over Linode consoles
boot.kernelParams = [ "console=ttyS0,19200n8" ];
boot.loader.grub = {
device = "nodev";
extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1;
terminal_input serial;
terminal_output serial;
'';
};
config = mkIf cfg.enable {
# Enables connection over Linode consoles
boot.kernelParams = [ "console=ttyS0,19200n8" ];
boot.loader.grub = {
device = "nodev";
extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1;
terminal_input serial;
terminal_output serial;
'';
};
# Tells grub to ignore partion-free device warnings, since we are on Linode
boot.loader.timeout = 15;
# Tells grub to ignore partion-free device warnings, since we are on Linode
boot.loader.timeout = 15;
networking.usePredictableInterfaceNames = false; # Use old style eth0 names
networking.useDHCP = false;
networking.interfaces.eth0.useDHCP = true;
networking.usePredictableInterfaceNames = false; # Use old style eth0 names
networking.useDHCP = false;
networking.interfaces.eth0.useDHCP = true;
# Suggested diagnostic tools
environment.systemPackages = with pkgs; [
inetutils
mtr
sysstat
];
};
# Suggested diagnostic tools
environment.systemPackages = with pkgs; [
inetutils
mtr
sysstat
];
};
}
+39
View File
@@ -0,0 +1,39 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.greg.print;
in
with lib;
{
options.greg.print.enable = mkOption {
type = types.bool;
default = true;
description = "Configures the system to print with my home printer";
};
config = mkIf cfg.enable {
# ipp://printer.thehellings.lan:631/ - generic postscript printer
services.printing = {
enable = true;
drivers = with pkgs; [ gutenprint ] ++ (lib.optional pkgs.stdenv.isx86_64 gutenprintBin);
};
hardware.printers.ensurePrinters = [
{
name = "HomeLexmarkColorPrinter";
location = "Home office";
deviceUri = "ipp://printer.thehellings.lan:631/";
model = "drv:///sample.drv/generic.ppd";
ppdOptions = {
PageSize = "Letter";
};
}
];
};
}
+82 -73
View File
@@ -1,87 +1,96 @@
{ config, lib, pkgs, ... }:
{ config, lib, ... }:
let
cfg = config.greg.proxies;
cfg = config.greg.proxies;
alias = name: with builtins; head (split "\\." name);
alias = name: with builtins; head (split "\\." name);
makeHost = name: dest: {
forceSSL = dest.ssl;
enableACME = dest.ssl;
locations."${dest.path}" = {
proxyPass = dest.target;
extraConfig = ''
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
'' + dest.extraConfig;
};
serverAliases = lib.mkIf dest.genAliases [ "${alias name}" ];
};
makeHost = name: dest: {
forceSSL = dest.ssl;
enableACME = dest.ssl;
locations."${dest.path}" = {
proxyPass = dest.target;
extraConfig =
''
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
''
+ dest.extraConfig;
};
serverAliases = lib.mkIf dest.genAliases [ "${alias name}" ];
};
in with lib; {
options = {
greg.proxies = mkOption {
default = {};
example = literalExpression ''
{ host-name = {
target = proxyLocation;
ssl = true;
};
'';
description = ''
Quick and simple Nginx proxy configurations.
Use this to configure a very simple proxy that does not
need any extra customization options other than SSL
enablement.
'';
in
with lib;
{
options = {
greg.proxies = mkOption {
default = { };
example = literalExpression ''
{ host-name = {
target = proxyLocation;
ssl = true;
};
'';
description = ''
Quick and simple Nginx proxy configurations.
Use this to configure a very simple proxy that does not
need any extra customization options other than SSL
enablement.
'';
type = with types; attrsOf (submodule (
{ name, config, options, ... }:
{
options = {
genAliases = mkOption {
type = types.bool;
description = "Whether to auto-generate short alias name";
default = true;
};
type =
with types;
attrsOf (
submodule (
{ ... }:
{
options = {
genAliases = mkOption {
type = types.bool;
description = "Whether to auto-generate short alias name";
default = true;
};
target = mkOption {
type = types.str;
description = ''The destination that is being proxied.'';
example = "http://localhost:8080";
};
target = mkOption {
type = types.str;
description = ''The destination that is being proxied.'';
example = "http://localhost:8080";
};
ssl = mkOption {
type = types.bool;
description = "Whether to enable SSL in front of the proxy";
default = false;
};
ssl = mkOption {
type = types.bool;
description = "Whether to enable SSL in front of the proxy";
default = false;
};
path = mkOption {
type = types.str;
description = "The path prefix for this proxy";
default = "/";
};
path = mkOption {
type = types.str;
description = "The path prefix for this proxy";
default = "/";
};
extraConfig = mkOption {
type = types.str;
description = "Extra nginx config options";
default = "";
};
};
}));
};
};
extraConfig = mkOption {
type = types.str;
description = "Extra nginx config options";
default = "";
};
};
}
)
);
};
};
config.services.nginx = mkIf ( ( attrValues cfg ) != [] ) {
enable = true;
config.services.nginx = mkIf ((attrValues cfg) != [ ]) {
enable = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
virtualHosts = mapAttrs makeHost cfg;
};
virtualHosts = mapAttrs makeHost cfg;
};
}
+33
View File
@@ -0,0 +1,33 @@
{ lib, config, ... }:
let
cfg = config.greg.remote-builder;
in
with lib;
{
options.greg.remote-builder = {
enable = mkEnableOption "Enable this as a remote builder for myself";
};
config = mkIf cfg.enable {
greg.tailscale.enable = true;
users.users.remote-builder-user = {
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG4fNCnomQEsFKQZp16LXRqkfXHzzZbGAYJWPMvlGGQy root@exodus"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMGJjyFVOsF74QKzRITc8z/5MJlIa47P1tMm9Z8HRJLm root@jude"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMMOdWSq6NtcP6sfe2uke4wSfgE16hfa970t+8ADdLwk root@nixos"
];
homeMode = "500";
isNormalUser = true;
useDefaultShell = true;
};
# The builder user needs to be trusted to submit builds
nix.settings.trusted-users = [ config.users.users.remote-builder-user.name ];
# If the system is powerful enough to be a remote builder, it should
# be powerful enough to do some basic qemu stuff
boot.binfmt.emulatedSystems = [
"i686-linux"
"aarch64-linux"
];
};
}
+107 -83
View File
@@ -1,93 +1,117 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
names = mylist: (lib.strings.concatMapStringsSep "," (x: ''"${x}"'') mylist);
# Pass the names of the wan/lan ports
nftConfig = {
wan,
lan,
limitedLan ? [],
openPorts ? [ "ssh" "67" "53" ], # ssh, dhcpd, dns
openUDPPorts ? [ "67" "53" ] # dhcpd, dns
}: let
lanList = names lan;
allLan = names (lan ++ limitedLan);
wanName = names wan;
portsString = lib.strings.concatMapStringsSep "\n" (x: "iifname { ${lanList}, \"tailscale0\" } tcp dport ${toString x} accept") openPorts;
udpPortsString = lib.strings.concatMapStringsSep "\n" (x: "iifname { ${lanList}, \"tailscale0\" } udp dport ${toString x} accept") openUDPPorts;
in lib.strings.concatStringsSep "\n" [
"table ip filter {"
" chain output {"
" type filter hook output priority 100; policy accept;"
" }"
names = mylist: (lib.strings.concatMapStringsSep "," (x: ''"${x}"'') mylist);
# Pass the names of the wan/lan ports
nftConfig =
{
wan,
lan,
limitedLan ? [ ],
openPorts ? [
"ssh"
"67"
"53"
],
# ssh, dhcpd, dns
openUDPPorts ? [
"67"
"53"
], # dhcpd, dns
}:
let
lanList = names lan;
allLan = names (lan ++ limitedLan);
wanName = names wan;
portsString = lib.strings.concatMapStringsSep "\n" (
x: "iifname { ${lanList}, \"tailscale0\" } tcp dport ${toString x} accept"
) openPorts;
udpPortsString = lib.strings.concatMapStringsSep "\n" (
x: "iifname { ${lanList}, \"tailscale0\" } udp dport ${toString x} accept"
) openUDPPorts;
in
lib.strings.concatStringsSep "\n" [
"table ip filter {"
" chain output {"
" type filter hook output priority 100; policy accept;"
" }"
" chain input {"
" type filter hook input priority 0; policy drop;"
" chain input {"
" type filter hook input priority 0; policy drop;"
" iifname lo accept"
portsString
udpPortsString
" iifname { ${lanList} } accept comment \"Allows LAN traffic and outgoing\""
" iifname { ${wanName} } ct state { established, related } accept comment \"Allows existing connections\""
" iifname { ${wanName} } icmp type { echo-request, destination-unreachable, time-exceeded } counter accept comment \"Allow some ICMP traffic\""
" iifname { ${wanName} } counter drop comment \"Drop other incoming traffic, and count how much\""
" }"
" chain forward {"
" type filter hook forward priority 0; policy drop;"
" iifname { ${allLan} } oifname { ${wanName} } accept comment \"Forward LAN to WAN\""
" iifname { ${wanName} } oifname { ${allLan} } ct state established, related accept comment \"Allow incoming established traffic\""
" }"
"}"
" iifname lo accept"
portsString
udpPortsString
" iifname { ${lanList} } accept comment \"Allows LAN traffic and outgoing\""
" iifname { ${wanName} } ct state { established, related } accept comment \"Allows existing connections\""
" iifname { ${wanName} } icmp type { echo-request, destination-unreachable, time-exceeded } counter accept comment \"Allow some ICMP traffic\""
" iifname { ${wanName} } counter drop comment \"Drop other incoming traffic, and count how much\""
" }"
" chain forward {"
" type filter hook forward priority 0; policy drop;"
" iifname { ${allLan} } oifname { ${wanName} } accept comment \"Forward LAN to WAN\""
" iifname { ${wanName} } oifname { ${allLan} } ct state established, related accept comment \"Allow incoming established traffic\""
" }"
"}"
"table ip nat {"
" chain postrouting {"
" type nat hook postrouting priority 100; policy accept;"
" oifname { ${wanName} } masquerade"
" }"
"}"
"table ip nat {"
" chain postrouting {"
" type nat hook postrouting priority 100; policy accept;"
" oifname { ${wanName} } masquerade"
" }"
"}"
"table ip6 filter {"
" chain input {"
" type filter hook input priority 0; policy drop;"
" }"
" chain forward {"
" type filter hook forward priority 0; policy drop;"
" }"
"}"
];
cfg = config.greg.router;
"table ip6 filter {"
" chain input {"
" type filter hook input priority 0; policy drop;"
" }"
" chain forward {"
" type filter hook forward priority 0; policy drop;"
" }"
"}"
];
cfg = config.greg.router;
in with lib; {
options.greg.router = {
enable = mkEnableOption "Enable NFTables and routing";
wan = mkOption {
type = (types.listOf types.str);
description = "The name of the network interface that is the WAN connection";
};
lan = mkOption {
type = (types.listOf types.str);
description = "A list of all network interfaces that are considered LAN connections";
};
limited = mkOption {
type = (types.listOf types.str);
description = "A list of limited access LAN connections - such as IOT connections and similar.";
default = [];
};
};
in
with lib;
{
options.greg.router = {
enable = mkEnableOption "Enable NFTables and routing";
wan = mkOption {
type = (types.listOf types.str);
description = "The name of the network interface that is the WAN connection";
};
lan = mkOption {
type = (types.listOf types.str);
description = "A list of all network interfaces that are considered LAN connections";
};
limited = mkOption {
type = (types.listOf types.str);
description = "A list of limited access LAN connections - such as IOT connections and similar.";
default = [ ];
};
};
config = mkIf cfg.enable {
networking.nftables = {
enable = true;
ruleset = (nftConfig {
inherit (cfg) lan wan;
openPorts = config.networking.firewall.allowedTCPPorts;
openUDPPorts = config.networking.firewall.allowedUDPPorts;
});
};
config = mkIf cfg.enable {
networking.nftables = {
enable = true;
ruleset = (
nftConfig {
inherit (cfg) lan wan;
openPorts = config.networking.firewall.allowedTCPPorts;
openUDPPorts = config.networking.firewall.allowedUDPPorts;
}
);
};
environment.systemPackages = [
pkgs.pciutils
pkgs.tcpdump
];
};
environment.systemPackages = [
pkgs.pciutils
pkgs.tcpdump
];
};
}
+41 -34
View File
@@ -1,43 +1,50 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.greg.rpi4;
cfg = config.greg.rpi4;
in with lib; {
options = {
greg.rpi4 = {
enable = mkEnableOption "Enable support for Raspberry Pi 4s";
};
};
in
with lib;
{
options = {
greg.rpi4 = {
enable = mkEnableOption "Enable support for Raspberry Pi 4s";
};
};
config = mkIf cfg.enable {
boot = {
# This prevents us from having to compile our own kernel
kernelPackages = pkgs.linuxPackages_rpi4;
kernelParams = [
"8250.nr_uarts=1"
"console=ttyAMA0,115200"
"console=tty1"
"cma=128M"
];
config = mkIf cfg.enable {
boot = {
# This prevents us from having to compile our own kernel
kernelPackages = pkgs.linuxPackages_rpi4;
kernelParams = [
"8250.nr_uarts=1"
"console=ttyAMA0,115200"
"console=tty1"
"cma=128M"
];
loader = {
raspberryPi = {
enable = true;
version = 4;
};
loader = {
raspberryPi = {
enable = true;
version = 4;
};
# Use the extlinux boot loader. (NixOS wants to enable GRUB by default)
grub.enable = false;
# Use the extlinux boot loader. (NixOS wants to enable GRUB by default)
grub.enable = false;
# Enables the generation of /boot/extlinux/extlinux.conf
#generic-extlinux-compatible.enable = true;
};
};
# Enables the generation of /boot/extlinux/extlinux.conf
#generic-extlinux-compatible.enable = true;
};
};
environment.systemPackages = with pkgs; [
raspberrypifw
usbutils
];
};
environment.systemPackages = with pkgs; [
raspberrypifw
usbutils
];
};
}
+36 -34
View File
@@ -1,42 +1,44 @@
{ config, pkgs, lib, ... }:
{ config, lib, ... }:
let
cfg = config.greg.sway;
cfg = config.greg.sway;
in with lib; {
options = {
greg.sway.enable = mkEnableOption "Enable my default Gnome3 setup";
};
in
with lib;
{
options = {
greg.sway.enable = mkEnableOption "Enable my default Gnome3 setup";
};
config = mkIf cfg.enable {
services = {
accounts-daemon.enable = true;
config = mkIf cfg.enable {
services = {
accounts-daemon.enable = true;
pipewire = {
enable = true;
alsa.enable = true;
audio.enable = true;
jack.enable = true;
pulse.enable = true;
wireplumber.enable = true;
};
pipewire = {
enable = true;
alsa.enable = true;
audio.enable = true;
jack.enable = true;
pulse.enable = true;
wireplumber.enable = true;
};
xserver = {
enable = true;
displayManager.gdm = {
enable = true;
autoSuspend = false;
banner = "Welcome to Greg's JUDE machine. Do I know you?";
wayland = true;
};
xkb.layout = "us";
};
};
xserver = {
enable = true;
displayManager.gdm = {
enable = true;
autoSuspend = false;
banner = "Welcome to Greg's JUDE machine. Do I know you?";
wayland = true;
};
xkb.layout = "us";
};
};
programs.sway = {
enable = true; # Will be enabled through home-manager
wrapperFeatures.gtk = true;
};
security.pam.services.swaylock = {};
};
programs.sway = {
enable = true; # Will be enabled through home-manager
wrapperFeatures.gtk = true;
};
security.pam.services.swaylock = { };
};
}
+27 -25
View File
@@ -1,29 +1,31 @@
{ config, lib, pkgs, ... }:
{ config, lib, ... }:
let
cfg = config.greg.syncthing;
in with lib; {
options.greg.syncthing = {
enable = mkEnableOption "Setup my personal minimal configuration for Syncthing";
};
cfg = config.greg.syncthing;
in
with lib;
{
options.greg.syncthing = {
enable = mkEnableOption "Setup my personal minimal configuration for Syncthing";
};
config = mkIf cfg.enable {
services.syncthing = {
enable = true;
overrideFolders = true;
overrideDevices = true;
settings = {
devices = {
chronicles.id = "7FI6Y3M-C7YQEDI-IB345L6-RKLXMB6-AEIV57Y-3J2RCXQ-MK6QRNK-EINPXAE";
genesis.id = "YDTH4SD-GUAC5AA-SSYWYPZ-YMJW5LK-LE7PZKJ-GV2UJFZ-CU7LZAD-GTYWCQK";
gitlab.id = "VAG5GHP-L7TNY7O-CHR3CKU-GXXVCIL-OT3WHHU-E4VAIZC-JI4BKOM-PYZQOQS";
linode.id = "IJMMXPR-WNALZBD-FMJH5W5-WV7XGJY-HLJTKGT-5TKHJIH-75LT56D-UUZCYQE";
matrix.id = "K5IHM3I-TJFFEW5-GAYJMPS-CYSHW5C-XHMC462-MFRMOHJ-EJLKIKC-CZHGJQ2";
};
options = {
urAccepted = -1;
};
};
};
};
config = mkIf cfg.enable {
services.syncthing = {
enable = true;
overrideFolders = true;
overrideDevices = true;
settings = {
devices = {
chronicles.id = "7FI6Y3M-C7YQEDI-IB345L6-RKLXMB6-AEIV57Y-3J2RCXQ-MK6QRNK-EINPXAE";
genesis.id = "YDTH4SD-GUAC5AA-SSYWYPZ-YMJW5LK-LE7PZKJ-GV2UJFZ-CU7LZAD-GTYWCQK";
gitlab.id = "VAG5GHP-L7TNY7O-CHR3CKU-GXXVCIL-OT3WHHU-E4VAIZC-JI4BKOM-PYZQOQS";
linode.id = "IJMMXPR-WNALZBD-FMJH5W5-WV7XGJY-HLJTKGT-5TKHJIH-75LT56D-UUZCYQE";
matrix.id = "K5IHM3I-TJFFEW5-GAYJMPS-CYSHW5C-XHMC462-MFRMOHJ-EJLKIKC-CZHGJQ2";
};
options = {
urAccepted = -1;
};
};
};
};
}
+15 -13
View File
@@ -1,18 +1,20 @@
{ lib, config, ... }:
let
cfg = config.greg.tailscale;
in {
options = {
greg.tailscale.enable = lib.mkEnableOption "Enable Tailscale";
};
cfg = config.greg.tailscale;
in
{
options = {
greg.tailscale.enable = lib.mkEnableOption "Enable Tailscale";
};
config = lib.mkIf cfg.enable {
services.tailscale.enable = true;
networking.firewall.checkReversePath = "loose";
boot.kernel.sysctl = {
"net.ipv4.ip_forward" = "1";
"net.ipv6.conf.all.forwarding" = "1";
};
};
config = lib.mkIf cfg.enable {
services.tailscale.enable = true;
networking.firewall.checkReversePath = "loose";
boot.kernel.sysctl = {
"net.ipv4.ip_forward" = "1";
"net.ipv6.conf.all.forwarding" = "1";
};
systemd.services.tailscaled.partOf = [ "network-online.target" ];
};
}
+70 -63
View File
@@ -1,74 +1,81 @@
{ pkgs, lib, config, ... }:
{
pkgs,
lib,
config,
...
}:
let
cfg = config.greg.vmdev;
in with lib;
cfg = config.greg.vmdev;
in
with lib;
{
options = {
greg.vmdev = {
enable = mkEnableOption "Enable this system for VM development work";
user = mkOption {
default = "greg";
type = types.str;
description = "The user who will be doing VM dev";
};
system = mkOption {
default = "amd";
type = types.str;
description = "Kernel module type to install - amd, intel, etc";
};
};
};
options = {
greg.vmdev = {
enable = mkEnableOption "Enable this system for VM development work";
user = mkOption {
default = "greg";
type = types.str;
description = "The user who will be doing VM dev";
};
system = mkOption {
default = "amd";
type = types.str;
description = "Kernel module type to install - amd, intel, etc";
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
dmidecode
guestfs-tools
libguestfs
OVMFFull
packer
virt-manager
xorriso
];
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
dmidecode
#guestfs-tools
libguestfs
OVMFFull
packer
virt-manager
xorriso
];
users.users."${cfg.user}".extraGroups = [ "libvirtd" ];
users.users."${cfg.user}".extraGroups = [ "libvirtd" ];
# Enable the virtualisation services
virtualisation = {
libvirtd = {
enable = true;
onBoot = "ignore"; # Do not auto-restart VMs on boot, unless they are marked autostart
qemu.ovmf.enable = true;
};
# Enable the virtualisation services
virtualisation = {
libvirtd = {
enable = true;
onBoot = "ignore"; # Do not auto-restart VMs on boot, unless they are marked autostart
qemu.ovmf.enable = true;
};
virtualbox.host = {
enable = true;
enableExtensionPack = true;
};
};
virtualbox.host = {
enable = true;
enableExtensionPack = true;
};
};
# Configuration for vbox user performance
users.extraGroups.vboxusers.members = [ cfg.user ];
# Configuration for vbox user performance
users.extraGroups.vboxusers.members = [ cfg.user ];
boot.extraModprobeConfig = "options kvm_${cfg.system} nested=1";
boot.extraModprobeConfig = "options kvm_${cfg.system} nested=1";
# Configure the services more
systemd.services = {
libvirtd = {
preStart = "${pkgs.kmod}/bin/modprobe kvm_${cfg.system}";
postStop = "${pkgs.kmod}/bin/rmmod kvm_${cfg.system} kvm";
conflicts = [ "vbox.service" ];
};
vbox = {
preStart = "${pkgs.kmod}/bin/modprobe vboxdrv vboxnetadp vboxnetflt";
postStop = "${pkgs.kmod}/bin/rmmod vboxnetadp vboxnetflt vboxdrv";
script = "echo Started";
conflicts = [ "libvirtd.service" ];
unitConfig = {
Type = "oneshot";
RemainAfterExit = "yes";
};
};
};
};
# Configure the services more
systemd.services = {
libvirtd = {
preStart = "${pkgs.kmod}/bin/modprobe kvm_${cfg.system}";
postStop = "${pkgs.kmod}/bin/rmmod kvm_${cfg.system} kvm";
conflicts = [ "vbox.service" ];
#overrideStrategy = "asDropin";
};
vbox = {
preStart = "${pkgs.kmod}/bin/modprobe vboxdrv vboxnetadp vboxnetflt";
postStop = "${pkgs.kmod}/bin/rmmod vboxnetadp vboxnetflt vboxdrv";
script = "echo Started";
conflicts = [ "libvirtd.service" ];
unitConfig = {
Type = "oneshot";
RemainAfterExit = "yes";
};
};
};
};
}