refactor(scripts): remove unnecessary imports
They slow down evaluations
This commit is contained in:
parent
46ba379d08
commit
165c403072
3 changed files with 23 additions and 23 deletions
|
@ -13,7 +13,7 @@ in
|
||||||
./home-modules.nix
|
./home-modules.nix
|
||||||
./nixvim-modules.nix
|
./nixvim-modules.nix
|
||||||
./overlays.nix
|
./overlays.nix
|
||||||
./scripts.nix
|
../scripts
|
||||||
];
|
];
|
||||||
|
|
||||||
perSystem =
|
perSystem =
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
let
|
|
||||||
scripts = import ../scripts;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
# Add scripts to overlay
|
|
||||||
flake.overlays.scripts = final: prev: scripts final;
|
|
||||||
|
|
||||||
# Add scripts to packages
|
|
||||||
perSystem =
|
|
||||||
{ pkgs, ... }:
|
|
||||||
{
|
|
||||||
packages = scripts pkgs;
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,23 +1,37 @@
|
||||||
# Autodetects files with a package.nix and calls `callPackage` on them.
|
{ lib, ... }:
|
||||||
#
|
|
||||||
# Will add a package .#dirname to the flake if it finds a ./dirname/package.nix file.
|
|
||||||
let
|
let
|
||||||
files = builtins.readDir ./.;
|
src = ./.;
|
||||||
|
# Autodetects files with a package.nix and calls `callPackage` on them.
|
||||||
|
#
|
||||||
|
# Will add a package .#dirname to the flake if it finds a ./dirname/package.nix file.
|
||||||
|
files = builtins.readDir src;
|
||||||
isPackage = path: type: (type == "directory") && (builtins.readDir path) ? "package.nix";
|
isPackage = path: type: (type == "directory") && (builtins.readDir path) ? "package.nix";
|
||||||
toPackage = name: pkgs: {
|
toPackage = name: pkgs: {
|
||||||
inherit name;
|
inherit name;
|
||||||
value = pkgs.callPackage (./. + "/${name}/package.nix") { };
|
value = pkgs.callPackage "${src}/${name}/package.nix" { };
|
||||||
};
|
};
|
||||||
# call pkgs.callPackage on all ./*/package.nix
|
# call pkgs.callPackage on all ./*/package.nix
|
||||||
makePackage =
|
makePackage =
|
||||||
pkgs: name:
|
pkgs: name:
|
||||||
let
|
let
|
||||||
type = files.${name};
|
type = files.${name};
|
||||||
path = ./. + "/${name}";
|
path = "${src}/${name}";
|
||||||
package = toPackage name pkgs;
|
package = toPackage name pkgs;
|
||||||
in
|
in
|
||||||
# if it is a package then return a package otherwise return no package c:
|
# if it is a package then return a package otherwise return no package c:
|
||||||
if isPackage path type then [ package ] else [ ];
|
if isPackage path type then [ package ] else [ ];
|
||||||
|
# we have lib.filterMapAttrs at home
|
||||||
|
scripts =
|
||||||
|
pkgs: builtins.listToAttrs (builtins.concatMap (makePackage pkgs) (builtins.attrNames files));
|
||||||
in
|
in
|
||||||
# we have lib.filterMapAttrs at home
|
{
|
||||||
pkgs: builtins.listToAttrs (builtins.concatMap (makePackage pkgs) (builtins.attrNames files))
|
# Add scripts to overlay
|
||||||
|
flake.overlays.scripts = final: scripts;
|
||||||
|
|
||||||
|
# Add scripts to packages
|
||||||
|
perSystem =
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
packages = scripts pkgs;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue