Last active
December 10, 2023 17:10
-
-
Save yunfachi/6c073cc6edc18f78cfc60bb9bb3f7143 to your computer and use it in GitHub Desktop.
Nix / NixOS : Import all files from current directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{...}: { | |
# imports by full path without copying to /nix/store | |
imports = builtins.map (n: toString ./. + "/${n}") (builtins.attrNames (builtins.removeAttrs (builtins.readDir ./.) [(builtins.unsafeGetAttrPos "_" {_ = null;}).file])); | |
# copies all files from the current directory to /nix/store and imports from /nix/store | |
# imports = builtins.map (n: "${./.}/${n}") (builtins.attrNames (builtins.removeAttrs (builtins.readDir ./.) [(builtins.unsafeGetAttrPos "_" {_ = null;}).file])); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
a more advanced implementation of this thing
https://github.com/yunfachi/nixpkgs-yunfachi/blob/master/lib/umport.nix