default.nix: support for traditional channels

Though, it's limited compared to flakes. I supposed that's better than
nothing.
This commit is contained in:
Gabriel Arazas 2022-07-14 08:17:02 +08:00
parent 0c7f57f5a9
commit 6a0c115432
4 changed files with 25 additions and 12 deletions

View File

@ -113,6 +113,7 @@ nixos-config
├── shells/ ├── shells/
├── templates/ ├── templates/
├── users/ ├── users/
├── default.nix
├── flake.lock ├── flake.lock
├── flake.nix ├── flake.nix
└── README.adoc └── README.adoc

11
default.nix Normal file
View File

@ -0,0 +1,11 @@
{ pkgs ? import <nixpkgs> { } }:
let
lib' = pkgs.lib.extend (final: prev:
import ./lib { lib = prev; } // import ./lib/private.nix { lib = final; });
in {
lib = import ./lib { lib = pkgs.lib; };
modules = lib'.importModules (lib'.filesToAttr ./modules/nixos);
overlays.foo-dogsquared-pkgs = final: prev: import ./pkgs { pkgs = prev; };
hmModules = lib'.importModules (lib'.filesToAttr ./modules/home-manager);
} // (import ./pkgs { inherit pkgs; })

View File

@ -232,16 +232,6 @@
}; };
}; };
# A list of module namespaces that will not be imported into the output.
# It could be blocked for whatever reason or as indicated.
blocklist = [
# The modules under this attribute are often incomplete and needing
# very specific requirements that is 99% going to be absent from the
# outside so we're not going to export it.
"tasks"
];
importModules = attrs:
lib'.filterAttrs (n: v: !lib'.elem n blocklist) (lib'.mapAttrsRecursive (_: path: import path) attrs);
in { in {
# Exposes only my library with the custom functions to make it easier to # Exposes only my library with the custom functions to make it easier to
# include in other flakes for whatever reason may be. # include in other flakes for whatever reason may be.
@ -260,7 +250,7 @@
# We're going to make our custom modules available for our flake. Whether # We're going to make our custom modules available for our flake. Whether
# or not this is a good thing is debatable, I just want to test it. # or not this is a good thing is debatable, I just want to test it.
nixosModules = importModules (lib'.filesToAttr ./modules/nixos); nixosModules = lib'.importModules (lib'.filesToAttr ./modules/nixos);
# I can now install home-manager users in non-NixOS systems. # I can now install home-manager users in non-NixOS systems.
# NICE! # NICE!
@ -278,7 +268,7 @@
(lib'.filesToAttr ./users/home-manager); (lib'.filesToAttr ./users/home-manager);
# Extending home-manager with my custom modules, if anyone cares. # Extending home-manager with my custom modules, if anyone cares.
homeManagerModules = importModules (lib'.filesToAttr ./modules/home-manager); homeManagerModules = lib'.importModules (lib'.filesToAttr ./modules/home-manager);
# My custom packages, available in here as well. Though, I mainly support # My custom packages, available in here as well. Though, I mainly support
# "x86_64-linux". I just want to try out supporting other systems. # "x86_64-linux". I just want to try out supporting other systems.

View File

@ -35,4 +35,15 @@ rec {
getUser = type: user: getUser = type: user:
lib.getAttr user (getUsers type [ user ]); lib.getAttr user (getUsers type [ user ]);
# Import modules with a set blocklist.
importModules = let
blocklist = [
# The modules under this attribute are often incomplete and needing
# very specific requirements that is 99% going to be absent from the
# outside so we're not going to export it.
"tasks"
];
in attrs:
lib.filterAttrs (n: v: !lib.elem n blocklist) (lib.mapAttrsRecursive (_: path: import path) attrs);
} }