refactor mkSystem

This commit is contained in:
Natalie 2025-04-19 10:06:25 -07:00
parent dce01a9832
commit e994781056
No known key found for this signature in database
GPG key ID: 61F4EAEB0C9C3D5F
4 changed files with 28 additions and 16 deletions

View file

@ -11,7 +11,7 @@
../../modules/shared/nix.nix ../../modules/shared/nix.nix
../../modules/nixos/nvidia.nix ../../modules/nixos/nvidia.nix
../../modules/nixos/boot.ni ../../modules/nixos/boot.nix
]; ];
services.avahi = { services.avahi = {
enable = true; enable = true;

View file

@ -5,12 +5,9 @@
... ...
}: { }: {
imports = [ imports = [
../../modules/shared/vars.nix
../../modules/shared/nix.nix ../../modules/shared/nix.nix
../../modules/shared/extras.nix ../../modules/shared/extras.nix
../../modules/shared/modules.nix
../../modules/shared/home-manager.nix
./modules/icons.nix ./modules/icons.nix
]; ];

View file

@ -10,24 +10,31 @@
darwin ? false, darwin ? false,
extraModules ? [], extraModules ? [],
}: let }: let
# True if this is a WSL system. # mkIfElse = p: yes: no:
# True if Linux, which is a heuristic for not being Darwin. # nixpkgs.lib.mkMerge [
mkIfElse = p: yes: no: # (nixpkgs.lib.mkIf p yes)
nixpkgs.lib.mkMerge [ # (nixpkgs.lib.mkIf (!p) no)
(nixpkgs.lib.mkIf p yes) # ];
(nixpkgs.lib.mkIf (!p) no) nixindex =
]; if darwin
then inputs.nix-index-database.darwinModules.nix-index
else inputs.nix-index-database.nixosModules.nix-index;
nixindex = mkIfElse darwin inputs.nix-index-database.darwinModules.nix-index inputs.nix-index-database.nixosModules.nix-index; host =
if darwin
host = mkIfElse darwin "laptop" "desktop"; then "laptop"
else "desktop";
# The config files for this system. # The config files for this system.
hostConfig = ../hosts/${host}/configuration.nix; hostConfig = ../hosts/${host}/configuration.nix;
# NixOS vs nix-darwin functions # NixOS vs nix-darwin functions
systemFunc = mkIfElse darwin inputs.darwin.lib.darwinSystem nixpkgs.lib.nixosSystem; systemFunc =
if darwin
then inputs.darwin.lib.darwinSystem
else nixpkgs.lib.nixosSystem;
home-manager = home-manager =
if darwin if darwin
then inputs.home-manager.darwinModules then inputs.home-manager.darwinModules
@ -42,7 +49,13 @@ in
# to go through and apply our system type. We do this first so # to go through and apply our system type. We do this first so
# the overlays are available globally. # the overlays are available globally.
{nixpkgs.overlays = overlays;} {nixpkgs.overlays = overlays;}
{inputs.programs.nix-index-database.comma.enable = true;}
# Enable caching for nix-index so we dont have to rebuild it
#shared modules
../modules/shared/nix.nix
../modules/shared/extras.nix
hostConfig hostConfig
nixindex nixindex
home-manager.home-manager home-manager.home-manager

View file

@ -6,4 +6,6 @@
}: { }: {
networking = { networking = {
}; };
inputs.programs.nix-index-database.comma.enable = true;
} }