lib: restructure folder structure

To easily support channels and flake.
This commit is contained in:
Gabriel Arazas 2023-12-23 11:03:17 +08:00
parent 9e170dd6ec
commit a5ababe88d
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
4 changed files with 19 additions and 12 deletions

View File

@ -1,8 +1,7 @@
{ pkgs ? import <nixpkgs> { } }: { pkgs ? import <nixpkgs> { } }:
let let
lib' = pkgs.lib.extend (final: prev: lib' = pkgs.lib.extend (import ./lib/extras/extend-lib.nix);
import ./lib { lib = prev; } // import ./lib/private.nix { lib = final; });
in in
{ {
lib = import ./lib { lib = pkgs.lib; }; lib = import ./lib { lib = pkgs.lib; };

View File

@ -87,7 +87,7 @@
users = lib'.importTOML ./users.toml; users = lib'.importTOML ./users.toml;
# A set of image-related utilities for the flake outputs. # A set of image-related utilities for the flake outputs.
inherit (import ./lib/images.nix { inherit inputs; lib = lib'; }) mkHost mkHome mkImage listImagesWithSystems; inherit (import ./lib/extras/images.nix { inherit inputs; lib = lib'; }) mkHost mkHome mkImage listImagesWithSystems;
# The order here is important(?). # The order here is important(?).
overlays = [ overlays = [

16
lib/extras/extend-lib.nix Normal file
View File

@ -0,0 +1,16 @@
# A lambda suitable to be used for `pkgs.lib.extend`.
self: super: let
publicLib = import ../. { lib = super; };
in
{
inherit (publicLib) filesToAttr countAttrs getSecrets
attachSopsPathPrefix;
# Until I figure out how to properly add them only for their respective
# environment, this is the working solution for now. Not really perfect
# since we use one nixpkgs instance for each configuration (home-manager or
# otherwise).
private = publicLib
// import ../private.nix { lib = self; }
// import ../home-manager.nix { lib = self; };
}

View File

@ -4,15 +4,7 @@
let let
# A function that generates a lambda suitable for `lib.extend`. # A function that generates a lambda suitable for `lib.extend`.
extendLib = self: super: let extendLib = import ./extend-lib.nix;
publicLib = import ./. { lib = super; };
in
{
inherit (publicLib) filesToAttr countAttrs getSecrets
attachSopsPathPrefix;
private = publicLib
// import ./private.nix { lib = self; };
};
in in
{ {
# A thin wrapper around the NixOS configuration function. # A thin wrapper around the NixOS configuration function.