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,
|
2025-04-21 10:25:32 -07:00
|
|
|
userSettings,
|
2025-04-18 16:46:54 -07:00
|
|
|
}: name: {
|
|
|
|
system,
|
|
|
|
darwin ? false,
|
|
|
|
extraModules ? [],
|
|
|
|
}: let
|
2025-04-21 10:25:32 -07:00
|
|
|
# userSettings = rec {
|
|
|
|
# username = "nmarks"; # username
|
|
|
|
# name = "Natalie"; # name/identifier
|
|
|
|
# email = "nmarks413@gmail.com"; # email (used for certain configurations)
|
|
|
|
# dotfilesDir = "~/.dotfiles"; # absolute path of the local repo
|
|
|
|
# browser = "firefox"; # Default browser; must select one from ./user/app/browser/
|
|
|
|
# term = "ghostty"; # Default terminal command;
|
|
|
|
# font = "iosevka Nerd Font"; # Selected font
|
|
|
|
# editor = "neovim"; # Default editor;
|
|
|
|
# spawnEditor = "exec" + term + "- e " + editor;
|
|
|
|
# };
|
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-21 10:25:32 -07:00
|
|
|
systemSettings = rec {
|
|
|
|
host =
|
|
|
|
if darwin
|
|
|
|
then "laptop"
|
|
|
|
else "desktop";
|
2025-04-18 16:46:54 -07:00
|
|
|
|
2025-04-21 10:25:32 -07:00
|
|
|
# The config files for this system.
|
2025-04-18 16:46:54 -07:00
|
|
|
|
2025-04-21 10:25:32 -07:00
|
|
|
hostConfig = ../hosts/${host}/configuration.nix;
|
|
|
|
homeConfig = ../hosts/${host}/home.nix;
|
2025-04-18 16:46:54 -07:00
|
|
|
|
2025-04-21 10:25:32 -07:00
|
|
|
homeDir =
|
|
|
|
if darwin
|
|
|
|
then "/Users/" + userSettings.username + "/"
|
|
|
|
else "/home/" + userSettings.username + "/";
|
2025-04-19 11:04:56 -07:00
|
|
|
|
2025-04-21 10:25:32 -07:00
|
|
|
# NixOS vs nix-darwin functions
|
|
|
|
systemFunc =
|
|
|
|
if darwin
|
|
|
|
then inputs.darwin.lib.darwinSystem
|
|
|
|
else nixpkgs.lib.nixosSystem;
|
2025-04-19 10:06:25 -07:00
|
|
|
|
2025-04-21 10:25:32 -07:00
|
|
|
hmModules =
|
|
|
|
if darwin
|
|
|
|
then inputs.home-manager.darwinModules
|
|
|
|
else inputs.home-manager.nixosModules;
|
|
|
|
};
|
2025-04-18 16:46:54 -07:00
|
|
|
in
|
2025-04-21 10:25:32 -07:00
|
|
|
with systemSettings;
|
|
|
|
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-18 16:46:54 -07:00
|
|
|
|
2025-04-21 10:25:32 -07:00
|
|
|
# Enable caching for nix-index so we dont have to rebuild it
|
2025-04-19 10:06:25 -07:00
|
|
|
|
2025-04-21 10:25:32 -07:00
|
|
|
#shared modules
|
|
|
|
../modules/shared/extras.nix
|
|
|
|
../modules/shared/nix.nix
|
2025-04-19 10:06:25 -07:00
|
|
|
|
2025-04-21 10:25:32 -07:00
|
|
|
hostConfig
|
|
|
|
nixindex
|
|
|
|
{programs.nix-index-database.comma.enable = true;}
|
|
|
|
hmModules.home-manager
|
|
|
|
{
|
|
|
|
home-manager = {
|
|
|
|
useGlobalPkgs = true;
|
|
|
|
useUserPackages = true;
|
|
|
|
backupFileExtension = "hm-backup";
|
|
|
|
extraSpecialArgs = {inherit inputs userSettings systemSettings;};
|
|
|
|
users.${userSettings.username} = homeConfig;
|
|
|
|
};
|
2025-04-19 10:06:25 -07:00
|
|
|
|
2025-04-21 10:25:32 -07:00
|
|
|
users.users.${userSettings.username}.home = homeDir;
|
|
|
|
}
|
2025-04-19 13:50:58 -07:00
|
|
|
|
2025-04-21 10:25:32 -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 = userSettings.username;
|
2025-04-18 16:46:54 -07:00
|
|
|
|
2025-04-21 10:25:32 -07:00
|
|
|
inherit inputs userSettings systemSettings;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]
|
|
|
|
++ extraModules;
|
|
|
|
}
|