From 5364cba1cea3e749af369628ddc174262f51659c Mon Sep 17 00:00:00 2001 From: Jens Nolte <git@queezle.net> Date: Sun, 29 Nov 2020 21:47:29 +0100 Subject: [PATCH] Load extra layers from machines repo --- configuration.nix | 15 +++++++++++++-- machine-manager.nix | 6 +++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/configuration.nix b/configuration.nix index f977419..7537d37 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,5 +1,5 @@ # This is the entry point for my NixOS configuration. -{ name, path, channel, isIso }: +{ name, path, channel, isIso, extraLayersDir }: { lib, config, pkgs, ... }: let @@ -8,8 +8,19 @@ let layerPath = layerName: let filePath = ./layers + "/${layerName}.nix"; dirPath = ./layers + "/${layerName}"; + extraDirFilePath = extraLayersDir + "/${layerName}.nix"; + extraDirDirPath = extraLayersDir + "/${layerName}"; in - if builtins.pathExists filePath then filePath else dirPath; + if builtins.pathExists filePath + then filePath + else if builtins.pathExists dirPath + then dirPath + else if builtins.pathExists extraDirFilePath + then extraDirFilePath + else if builtins.pathExists extraDirDirPath + then extraDirDirPath + else builtins.throw "Cannot find layer `${layerName}`"; + layerImports = map layerPath dotfilesConfig.layers; in ({ diff --git a/machine-manager.nix b/machine-manager.nix index 5445314..a92a702 100644 --- a/machine-manager.nix +++ b/machine-manager.nix @@ -1,7 +1,7 @@ # entry point for machine configurations: # (import <repo-path> { machinesDir=./machines }).<netname>.configurations.<hostname> -{ machinesDir }: +{ machinesDir, extraLayersDir }: with builtins; let @@ -33,7 +33,7 @@ let withMachines = lambda: listToAttrs (map (m: {name = m; value = lambda { name = m; path = (machinesDir + "/${m}"); }; }) machineNames); mkMachineConfig = { name, path, isIso ? false }: ( import ./configuration.nix { - inherit name path isIso; + inherit name path isIso extraLayersDir; channel = machineChannels.${name}; } ); @@ -82,4 +82,4 @@ in nixosIsoDerivations = withMachines mkNixosIsoDerivation; machineTemplates = withMachines ({name, path}: import (path + /template.nix)); channels = machineChannels; -} \ No newline at end of file +} -- GitLab