eab0bf074c
Also format all files and add a flake.lock for lib for a folder thats meant to work on other flakes theres never a reason it should need to refer to itself, only other flakes. So "self" and "inputs" are better namings for these variables. The userFlake* is redundant and confusing, when trying to call the functions its hard to figure out how to use them when there are now two lines of arguments to figure out.
110 lines
2.6 KiB
Nix
110 lines
2.6 KiB
Nix
{ lib }:
|
|
|
|
{ self, nixos, inputs, dir, extern, suites, overrides, multiPkgs }:
|
|
let
|
|
defaultSystem = "x86_64-linux";
|
|
|
|
experimentalFeatures = [
|
|
"flakes"
|
|
"nix-command"
|
|
"ca-references"
|
|
"ca-derivations"
|
|
];
|
|
|
|
modules = {
|
|
modOverrides = { config, overrideModulesPath, ... }:
|
|
let
|
|
inherit (overrides) modules disabledModules;
|
|
in
|
|
{
|
|
disabledModules = modules ++ disabledModules;
|
|
imports = map
|
|
(path: "${overrideModulesPath}/${path}")
|
|
modules;
|
|
};
|
|
|
|
global = { config, pkgs, ... }: {
|
|
home-manager = {
|
|
useGlobalPkgs = true;
|
|
useUserPackages = true;
|
|
|
|
extraSpecialArgs = extern.userSpecialArgs // { suites = suites.user; };
|
|
sharedModules = extern.userModules ++ (builtins.attrValues self.homeModules);
|
|
};
|
|
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;
|
|
};
|
|
|
|
# Everything in `./modules/list.nix`.
|
|
flakeModules = { imports = builtins.attrValues self.nixosModules ++ extern.modules; };
|
|
|
|
cachix = let rootCachix = "${self}/cachix.nix"; in
|
|
if builtins.pathExists rootCachix
|
|
then rootCachix
|
|
else { }
|
|
;
|
|
};
|
|
|
|
specialArgs = extern.specialArgs // { suites = suites.system; };
|
|
|
|
mkHostConfig = hostName:
|
|
let
|
|
local = {
|
|
require = [
|
|
"${dir}/${hostName}.nix"
|
|
];
|
|
|
|
networking = { inherit hostName; };
|
|
|
|
_module.args = {
|
|
self = self;
|
|
hosts = builtins.mapAttrs (_: host: host.config)
|
|
(removeAttrs hosts [ hostName ]);
|
|
};
|
|
|
|
lib = { inherit specialArgs; };
|
|
lib.testModule = {
|
|
imports = builtins.attrValues modules;
|
|
};
|
|
|
|
};
|
|
in
|
|
lib.os.devosSystem {
|
|
inherit self nixos inputs specialArgs;
|
|
system = defaultSystem;
|
|
modules = modules // { inherit local; };
|
|
};
|
|
|
|
hosts = lib.os.recImport
|
|
{
|
|
inherit dir;
|
|
_import = mkHostConfig;
|
|
};
|
|
in
|
|
hosts
|