modules: fix custom library

This commit is contained in:
Gabriel Arazas 2024-02-25 22:27:05 +08:00
parent 5af7ac1c3d
commit ac036d10a9
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
8 changed files with 31 additions and 31 deletions

View File

@ -1,7 +1,7 @@
# The entrypoint for our custom library set. # The entrypoint for our custom library set.
{ lib }: { pkgs }:
lib.makeExtensible pkgs.lib.makeExtensible
(self: (self:
rec { rec {
/* Count the attributes with the given predicate. /* Count the attributes with the given predicate.
@ -14,8 +14,8 @@ lib.makeExtensible
=> 1 => 1
*/ */
countAttrs = pred: attrs: countAttrs = pred: attrs:
lib.count (attr: pred attr.name attr.value) pkgs.lib.count (attr: pred attr.name attr.value)
(lib.mapAttrsToList lib.nameValuePair attrs); (pkgs.lib.mapAttrsToList pkgs.lib.nameValuePair attrs);
/* Returns the file path of the given config of the given environment. /* Returns the file path of the given config of the given environment.

View File

@ -1,5 +1,5 @@
# Custom libraries for home-manager library. # Custom libraries for home-manager library.
{ lib }: { pkgs, lib }:
rec { rec {
/* /*
@ -15,7 +15,7 @@ rec {
# The default value when `attrPath` is missing. # The default value when `attrPath` is missing.
default: default:
attrs ? nixosConfig && lib.attrByPath attrPath default attrs; attrs ? nixosConfig && pkgs.lib.attrByPath attrPath default attrs;
hasDarwinConfigAttr = hasDarwinConfigAttr =
# The configuration attribute set of the home-manager configuration. # The configuration attribute set of the home-manager configuration.
@ -26,7 +26,7 @@ rec {
# The default value when `attrPath` is missing. # The default value when `attrPath` is missing.
default: default:
attrs ? darwinConfig && lib.attrByPath attrPath default attrs; attrs ? darwinConfig && pkgs.lib.attrByPath attrPath default attrs;
/* /*
A quick function to check if the optional NixOS system module is enabled. A quick function to check if the optional NixOS system module is enabled.

View File

@ -1,5 +1,5 @@
# All of the functions suitable only for NixOS. # All of the functions suitable only for NixOS.
{ lib }: { pkgs, lib }:
rec { rec {
# This is only used for home-manager users without a NixOS user counterpart. # This is only used for home-manager users without a NixOS user counterpart.
@ -7,10 +7,10 @@ rec {
let let
homeDirectory = "/home/${user}"; homeDirectory = "/home/${user}";
defaultUserConfig = { defaultUserConfig = {
extraGroups = lib.mkDefault [ "wheel" ]; extraGroups = pkgs.lib.mkDefault [ "wheel" ];
createHome = lib.mkDefault true; createHome = pkgs.lib.mkDefault true;
home = lib.mkDefault homeDirectory; home = pkgs.lib.mkDefault homeDirectory;
isNormalUser = lib.mkForce true; isNormalUser = pkgs.lib.mkForce true;
}; };
in in
({ lib, ... }: { ({ lib, ... }: {

View File

@ -1,4 +1,4 @@
{ config, lib }: { config, pkgs, lib }:
{ {
isStandalone = isStandalone =

View File

@ -1,5 +1,5 @@
# A library specifically for environments with sops-nix. # A library specifically for environments with sops-nix.
{ lib }: { pkgs, lib }:
{ {
/* Get the secrets from a given sops file. This will set the individual /* Get the secrets from a given sops file. This will set the individual
@ -21,7 +21,7 @@
let let
getKey = key: { inherit key sopsFile; }; getKey = key: { inherit key sopsFile; };
in in
lib.mapAttrs pkgs.lib.mapAttrs
(path: attrs: (path: attrs:
(getKey path) // attrs) (getKey path) // attrs)
secrets; secrets;
@ -44,9 +44,9 @@
})) }))
*/ */
attachSopsPathPrefix = prefix: secrets: attachSopsPathPrefix = prefix: secrets:
lib.mapAttrs' pkgs.lib.mapAttrs'
(key: settings: (key: settings:
lib.nameValuePair pkgs.lib.nameValuePair
"${prefix}/${key}" "${prefix}/${key}"
({ inherit key; } // settings)) ({ inherit key; } // settings))
secrets; secrets;

View File

@ -1,15 +1,15 @@
# All of the extra module arguments to be passed as part of the home-manager # All of the extra module arguments to be passed as part of the home-manager
# environment. # environment.
{ options, lib, ... }: { options, pkgs, lib, ... }:
let let
foodogsquaredLib = import ../../../lib { inherit lib; }; foodogsquaredLib = import ../../../lib { inherit pkgs; };
in in
{ {
_module.args.foodogsquaredLib = _module.args.foodogsquaredLib =
foodogsquaredLib.extend (self: foodogsquaredLib.extend (final: prev:
import ../../../lib/home-manager.nix { inherit lib; } import ../../../lib/home-manager.nix { inherit pkgs; lib = prev; }
// lib.optionalAttrs (options?sops) { // lib.optionalAttrs (options?sops) {
sops-nix = import ../../../lib/sops.nix { inherit lib; }; sops-nix = import ../../../lib/sops.nix { inherit pkgs; lib = prev; };
}); });
} }

View File

@ -1,15 +1,15 @@
# All of the extra module arguments to be passed as part of the holistic NixOS # All of the extra module arguments to be passed as part of the holistic NixOS
# system. # system.
{ options, lib, ... }: { options, lib, pkgs, ... }:
let let
foodogsquaredLib = import ../../../lib { inherit lib; }; foodogsquaredLib = import ../../../lib { inherit pkgs; };
in in
{ {
_module.args.foodogsquaredLib = _module.args.foodogsquaredLib =
foodogsquaredLib.extend (self: foodogsquaredLib.extend (final: prev:
import ../../../lib/nixos.nix { inherit lib; } import ../../../lib/nixos.nix { inherit pkgs; lib = prev; }
// lib.optionalAttrs (options?sops) { // lib.optionalAttrs (options?sops) {
sops-nix = import ../../../lib/sops.nix { inherit lib; }; sops-nix = import ../../../lib/sops.nix { inherit pkgs; lib = prev; };
}); });
} }

View File

@ -1,11 +1,11 @@
# All of the extra module arguments to be passed as part of NixVim module. # All of the extra module arguments to be passed as part of NixVim module.
{ options, lib, ... }: { options, config, lib, pkgs, ... }:
let let
foodogsquaredLib = import ../../../lib { inherit lib; }; foodogsquaredLib = import ../../../lib { inherit pkgs; };
in in
{ {
_module.args.foodogsquaredLib = _module.args.foodogsquaredLib =
foodogsquaredLib.extend (self: foodogsquaredLib.extend (final: prev:
import ../../../lib/nixvim.nix { inherit lib; }); import ../../../lib/nixvim.nix { inherit config pkgs; lib = prev; });
} }