mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
[nix] Rewrite the autoimport code
This commit is contained in:
parent
d857a6a0dc
commit
853afc9541
1 changed files with 28 additions and 15 deletions
|
@ -1,5 +1,6 @@
|
||||||
{ pkgs, lib, dotfiles, ... }:
|
{ pkgs, specialArgs, lib, dotfiles, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
let
|
let
|
||||||
textEditor = "nvim";
|
textEditor = "nvim";
|
||||||
|
|
||||||
|
@ -73,6 +74,7 @@ let
|
||||||
everything = system ++ base ++ languages ++ programs ++ multimedia ++ fonts;
|
everything = system ++ base ++ languages ++ programs ++ multimedia ++ fonts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Old solution kept for posterity {{{
|
||||||
# We've got a small issue here. I tested this in a repl, and what I've
|
# We've got a small issue here. I tested this in a repl, and what I've
|
||||||
# observed is that listFilesRecursive spits out [ /full/path/to/default.nix ],
|
# observed is that listFilesRecursive spits out [ /full/path/to/default.nix ],
|
||||||
# while builtins.readDir spits out { "default.nix" = "regular"; }
|
# while builtins.readDir spits out { "default.nix" = "regular"; }
|
||||||
|
@ -90,19 +92,30 @@ let
|
||||||
# be generated from the entire directory listing, it isn't going to work out.
|
# be generated from the entire directory listing, it isn't going to work out.
|
||||||
# The solution was slightly modified from this Reddit answer:
|
# The solution was slightly modified from this Reddit answer:
|
||||||
# <https://www.reddit.com/r/NixOS/comments/j5pa9o/comment/g81dvop/>
|
# <https://www.reddit.com/r/NixOS/comments/j5pa9o/comment/g81dvop/>
|
||||||
# So, let's get all files in the current directory...
|
|
||||||
importMap = map
|
|
||||||
(n: "${n}")
|
|
||||||
(lib.filesystem.listFilesRecursive ./.);
|
|
||||||
# importMap = map
|
# importMap = map
|
||||||
# (n: "${./.}/${n}")
|
# (n: "${n}")
|
||||||
# (builtins.attrNames (builtins.readDir ./.));
|
# (lib.filesystem.listFilesRecursive ./.);
|
||||||
|
# importsFiltered =
|
||||||
|
# builtins.filter
|
||||||
|
# (x: !lib.strings.hasInfix "default" x)
|
||||||
|
# importMap;
|
||||||
|
# }}}
|
||||||
|
|
||||||
# And filter out default.nix
|
getDir = dir: mapAttrs
|
||||||
importsFiltered =
|
(file: type:
|
||||||
builtins.filter
|
if type == "directory" then getDir "${dir}/${file}" else type
|
||||||
(x: !lib.strings.hasInfix "default" x)
|
)
|
||||||
importMap;
|
(builtins.readDir dir);
|
||||||
|
|
||||||
|
files = dir: collect isString (mapAttrsRecursive
|
||||||
|
(path: type: concatStringsSep "/" path)
|
||||||
|
(getDir dir));
|
||||||
|
|
||||||
|
validFiles = dir: map
|
||||||
|
(file: ./. + "/${file}")
|
||||||
|
(filter
|
||||||
|
(file: hasSuffix ".nix" file && file != "default.nix")
|
||||||
|
(files dir));
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -131,8 +144,8 @@ in
|
||||||
useUserPackages = true;
|
useUserPackages = true;
|
||||||
extraSpecialArgs = { inherit dotfiles; };
|
extraSpecialArgs = { inherit dotfiles; };
|
||||||
users.alyxia = { pkgs, ... }: {
|
users.alyxia = { pkgs, ... }: {
|
||||||
# Defined further above, a list of files to import.
|
# Defined further above, generates a list of files to import.
|
||||||
imports = importsFiltered;
|
imports = validFiles ./.;
|
||||||
|
|
||||||
home = {
|
home = {
|
||||||
packages = packageSets.everything;
|
packages = packageSets.everything;
|
||||||
|
@ -192,7 +205,7 @@ in
|
||||||
"itch"
|
"itch"
|
||||||
"iterm2"
|
"iterm2"
|
||||||
"obs"
|
"obs"
|
||||||
"plex"
|
"plexamp"
|
||||||
"raycast"
|
"raycast"
|
||||||
"sequel-ace"
|
"sequel-ace"
|
||||||
"shottr"
|
"shottr"
|
||||||
|
|
Loading…
Reference in a new issue