os/hosts/default.nix
Timothy DeHerrera 3a735ce70b
core: pin registry by ref
Users may wish to change the default value of override and nixos
inputs. If they do so, we want the registry listing to reflect the
proper ref names afterwards.

Also create a shell alias to easily search every flake in nix.registry.
2021-02-14 15:50:49 -07:00

117 lines
2.7 KiB
Nix

{ extern
, home
, lib
, nixos
, nixos-hardware
, override
, pkgs
, self
, system
, ...
}:
let
inherit (lib.flk) recImport nixosSystemExtended defaultImports;
inherit (builtins) attrValues removeAttrs;
suites = import ../suites { inherit lib; };
config = hostName:
nixosSystemExtended {
inherit system;
specialArgs = extern.specialArgs // { inherit suites; };
modules =
let
core = import ../profiles/core;
modOverrides = { config, overrideModulesPath, ... }:
let
overrides = import ../overrides;
inherit (overrides) modules disabledModules;
in
{
disabledModules = modules ++ disabledModules;
imports = map
(path: "${overrideModulesPath}/${path}")
modules;
};
global =
let
inherit (lock) nodes;
lock = builtins.fromJSON (builtins.readFile ../flake.lock);
in
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
hardware.enableRedistributableFirmware = lib.mkDefault true;
networking.hostName = hostName;
nix.nixPath = [
"nixpkgs=${nixos}"
"nixos-config=${self}/compat/nixos"
"home-manager=${home}"
];
nixpkgs = { inherit pkgs; };
nix.registry = {
flk.flake = self;
nixos = {
exact = true;
from = nodes.nixos.original;
to = {
inherit (nixos) lastModified narHash rev;
path = override.outPath;
type = "path";
};
};
override = {
exact = true;
from = nodes.override.original;
to = {
inherit (override) lastModified narHash rev;
path = override.outPath;
type = "path";
};
};
};
system.configurationRevision = lib.mkIf (self ? rev) self.rev;
};
local = {
require = [
(import "${toString ./.}/${hostName}.nix")
];
};
# Everything in `./modules/list.nix`.
flakeModules =
attrValues self.nixosModules;
in
flakeModules ++ [
core
global
local
modOverrides
] ++ extern.modules;
};
hosts = recImport {
dir = ./.;
_import = config;
};
in
hosts