pub-solar-os/flake.nix
Jan Tojnar 0b14dbbc2d
flake: Refactor nixosModules collection
We will want to reuse the prep method for overlays so let's move it higher and simplify it a bit.
2020-06-02 01:14:33 +02:00

59 lines
1.7 KiB
Nix

{
description = "A highly structured configuration database.";
inputs.nixpkgs.url = "nixpkgs/release-20.03";
inputs.home.url = "github:nrdxp/home-manager/flakes";
outputs = inputs@{ self, home, nixpkgs }:
let
inherit (builtins) listToAttrs baseNameOf attrNames readDir;
inherit (nixpkgs.lib) removeSuffix;
system = "x86_64-linux";
# Generate an attribute set by mapping a function over a list of values.
genAttrs' = values: f: listToAttrs (map f values);
# Convert a list to file paths to attribute set
# that has the filenames stripped of nix extension as keys
# and imported content of the file as value.
pathsToImportedAttrs = paths:
genAttrs' paths (path: {
name = removeSuffix ".nix" (baseNameOf path);
value = import path;
});
pkgs = import nixpkgs {
inherit system;
overlays = self.overlays;
config = { allowUnfree = true; };
};
in {
nixosConfigurations =
let configs = import ./hosts (inputs // { inherit system pkgs; });
in configs;
overlay = import ./pkgs;
overlays = let
overlays = map (name: import (./overlays + "/${name}"))
(attrNames (readDir ./overlays));
in overlays;
packages.x86_64-linux = {
inherit (pkgs) sddm-chili dejavu_nerdfont purs pure;
};
nixosModules = let
# modules
moduleList = import ./modules/list.nix;
modulesAttrs = pathsToImportedAttrs moduleList;
# profiles
profilesList = import ./profiles/list.nix;
profilesAttrs = { profiles = pathsToImportedAttrs profilesList; };
in modulesAttrs // profilesAttrs;
};
}