2025-04-18 16:46:54 -07:00
|
|
|
# This function creates a NixOS system based on our VM setup for a
|
|
|
|
# particular architecture.
|
|
|
|
{
|
|
|
|
nixpkgs,
|
|
|
|
overlays,
|
|
|
|
inputs,
|
|
|
|
}: name: {
|
|
|
|
system,
|
|
|
|
user,
|
|
|
|
darwin ? false,
|
|
|
|
extraModules ? [],
|
|
|
|
}: let
|
2025-04-19 10:06:25 -07:00
|
|
|
nixindex =
|
|
|
|
if darwin
|
|
|
|
then inputs.nix-index-database.darwinModules.nix-index
|
|
|
|
else inputs.nix-index-database.nixosModules.nix-index;
|
2025-04-18 16:46:54 -07:00
|
|
|
|
2025-04-19 10:06:25 -07:00
|
|
|
host =
|
|
|
|
if darwin
|
|
|
|
then "laptop"
|
|
|
|
else "desktop";
|
2025-04-18 16:46:54 -07:00
|
|
|
|
|
|
|
# The config files for this system.
|
|
|
|
|
|
|
|
hostConfig = ../hosts/${host}/configuration.nix;
|
2025-04-19 10:35:31 -07:00
|
|
|
homeConfig = ../hosts/${host}/home.nix;
|
2025-04-18 16:46:54 -07:00
|
|
|
|
2025-04-19 11:04:56 -07:00
|
|
|
homeDir =
|
|
|
|
if darwin
|
|
|
|
then "/Users/nmarks/"
|
|
|
|
else "/home/nmarks";
|
|
|
|
|
2025-04-18 16:46:54 -07:00
|
|
|
# NixOS vs nix-darwin functions
|
2025-04-19 10:06:25 -07:00
|
|
|
systemFunc =
|
|
|
|
if darwin
|
|
|
|
then inputs.darwin.lib.darwinSystem
|
|
|
|
else nixpkgs.lib.nixosSystem;
|
|
|
|
|
2025-04-19 10:35:31 -07:00
|
|
|
hmModules =
|
2025-04-18 16:46:54 -07:00
|
|
|
if darwin
|
|
|
|
then inputs.home-manager.darwinModules
|
|
|
|
else inputs.home-manager.nixosModules;
|
|
|
|
in
|
|
|
|
systemFunc rec {
|
|
|
|
inherit system;
|
|
|
|
|
|
|
|
modules =
|
|
|
|
[
|
|
|
|
# Apply our overlays. Overlays are keyed by system type so we have
|
|
|
|
# to go through and apply our system type. We do this first so
|
|
|
|
# the overlays are available globally.
|
|
|
|
{nixpkgs.overlays = overlays;}
|
2025-04-19 10:06:25 -07:00
|
|
|
|
|
|
|
# Enable caching for nix-index so we dont have to rebuild it
|
|
|
|
|
|
|
|
#shared modules
|
2025-04-19 21:57:56 -07:00
|
|
|
../modules/shared/extras.nix
|
|
|
|
../modules/shared/nix.nix
|
2025-04-19 10:06:25 -07:00
|
|
|
|
2025-04-18 16:46:54 -07:00
|
|
|
hostConfig
|
|
|
|
nixindex
|
2025-04-19 10:35:31 -07:00
|
|
|
{programs.nix-index-database.comma.enable = true;}
|
|
|
|
hmModules.home-manager
|
2025-04-18 16:46:54 -07:00
|
|
|
{
|
|
|
|
home-manager = {
|
|
|
|
useGlobalPkgs = true;
|
|
|
|
useUserPackages = true;
|
|
|
|
backupFileExtension = "hm-backup";
|
2025-04-19 13:50:58 -07:00
|
|
|
extraSpecialArgs = {inherit inputs user;};
|
2025-04-19 10:35:31 -07:00
|
|
|
users.${user} = homeConfig;
|
2025-04-18 16:46:54 -07:00
|
|
|
};
|
2025-04-19 13:50:58 -07:00
|
|
|
|
|
|
|
users.users.${user}.home = homeDir;
|
2025-04-18 16:46:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
# We expose some extra arguments so that our modules can parameterize
|
|
|
|
# better based on these values.
|
|
|
|
{
|
|
|
|
config._module.args = {
|
|
|
|
currentSystem = system;
|
|
|
|
currentSystemName = name;
|
|
|
|
currentSystemUser = user;
|
|
|
|
inherit inputs;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]
|
|
|
|
++ extraModules;
|
|
|
|
}
|