Skip to content

Commit

Permalink
Extend lib to include custom util functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Dal-Pra committed Mar 2, 2024
1 parent 6c37b42 commit ab19162
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
9 changes: 4 additions & 5 deletions home/modules/cli/starship.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{ pkgs, lib, myLib, ... }:
{ pkgs, lib, ... }:

with builtins;
with lib;
with myLib;

let
isRust = path: hasSuffix ".rs" path && path != "mod.rs";
toogleModules = enabled: modules: mergeAll (map (mod: { "${mod}" = { disabled = !enabled; }; }) modules);
toogleModules = enabled: modules: my.mergeAll (map (mod: { "${mod}" = { disabled = !enabled; }; }) modules);
starshipPackage = pkgs.unstable.starship;
promptOrder = [
"nix_shell"
Expand All @@ -33,7 +32,7 @@ let
# - Get the file name, without the extension (<- name of the module)
# - Exclude the enabled modules
disabledModules = pipe modulesSources [
(filterFiles isRust)
(my.filterFiles isRust)
(map (removeSuffix ".rs"))
(subtractLists promptOrder)
(toogleModules false)
Expand Down Expand Up @@ -78,7 +77,7 @@ in
enable = true;
enableZshIntegration = true;
package = starshipPackage;
settings = mergeAll [
settings = my.mergeAll [
enabledModules
disabledModules
starshipConfig
Expand Down
7 changes: 3 additions & 4 deletions home/modules/wm/xmonad.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{ pkgs, config, lib, myLib, ... }:
{ pkgs, config, lib, ... }:

with lib;
with myLib;

let
libPath = ./xmonad-config/lib;
libFiles = pipe libPath [
listFiles
my.listFiles
(map (file: { "${file}" = libPath + "/${file}"; }))
mergeAll
my.mergeAll
];
in
{
Expand Down
9 changes: 2 additions & 7 deletions lib/mk-hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ username: { overlays, home-manager, system }:
let
pkgs = overlays system;
isDarwin = pkgs.lib.strings.hasSuffix system "-darwin";
specialArgs = {
inherit isDarwin;
myLib = import ./utils.nix { inherit (pkgs) lib; };
};
extraSpecialArgs = { inherit isDarwin; };
homeDirectory = if isDarwin then "/Users/${username}" else "/home/${username}";
in
home-manager.lib.homeManagerConfiguration {
inherit pkgs;

extraSpecialArgs = specialArgs;
inherit pkgs extraSpecialArgs;

modules = [
{ home = { inherit username homeDirectory; }; }
Expand Down
3 changes: 1 addition & 2 deletions lib/mk-nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ let
pkgs = overlays system;
specialArgs = {
hmPkgs = home-manager.packages.${system};
myLib = import ./utils.nix { inherit (pkgs) lib; };
};
baseConfig = _: {
system.configurationRevision = revision;
Expand All @@ -15,7 +14,7 @@ let
diskoConfig = import (machineRoot + /disks.nix) { };
in
lib.nixosSystem {
inherit system specialArgs pkgs;
inherit lib system specialArgs pkgs;

modules = [
baseConfig
Expand Down
6 changes: 6 additions & 0 deletions lib/overlays.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ let
unstableOverlay = final: prev: {
unstable = import nixpkgs-unstable { inherit config system; };
};
withCustomLib = final: prev: {
lib = prev.lib // {
my = import ./utils.nix { inherit (prev) lib; };
};
};
in
import nixpkgs {
inherit config system;

overlays = [
nurOverlay
unstableOverlay
withCustomLib
];
}

0 comments on commit ab19162

Please sign in to comment.