From 922fe7de731bcd6710fd32d53f157491fcfcdde4 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Sun, 7 Jul 2024 14:32:46 -0500 Subject: [PATCH] make nix-ld more modular --- hosts/othalan/default.nix | 45 ++++++----- lib/generators.nix | 15 ++-- modules/nix-ld.nix | 159 ++++++++++++++++++++++++-------------- todo.md | 5 -- 4 files changed, 130 insertions(+), 94 deletions(-) diff --git a/hosts/othalan/default.nix b/hosts/othalan/default.nix index 1b73d92..057512b 100644 --- a/hosts/othalan/default.nix +++ b/hosts/othalan/default.nix @@ -1,28 +1,27 @@ -{ enableAttrs, ... }: +{ enabled, ... }: { - oizys = - (enableAttrs [ - "vpn" - "desktop" - "hyprland" - "chrome" - "docker" - "nix-ld" - "vbox" - "backups" - ]) - // { - languages = [ - "misc" - "nim" - "node" - "nushell" - "python" - "roc" - "tex" - "zig" - ]; + oizys = { + vpn = enabled; + desktop = enabled; + hyprland = enabled; + chrome = enabled; + docker = enabled; + nix-ld = enabled // { + overkill = enabled; }; + vbox = enabled; + backups = enabled; + languages = [ + "misc" + "nim" + "node" + "nushell" + "python" + "roc" + "tex" + "zig" + ]; + }; services.restic.backups.gdrive = { user = "daylin"; diff --git a/lib/generators.nix b/lib/generators.nix index 7e5204b..64a72ee 100644 --- a/lib/generators.nix +++ b/lib/generators.nix @@ -29,13 +29,14 @@ let } ) ]; - specialArgs = { - inherit - inputs - lib - self - enabled; - }; + specialArgs = { + inherit + inputs + lib + self + enabled + ; + }; }; mkSystem = hostName: diff --git a/modules/nix-ld.nix b/modules/nix-ld.nix index 4312972..3dccf1e 100644 --- a/modules/nix-ld.nix +++ b/modules/nix-ld.nix @@ -5,68 +5,109 @@ ... }: let - inherit (lib) mkEnableOption mkIf; + inherit (lib) + mkEnableOption + mkIf + mkOption + literalExpression + types + ; cfg = config.oizys.nix-ld; + + # https://github.com/NixOS/nixpkgs/blob/a4f437f0f5db62e6bcd7979c10eab177dd0fa188/nixos/modules/programs/nix-ld.nix#L44-L59 + defaultLibraries = with pkgs; [ + zlib + zstd + stdenv.cc.cc + curl + openssl + attr + libssh + bzip2 + libxml2 + acl + libsodium + util-linux + xz + systemd + ]; + + # https://github.com/Mic92/dotfiles/blob/340152bdf4bd193269474426ca5d90c479aae0b7/nixos/modules/nix-ld.nix#L7-L58 + overkillLibraries = with pkgs; [ + alsa-lib + at-spi2-atk + at-spi2-core + atk + cairo + cups + curl + dbus + expat + fontconfig + freetype + fuse3 + gdk-pixbuf + glib + gtk3 + icu + libGL + libappindicator-gtk3 + libdrm + libglvnd + libnotify + libpulseaudio + libunwind + libusb1 + libuuid + libxkbcommon + mesa + nspr + nss + openssl + pango + pipewire + stdenv.cc.cc + systemd + vulkan-loader + xorg.libX11 + xorg.libXScrnSaver + xorg.libXcomposite + xorg.libXcursor + xorg.libXdamage + xorg.libXext + xorg.libXfixes + xorg.libXi + xorg.libXrandr + xorg.libXrender + xorg.libXtst + xorg.libxcb + xorg.libxkbfile + xorg.libxshmfence + zlib + ]; + in { - options.oizys.nix-ld.enable = mkEnableOption "enable nix-ld support"; - config = mkIf cfg.enable { - programs.nix-ld.enable = true; + options.oizys.nix-ld = { + enable = mkEnableOption "enable nix-ld support"; + extra-libraries = mkOption { + type = types.listOf types.package; + description = "Libraries that automatically become available to all programs."; + default = [ ]; + defaultText = literalExpression "baseLibraries derived from systemd and nix dependencies."; + }; + overkill.enable = mkEnableOption "enable overkill list of libraries"; - # Packages that need at least something in this list: - # Geneious Prime - # list from https://github.com/Mic92/dotfiles/blob/cb180bdd3805b373e556a93ccb275b7f0f902a3b/nixos/modules/nix-ld.nix#L9C3-L60C5 - programs.nix-ld.libraries = with pkgs; [ - alsa-lib - at-spi2-atk - at-spi2-core - atk - cairo - cups - curl - dbus - expat - fontconfig - freetype - fuse3 - gdk-pixbuf - glib - gtk3 - icu - libGL - libappindicator-gtk3 - libdrm - libglvnd - libnotify - libpulseaudio - libunwind - libusb1 - libuuid - libxkbcommon - mesa - nspr - nss - openssl - pango - # pipewire - stdenv.cc.cc - systemd - vulkan-loader - xorg.libX11 - xorg.libXScrnSaver - xorg.libXcomposite - xorg.libXcursor - xorg.libXdamage - xorg.libXext - xorg.libXfixes - xorg.libXi - xorg.libXrandr - xorg.libXrender - xorg.libXtst - xorg.libxcb - xorg.libxkbfile - xorg.libxshmfence - zlib - ]; }; + + config = + mkIf cfg.enable + + { + programs.nix-ld.enable = true; + programs.nix-ld.libraries = + + defaultLibraries ++ cfg.extra-libraries ++ (if cfg.overkill.enable then overkillLibraries else [ ]); + }; + } diff --git a/todo.md b/todo.md index 7d1129a..4357aa9 100644 --- a/todo.md +++ b/todo.md @@ -2,11 +2,6 @@ ## oizys -- [ ] make interoperable with a single command so first installation can be ran by root as: - ```sh - nix --extra-experimental-features 'flakes nix-command' run "github:daylinmorgan/oiyzs" switch --host - ``` - ## software - [ ] lid closed does not engage hyprlock?