Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- { lib, ... }:
- with lib;
- let
- # Recursively constructs an attrset of a given folder, recursing on directories, value of attrs is the filetype
- getDir = dir: mapAttrs
- (file: type:
- if type == "directory" then getDir "${dir}/${file}" else type
- )
- (builtins.readDir dir);
- # Collects all files of a directory as a list of strings of paths
- files = dir: collect isString (mapAttrsRecursive (path: type: concatStringsSep "/" path) (getDir dir));
- # Filters out directories that don't end with .nix or are this file, also makes the strings absolute
- validFiles = dir: map
- (file: ./. + "/${file}")
- (filter
- (file: hasSuffix ".nix" file && file != "default.nix" &&
- ! lib.hasPrefix "x/taffybar/" file &&
- ! lib.hasSuffix "-hm.nix" file)
- (files dir));
- finalFiles = validFiles ./.;
- mkPins = inputs:
- pkgs.runCommand "ifd-pins" { } ''
- mkdir $out
- cd $out
- ${lib.concatMapStringsSep "\n" (i: "ln -sv ${i.value} ${i.key}")
- (lib.attrValues
- (lib.mapAttrs (key: value: { inherit key value; }) inputs))}
- '';
- finalImports = builtins.map (i: import i) finalFiles;
- in
- {
- #imports = validFiles ./.;
- imports = mkPins finalImports;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement