os/lib/modules.nix
Pacman99 2d9ea0d27e lib: init modules and move mkHosts modules there
This helps to split up the code in mkHosts and creates a place where we
can store modules relevent to devos. It will also be easier to remove
unecessary parts of each module in the future when they are all
compartmentalized.
2021-04-24 14:44:16 -07:00

75 lines
1.8 KiB
Nix

{ lib }:
{
modOverrides = { overrides }:
{ config, overrideModulesPath, ... }:
let
inherit (overrides) modules disabledModules;
in
{
disabledModules = modules ++ disabledModules;
imports = map
(path: "${overrideModulesPath}/${path}")
modules;
};
hmDefaults = { userSuites, extern, homeModules }: {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = extern.userSpecialArgs // { suites = userSuites; };
sharedModules = extern.userModules ++ (builtins.attrValues homeModules);
};
};
globalDefaults = { self, nixos, inputs, multiPkgs }:
let
experimentalFeatures = [
"flakes"
"nix-command"
"ca-references"
"ca-derivations"
];
in
{ config, pkgs, ... }: {
users.mutableUsers = lib.mkDefault false;
hardware.enableRedistributableFirmware = lib.mkDefault true;
nix.nixPath = [
"nixpkgs=${nixos}"
"nixos-config=${self}/lib/compat/nixos"
"home-manager=${inputs.home}"
];
nixpkgs.pkgs = lib.mkDefault multiPkgs.${config.nixpkgs.system};
nix.registry = {
devos.flake = self;
nixos.flake = nixos;
override.flake = inputs.override;
};
nix.package = pkgs.nixFlakes;
nix.extraOptions = ''
experimental-features = ${lib.concatStringsSep " "
experimentalFeatures
}
'';
system.configurationRevision = lib.mkIf (self ? rev) self.rev;
};
cachix = { self }:
let rootCachix = "${self}/cachix.nix"; in
if builtins.pathExists rootCachix
then rootCachix
else { };
flakeModules = { self, extern }: { imports = builtins.attrValues self.nixosModules ++ extern.modules; };
}