forked from pub-solar/os
c012f2f4ed
- [x] refactor lib into separate files, similar to NixOS/nixpkgs/lib. - [x] refactor ci to automatically generate derivations from flake outputs - [x] remove cluttered indirection statements throughout the codebase - [x] refactor hosts to allow for upcoming integration tests - [x] improve ambiguity in the existing docs - [x] add [BORS](https://bors.tech) support - [x] add initial integration test - [x] write tests documentation - [x] test lib - [x] improve version string generation, and do so automatically for pkgs/flake.nix sources Clean up the codebase as best we can in preparation for #152 and add tests. From now on, all PRs will be merged with BORS.
36 lines
768 B
Nix
36 lines
768 B
Nix
{ lib, ... }:
|
|
|
|
let mkProfileAttrs =
|
|
/**
|
|
Synopsis: mkProfileAttrs _path_
|
|
|
|
Recursively collect the subdirs of _path_ containing a default.nix into attrs.
|
|
This sets a contract, eliminating ambiguity for _default.nix_ living under the
|
|
profile directory.
|
|
|
|
Example:
|
|
let profiles = mkProfileAttrs ./profiles; in
|
|
assert profiles ? core.default; 0
|
|
**/
|
|
dir:
|
|
let
|
|
imports =
|
|
let
|
|
files = builtins.readDir dir;
|
|
|
|
p = n: v:
|
|
v == "directory"
|
|
&& n != "profiles";
|
|
in
|
|
lib.filterAttrs p files;
|
|
|
|
f = n: _:
|
|
lib.optionalAttrs
|
|
(lib.pathExists "${dir}/${n}/default.nix")
|
|
{ default = "${dir}/${n}"; }
|
|
// mkProfileAttrs "${dir}/${n}";
|
|
in
|
|
lib.mapAttrs f imports;
|
|
in mkProfileAttrs
|
|
|