lib: standardize the required arguments

Just to make it consistent.
This commit is contained in:
Gabriel Arazas 2024-03-01 18:09:47 +08:00
parent d183306336
commit 40352d6a74
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
5 changed files with 21 additions and 49 deletions

View File

@ -1,43 +1,14 @@
# All of the functions suitable only for NixOS. # All of the functions suitable only for NixOS.
{ pkgs, config, lib }: { pkgs, lib }:
rec { rec {
# This is only used for home-manager users without a NixOS user counterpart.
mapHomeManagerUser = user: settings:
let
homeDirectory = "/home/${user}";
defaultUserConfig = {
extraGroups = pkgs.lib.mkDefault [ "wheel" ];
createHome = pkgs.lib.mkDefault true;
home = pkgs.lib.mkDefault homeDirectory;
isNormalUser = pkgs.lib.mkForce true;
};
in
({ lib, ... }: {
home-manager.users."${user}" = { ... }: {
imports = [
{
home.username = user;
home.homeDirectory = homeDirectory;
}
../configs/home-manager/${user}
];
};
users.users."${user}" = lib.mkMerge [
defaultUserConfig
settings
];
});
# Checks if the NixOS configuration is part of the nixos-generator build. # Checks if the NixOS configuration is part of the nixos-generator build.
# Typically, we just check if there's a certain attribute that is imported # Typically, we just check if there's a certain attribute that is imported
# from it. # from it.
hasNixosFormat = hasNixosFormat = config:
pkgs.lib.hasAttrByPath [ "formatAttr" ] config; pkgs.lib.hasAttrByPath [ "formatAttr" ] config;
# Checks if the NixOS config is being built for a particular format. # Checks if the NixOS config is being built for a particular format.
isFormat = format: isFormat = config: format:
hasNixosFormat && config.formatAttr == format; hasNixosFormat config && config.formatAttr == format;
} }

View File

@ -1,6 +1,6 @@
{ config, pkgs, lib }: { pkgs, lib }:
{ {
isStandalone = isStandalone = config:
!config?hmConfig && !config?nixosConfig && !config?darwinConfig; !config?hmConfig && !config?nixosConfig && !config?darwinConfig;
} }

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, pkgs, lib, ... }: { pkgs, lib, options, ... }:
let let
foodogsquaredLib = import ../../../lib { inherit pkgs; }; foodogsquaredLib = import ../../../lib { inherit pkgs; };
in in
{ {
_module.args.foodogsquaredLib = _module.args.foodogsquaredLib =
foodogsquaredLib.extend (final: prev: foodogsquaredLib.extend (final: prev: {
import ../../../lib/home-manager.nix { inherit pkgs; lib = prev; } home-manager = import ../../../lib/home-manager.nix { inherit pkgs; lib = prev; };
// lib.optionalAttrs (options?sops) { } // lib.optionalAttrs (options?sops) {
sops-nix = import ../../../lib/sops.nix { inherit pkgs; lib = prev; }; 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.
{ config, options, lib, pkgs, ... }: { pkgs, lib, options, ... }:
let let
foodogsquaredLib = import ../../../lib { inherit pkgs; }; foodogsquaredLib = import ../../../lib { inherit pkgs; };
in in
{ {
_module.args.foodogsquaredLib = _module.args.foodogsquaredLib =
foodogsquaredLib.extend (final: prev: foodogsquaredLib.extend (final: prev: {
import ../../../lib/nixos.nix { inherit pkgs config; lib = prev; } nixos = import ../../../lib/nixos.nix { inherit pkgs; lib = final; };
// lib.optionalAttrs (options?sops) { } // lib.optionalAttrs (options?sops) {
sops-nix = import ../../../lib/sops.nix { inherit pkgs; lib = prev; }; sops-nix = import ../../../lib/sops.nix { inherit pkgs; lib = final; };
}); });
} }

View File

@ -6,6 +6,7 @@ let
in in
{ {
_module.args.foodogsquaredLib = _module.args.foodogsquaredLib =
foodogsquaredLib.extend (final: prev: foodogsquaredLib.extend (final: prev: {
import ../../../lib/nixvim.nix { inherit config pkgs; lib = prev; }); nixvim = import ../../../lib/nixvim.nix { inherit pkgs; lib = prev; };
});
} }