1
0
Fork 0

General: cleanup 'with lib;'s

This commit is contained in:
Aires 2024-08-02 17:55:48 -04:00
parent 148c11f8b9
commit 0f8a5d41a5
38 changed files with 215 additions and 321 deletions

View file

@ -1,9 +1,4 @@
{
config,
lib,
pkgs,
...
}:
{ config, pkgs, ... }:
let
# Do not change this value! This tracks when NixOS was installed on your system.

View file

@ -1,7 +1,6 @@
{
config,
lib,
pkgs,
modulesPath,
...
}:

View file

@ -1,10 +1,4 @@
{
config,
lib,
pkgs,
system,
...
}:
{ ... }:
let
# Do not change this value! This tracks when NixOS was installed on your system.

View file

@ -2,7 +2,6 @@
config,
pkgs,
lib,
nix-secrets,
...
}:
let

View file

@ -1,13 +1,6 @@
# Raspberry Pi 4B
# See https://wiki.nixos.org/wiki/NixOS_on_ARM/Raspberry_Pi_4
{
config,
lib,
pkgs,
modulesPath,
nixos-hardware,
...
}:
{ lib, modulesPath, ... }:
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];

View file

@ -1,9 +1,4 @@
{
config,
pkgs,
lib,
...
}:
{ config, pkgs, ... }:
let
# Do not change this value! This tracks when NixOS was installed on your system.
stateVersion = "24.05";
@ -30,6 +25,12 @@ in
system.stateVersion = stateVersion;
networking.hostName = hostName;
# TESTING: Try out different GTK renderers: gl (old), ngl (new), or vulkan (new and unstable)
# See https://blog.gtk.org/2024/01/28/new-renderers-for-gtk/
environment.sessionVariables = {
"GSK_RENDERER" = "gl";
};
aux.system = {
apps = {
development.enable = true;

View file

@ -1,11 +1,5 @@
# Lenovo Legion Slim 7 Gen 7 AMD (16ARHA7)
{
config,
lib,
pkgs,
modulesPath,
...
}:
{ pkgs, modulesPath, ... }:
let
bootUUID = "AFCB-D880"; # The UUID of the boot partition.
luksUUID = "bcf67e34-339e-40b9-8ffd-bec8f7f55248"; # The UUID of the locked LUKS partition.

View file

@ -1,10 +1,4 @@
{
pkgs,
home-manager,
lib,
config,
...
}:
{ pkgs, config, ... }:
let
stateVersion = "24.05";
hostName = "Haven";

View file

@ -1,11 +1,5 @@
# Minisforum UM340
{
config,
lib,
pkgs,
modulesPath,
...
}:
{ config, modulesPath, ... }:
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];

View file

@ -2,7 +2,6 @@
{
config,
lib,
pkgs,
modulesPath,
...
}:

View file

@ -8,17 +8,16 @@
let
cfg = config.aux.system.apps.development;
in
with lib;
{
options = {
aux.system.apps.development = {
enable = mkEnableOption (mdDoc "Enables development tools");
kubernetes.enable = mkEnableOption (mdDoc "Enables kubectl, virtctl, and similar tools.");
enable = lib.mkEnableOption "Enables development tools";
kubernetes.enable = lib.mkEnableOption "Enables kubectl, virtctl, and similar tools.";
};
};
config = mkMerge [
(mkIf cfg.enable {
config = lib.mkMerge [
(lib.mkIf cfg.enable {
aux.system = {
packages = with pkgs; [ nixd ];
ui.flatpak = {
@ -27,7 +26,7 @@ with lib;
};
};
})
(mkIf cfg.kubernetes.enable {
(lib.mkIf cfg.kubernetes.enable {
environment.systemPackages = with pkgs; [
kubectl
kubernetes-helm

View file

@ -3,13 +3,12 @@
let
cfg = config.aux.system.apps.dj;
in
with lib;
{
options = {
aux.system.apps.dj.enable = mkEnableOption (mdDoc "Enables DJing tools (i.e. Mixxx)");
aux.system.apps.dj.enable = lib.mkEnableOption "Enables DJing tools (i.e. Mixxx)";
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
aux.system.ui.flatpak = {
enable = true;
packages = [ "org.mixxx.Mixxx" ];

View file

@ -14,13 +14,12 @@ let
sudo systemctl restart bluetooth.service
'';
in
with lib;
{
options = {
aux.system.apps.gaming.enable = mkEnableOption (mdDoc "Enables gaming features");
aux.system.apps.gaming.enable = lib.mkEnableOption "Enables gaming features";
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
aux.system.ui.flatpak = {
enable = true;
packages = [

View file

@ -3,13 +3,12 @@
let
cfg = config.aux.system.apps.media;
in
with lib;
{
options = {
aux.system.apps.media.enable = mkEnableOption (mdDoc "Enables media playback and editing apps");
aux.system.apps.media.enable = lib.mkEnableOption "Enables media playback and editing apps";
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
aux.system.ui.flatpak = {
enable = true;
packages = [

View file

@ -3,13 +3,12 @@
let
cfg = config.aux.system.apps.office;
in
with lib;
{
options = {
aux.system.apps.office.enable = mkEnableOption (mdDoc "Enables office and workstation apps");
aux.system.apps.office.enable = lib.mkEnableOption "Enables office and workstation apps";
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
aux.system.ui.flatpak = {
enable = true;
packages = [

View file

@ -8,13 +8,12 @@
let
cfg = config.aux.system.apps.recording;
in
with lib;
{
options = {
aux.system.apps.recording.enable = mkEnableOption (mdDoc "Enables video editing tools");
aux.system.apps.recording.enable = lib.mkEnableOption "Enables video editing tools";
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
aux.system.ui.flatpak.enable = true;
services.flatpak.packages = [

View file

@ -8,13 +8,12 @@
let
cfg = config.aux.system.apps.social;
in
with lib;
{
options = {
aux.system.apps.social.enable = mkEnableOption (mdDoc "Enables chat apps");
aux.system.apps.social.enable = lib.mkEnableOption "Enables chat apps";
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
aux.system = {
allowUnfree = true;
ui.flatpak = {

View file

@ -1,20 +1,14 @@
{
pkgs,
config,
lib,
...
}:
{ config, lib, ... }:
let
cfg = config.aux.system.apps.tmux;
in
with lib;
{
options = {
aux.system.apps.tmux.enable = mkEnableOption (mdDoc "Enables tmux - terminal multiplexer");
aux.system.apps.tmux.enable = lib.mkEnableOption "Enables tmux - terminal multiplexer";
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
programs.tmux = {
enable = true;
newSession = true;

View file

@ -1,27 +1,29 @@
# Auto-import modules in this folder, recursively.
# Sourced from https://github.com/evanjs/nixos_cfg/blob/4bb5b0b84a221b25cf50853c12b9f66f0cad3ea4/config/new-modules/default.nix
{ lib, ... }:
with lib;
let
# Recursively constructs an attrset of a given folder, recursing on directories, value of attrs is the filetype
getDir =
dir:
mapAttrs (file: type: if type == "directory" then getDir "${dir}/${file}" else type) (
lib.mapAttrs (file: type: if type == "directory" then getDir "${dir}/${file}" else type) (
builtins.readDir dir
);
# Collects all files of a directory as a list of strings of paths
files =
dir: collect isString (mapAttrsRecursive (path: type: concatStringsSep "/" path) (getDir dir));
dir:
lib.collect lib.isString (
lib.mapAttrsRecursive (path: type: lib.concatStringsSep "/" path) (getDir dir)
);
# Search all files and folders within and below the current directory.
# Filters out directories that belong to home-manager, and don't end with .nix or are this file.
validFiles =
dir:
map (file: ./. + "/${file}") (
filter (file: !hasInfix "home-manager" file && file != "autoimport.nix" && hasSuffix ".nix" file) (
files dir
)
lib.filter (
file: !lib.hasInfix "home-manager" file && file != "autoimport.nix" && lib.hasSuffix ".nix" file
) (files dir)
);
in
{

View file

@ -1,17 +1,11 @@
{
pkgs,
config,
lib,
...
}:
{ config, lib, ... }:
let
cfg = config.aux.system.services.apcupsd;
in
with lib;
{
options = {
aux.system.services.apcupsd = {
enable = mkEnableOption (mdDoc "Enables apcupsd");
enable = lib.mkEnableOption "Enables apcupsd";
configText = lib.mkOption {
type = lib.types.str;
description = "The configuration to pass to apcupsd.";
@ -19,7 +13,7 @@ with lib;
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
services.apcupsd = {
enable = true;
configText = cfg.configText;

View file

@ -1,10 +1,5 @@
# Run automatic updates. Replaces system.autoUpgrade.
{
config,
lib,
pkgs,
...
}:
{ config, lib, ... }:
let
cfg = config.aux.system.services.autoUpgrade;

View file

@ -1,10 +1,5 @@
# Serves a binary cache for Nix packages
{
config,
lib,
self,
...
}:
{ config, lib, ... }:
let
cfg = config.aux.system.services.cache;

View file

@ -9,20 +9,19 @@ let
cfg = config.aux.system.services.duplicacy-web;
duplicacy-web = pkgs.callPackage ../../packages/duplicacy-web.nix { inherit pkgs lib; };
in
with lib;
rec {
{
options = {
aux.system.services.duplicacy-web = {
enable = mkEnableOption (mdDoc "Enables duplicacy-web");
autostart = mkOption {
enable = lib.mkEnableOption "Enables duplicacy-web";
autostart = lib.mkOption {
default = true;
type = types.bool;
type = lib.types.bool;
description = "Whether to auto-start duplicacy-web on boot";
};
environment = mkOption {
environment = lib.mkOption {
default = "";
type = types.str;
type = lib.types.str;
description = "Environment where duplicacy-web stores its config files";
};
};

View file

@ -4,13 +4,12 @@
let
cfg = config.aux.system.services.msmtp;
in
with lib;
{
options = {
aux.system.services.msmtp.enable = mkEnableOption (mdDoc "Enables mail server");
aux.system.services.msmtp.enable = lib.mkEnableOption "Enables mail server";
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
programs.msmtp = {
enable = true;
accounts.default = {

View file

@ -39,7 +39,7 @@ in
};
config = lib.mkMerge [
({ programs.virt-manager.enable = cfg.enable; })
{ programs.virt-manager.enable = cfg.enable; }
(lib.mkIf (cfg.host.enable || cfg.host.vmBuilds.enable) {
virtualisation = {
libvirtd = {

View file

@ -1,11 +1,5 @@
# Basic system-wide text editor configuration.
{
pkgs,
config,
lib,
inputs,
...
}:
{ config, lib, ... }:
let
cfg = config.aux.system.editor;

View file

@ -1,6 +1,5 @@
# Core Nix configuration
{
pkgs,
config,
lib,
inputs,

View file

@ -1,10 +1,5 @@
# Enables the Budgie desktop environment.
{
pkgs,
config,
lib,
...
}:
{ config, lib, ... }:
let
cfg = config.aux.system.ui.desktops.budgie;
in

View file

@ -1,10 +1,5 @@
# Enables the Hyprland desktop environment.
{
pkgs,
config,
lib,
...
}:
{ config, lib, ... }:
let
cfg = config.aux.system.ui.desktops.hyprland;
in

View file

@ -1,10 +1,5 @@
# Enables the XFCE desktop environment.
{
pkgs,
config,
lib,
...
}:
{ config, lib, ... }:
let
cfg = config.aux.system.ui.desktops.xfce;
in

View file

@ -1,5 +1,4 @@
{
nix-flatpak,
pkgs,
config,
lib,

View file

@ -9,26 +9,26 @@
let
cfg = config.aux.system.users.aires;
in
with lib;
{
options = {
aux.system.users.aires = {
enable = mkEnableOption (mdDoc "Enables aires user account");
autologin = mkEnableOption (mdDoc "Automatically logs aires in on boot");
enable = lib.mkEnableOption "Enables aires user account";
autologin = lib.mkEnableOption "Automatically logs aires in on boot";
services.syncthing = {
enable = mkEnableOption (mdDoc "Enables Syncthing");
enableTray = mkEnableOption (mdDoc "Enables the Syncthing Tray application");
autostart = mkOption {
enable = lib.mkEnableOption "Enables Syncthing";
enableTray = lib.mkEnableOption "Enables the Syncthing Tray application";
autostart = lib.mkOption {
default = true;
type = types.bool;
type = lib.types.bool;
description = "Whether to auto-start Syncthing on boot";
};
};
};
};
config = mkIf cfg.enable (mkMerge [
config = lib.mkIf cfg.enable (
lib.mkMerge [
{
users.users.aires = {
isNormalUser = true;
@ -126,7 +126,7 @@ with lib;
}
# Autologin aires
(mkIf cfg.autologin {
(lib.mkIf cfg.autologin {
services.displayManager.autoLogin = {
enable = true;
user = "aires";
@ -138,10 +138,10 @@ with lib;
})
# Enable Syncthing
(mkIf cfg.services.syncthing.enable {
(lib.mkIf cfg.services.syncthing.enable {
users.users.aires.packages = [
pkgs.syncthing
(mkIf cfg.services.syncthing.enableTray pkgs.syncthingtray)
(lib.mkIf cfg.services.syncthing.enableTray pkgs.syncthingtray)
];
# Open port 8080
@ -159,10 +159,11 @@ with lib;
};
# Override the default Syncthing settings so it doesn't start on boot
systemd.user.services."syncthing" = mkIf (!cfg.services.syncthing.autostart) {
systemd.user.services."syncthing" = lib.mkIf (!cfg.services.syncthing.autostart) {
wantedBy = lib.mkForce { };
};
};
})
]);
]
);
}

View file

@ -1,9 +1,4 @@
{
lib,
pkgs,
osConfig,
...
}:
{ lib, osConfig, ... }:
{
# Additional Gnome configurations via home-manager.
dconf.settings = lib.mkIf osConfig.aux.system.ui.desktops.gnome.enable {

View file

@ -9,26 +9,25 @@
let
cfg = config.aux.system.users.gremlin;
in
with lib;
{
options = {
aux.system.users.gremlin = {
enable = mkEnableOption (mdDoc "Enables gremlin user account");
enable = lib.mkEnableOption "Enables gremlin user account";
services.syncthing = {
enable = mkEnableOption (mdDoc "Enables Syncthing");
enableTray = mkEnableOption (mdDoc "Enables the Syncthing Tray application");
autostart = mkOption {
enable = lib.mkEnableOption "Enables Syncthing";
enableTray = lib.mkEnableOption "Enables the Syncthing Tray application";
autostart = lib.mkOption {
default = true;
type = types.bool;
type = lib.types.bool;
description = "Whether to auto-start Syncthing on boot";
};
};
};
};
config = mkMerge [
(mkIf cfg.enable {
config = lib.mkMerge [
(lib.mkIf cfg.enable {
# Add Gremlin account
users.users.gremlin = {
isNormalUser = true;
@ -110,11 +109,11 @@ with lib;
})
# Enable Syncthing
(mkIf cfg.services.syncthing.enable {
(lib.mkIf cfg.services.syncthing.enable {
users.users.gremlin = {
packages = [
pkgs.syncthing
(mkIf cfg.services.syncthing.enableTray pkgs.syncthingtray)
(lib.mkIf cfg.services.syncthing.enableTray pkgs.syncthingtray)
];
};
@ -130,7 +129,7 @@ with lib;
};
# Override the default Syncthing settings so it doesn't start on boot
systemd.user.services."syncthing" = mkIf (!cfg.services.syncthing.autostart) {
systemd.user.services."syncthing" = lib.mkIf (!cfg.services.syncthing.autostart) {
wantedBy = lib.mkForce { };
};
};

View file

@ -1,24 +1,18 @@
{
pkgs,
lib,
config,
...
}:
{ lib, config, ... }:
# Define user for managing media files
let
cfg = config.aux.system.users.media;
in
with lib;
{
options = {
aux.system.users.media = {
enable = mkEnableOption (mdDoc "Enables media user account");
enable = lib.mkEnableOption "Enables media user account";
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
users.groups."media" = {
gid = 1001;
};

View file

@ -1,9 +1,4 @@
{
config,
home-manager,
lib,
...
}:
{ config, lib, ... }:
{
# Give root user access to run remote builds
home-manager.users.root = {

View file

@ -23,11 +23,11 @@ stdenv.mkDerivation rec {
airsonic-starts = nixosTests.airsonic;
};
meta = with lib; {
meta = {
description = "Free, web-based media streamer providing ubiquitous access to your music.";
homepage = "https://github.com/kagemomiji/airsonic-advanced/";
sourceProvenance = with sourceTypes; [ binaryBytecode ];
sourceProvenance = [ lib.sourceTypes.binaryBytecode ];
license = lib.licenses.gpl3;
platforms = platforms.all;
platforms = lib.platforms.all;
};
}

View file

@ -18,10 +18,10 @@ pkgs.stdenv.mkDerivation rec {
chmod a+x $out/duplicacy-web
'';
meta = with lib; {
meta = {
homepage = "https://duplicacy.com";
description = "A new generation cloud backup tool";
platforms = platforms.linux;
license = licenses.unfreeRedistributable;
platforms = lib.platforms.linux;
license = lib.licenses.unfreeRedistributable;
};
}