migrate lib functions to lib/, remove extra overlays
Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
This commit is contained in:
parent
298d7423c6
commit
5261a65ecc
56
flake.nix
56
flake.nix
@ -125,7 +125,6 @@
|
||||
}@inputs:
|
||||
let
|
||||
|
||||
inherit (nixpkgs) lib;
|
||||
inherit (self) outputs;
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
@ -133,35 +132,14 @@
|
||||
];
|
||||
|
||||
forEachSystem = lib.genAttrs systems;
|
||||
overlayList = [
|
||||
#self.overlays.default
|
||||
nix.overlays.default
|
||||
];
|
||||
pkgsBySystem = forEachSystem (
|
||||
system:
|
||||
import nixpkgs {
|
||||
inherit system;
|
||||
overlays = overlayList;
|
||||
config = {
|
||||
allowUnfree = true;
|
||||
isHydra = true;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
# filter out all non-nix files and returns the nix-store path
|
||||
# (ie. git configs, git refs, etc)
|
||||
#
|
||||
# used for module imports and system search
|
||||
src = builtins.filterSource (
|
||||
path: type: type == "directory" || lib.hasSuffix ".nix" (baseNameOf path)
|
||||
) ./.;
|
||||
ls = dir: lib.attrNames (builtins.readDir (src + "/${dir}"));
|
||||
lsdir =
|
||||
dir:
|
||||
if (builtins.pathExists (src + "/${dir}")) then
|
||||
(lib.attrNames (
|
||||
lib.filterAttrs (path: type: type == "directory") (builtins.readDir (src + "/${dir}"))
|
||||
))
|
||||
else
|
||||
[ ];
|
||||
fileList = dir: map (file: ./. + "/${dir}/${file}") (ls dir);
|
||||
|
||||
config = {
|
||||
repos = [
|
||||
@ -179,22 +157,21 @@
|
||||
}
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit (self) outputs;
|
||||
hydraJobs = import ./hydra/jobs.nix { inherit inputs outputs; };
|
||||
|
||||
formatter = forEachSystem (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
|
||||
|
||||
# adds our lib functions to lib namespace
|
||||
lib = nixpkgs.lib.extend (
|
||||
self: super: {
|
||||
my = import ./lib {
|
||||
inherit nixpkgs inputs;
|
||||
lib = self;
|
||||
};
|
||||
self: super:
|
||||
import ./lib {
|
||||
inherit nixpkgs inputs;
|
||||
lib = self;
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
inherit (self) outputs;
|
||||
|
||||
hydraJobs = import ./hydra/jobs.nix { inherit inputs outputs; };
|
||||
formatter = forEachSystem (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
|
||||
|
||||
nixosConfigurations =
|
||||
let
|
||||
@ -220,7 +197,7 @@
|
||||
./systems/${hostname}/hardware.nix
|
||||
./systems/${hostname}/configuration.nix
|
||||
]
|
||||
++ fileList "modules"
|
||||
++ (lib.rad-dev.fileList src "modules")
|
||||
++ modules
|
||||
++ lib.optional home home-manager.nixosModules.home-manager
|
||||
++ (
|
||||
@ -271,7 +248,8 @@
|
||||
"home"
|
||||
]
|
||||
);
|
||||
}) (lsdir "systems")
|
||||
}) (lib.rad-dev.lsdir src "systems")
|
||||
|
||||
));
|
||||
|
||||
devShell = lib.mapAttrs (
|
||||
|
61
lib/default.nix
Normal file
61
lib/default.nix
Normal file
@ -0,0 +1,61 @@
|
||||
{ lib, ... }:
|
||||
{
|
||||
# create rad-dev namespace for lib
|
||||
rad-dev = rec {
|
||||
# any(), but checks if any value in the list is true
|
||||
#
|
||||
# args:
|
||||
# n: list of booleans
|
||||
#
|
||||
# type:
|
||||
# anyBool:: [bool] -> bool
|
||||
anyBool = lib.any (n: n);
|
||||
|
||||
# pulls a value out of an attrset and converts it to a list
|
||||
#
|
||||
# args:
|
||||
# attr: attribute to search for in an attrset
|
||||
# set: attrset to search
|
||||
#
|
||||
# type:
|
||||
# mapGetAttr :: String -> Attrset -> [Any]
|
||||
mapGetAttr = (attr: set: lib.mapAttrsToList (_: attrset: lib.getAttr attr attrset) set);
|
||||
|
||||
# gets list of files and directories inside of a directory
|
||||
#
|
||||
# args:
|
||||
# base: base path to search
|
||||
# dir: directory to get files from
|
||||
#
|
||||
# type:
|
||||
# ls :: Path -> String -> [String]
|
||||
ls = base: dir: lib.attrNames (builtins.readDir (base + "/${dir}"));
|
||||
|
||||
# gets list of directories inside of a given directory
|
||||
#
|
||||
# args:
|
||||
# base: base path to search
|
||||
# dir: directory to get files from
|
||||
#
|
||||
# type:
|
||||
# lsdir :: Path -> String -> [String]
|
||||
lsdir =
|
||||
base: dir:
|
||||
if (builtins.pathExists (base + "/${dir}")) then
|
||||
(lib.attrNames (
|
||||
lib.filterAttrs (path: type: type == "directory") (builtins.readDir (base + "/${dir}"))
|
||||
))
|
||||
else
|
||||
[ ];
|
||||
|
||||
# return full paths of all files in a directory
|
||||
#
|
||||
# args:
|
||||
# base: base path to search
|
||||
# dir: path to get files from
|
||||
#
|
||||
# type:
|
||||
# fileList :: Path -> String -> [Path]
|
||||
fileList = base: dir: map (file: base + "/${dir}/${file}") (ls base dir);
|
||||
};
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
# create rad-dev namespace for lib
|
||||
rad-dev = {
|
||||
# any(), but checks if any value in the list is true
|
||||
# type:
|
||||
# anyBool:: [bool] -> bool
|
||||
anyBool = lib.any (n: n);
|
||||
|
||||
# pulls a value out of an attrset and converts it to a list
|
||||
# type:
|
||||
# mapGetAttr :: String -> Attrset -> [Any]
|
||||
mapGetAttr = (attr: set: lib.mapAttrsToList (_: attrset: lib.getAttr attr attrset) set);
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user