From 3d3da6a405ecafbf3f161c66fab8bb2dd7ed15be Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 1 Dec 2023 12:51:55 +0100 Subject: [PATCH] Allow creation of system-specific config files --- flake.nix | 4 +++- lib/system.nix | 30 ++++++++++++++++++------------ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/flake.nix b/flake.nix index 573676c..8108a0d 100644 --- a/flake.nix +++ b/flake.nix @@ -7,7 +7,9 @@ outputs = { self, nixpkgs }: let - system = import ./system.nix; + system = import ./lib/system.nix { + inherit nixpkgs; + }; in { nixosConfigurations.manu-surface = system "manu-surface" {}; }; diff --git a/lib/system.nix b/lib/system.nix index dd24c4f..ce886da 100644 --- a/lib/system.nix +++ b/lib/system.nix @@ -1,12 +1,18 @@ -name : - { dualBoot ? false } : - nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - { config, pkgs, ... }: { - imports = [ - ../hardware-configuration.nix - ]; - } - ]; - } +{ nixpkgs }: + name : + { dualBoot ? false } : + let + lib = nixpkgs.lib; + in + lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + (lib.optional (builtins.pathExists ../machines/${name}.nix) ../machines/${name}.nix) + ( + { config, pkgs, ... }: { + imports = [ + ../hardware-configuration.nix + ]; + }) + ]; + }