configuration.nix/scripts/default.nix
Jalil David Salamé Messina ac41d8527f
All checks were successful
/ check (push) Successful in 30s
/ build (docs) (push) Successful in 3s
/ build (nixosConfigurations.vm.config.system.build.toplevel) (push) Successful in 28s
/ build (nvim) (push) Successful in 15s
[feat] scripts: import jpassmenu and RiiR
2024-07-20 01:34:06 +02:00

23 lines
862 B
Nix

# 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.
let
files = builtins.readDir ./.;
isPackage = path: type: (type == "directory") && (builtins.readDir path) ? "package.nix";
toPackage = name: pkgs: {
inherit name;
value = pkgs.callPackage (./. + "/${name}/package.nix") { };
};
# call pkgs.callPackage on all ./*/package.nix
makePackage =
pkgs: name:
let
type = files.${name};
path = ./. + "/${name}";
package = toPackage name pkgs;
in
# if it is a package then return a package otherwise return no package c:
if isPackage path type then [ package ] else [ ];
in
# we have lib.filterMapAttrs at home
pkgs: builtins.listToAttrs (builtins.concatMap (makePackage pkgs) (builtins.attrNames files))