From bdea1aa785f0c0b88eee606ba8d99f6930c57eb4 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 7 May 2024 21:59:58 +0200 Subject: [PATCH] Grant machine configs access to the `pkgs` attribute --- flake.nix | 69 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/flake.nix b/flake.nix index aade100..a018486 100644 --- a/flake.nix +++ b/flake.nix @@ -44,47 +44,48 @@ ) // { nixosConfigurations = let - default = { + default = { pkgs, ... }: { dualBoot = false; timeZone = null; keyMap = "us"; keyboardLayout = "us"; localeSettings = { }; }; - systems = [ - { - name = "nixos"; - } - ]; + systems = { + nixos.config = { ... }: { + }; + }; in - builtins.listToAttrs ( - builtins.map ( - { name, system ? "x86_64-linux", ... }@config: { - inherit name; + builtins.mapAttrs ( + name: { system ? "x86_64-linux", config }: nixpkgs.lib.nixosSystem { + inherit system; - value = nixpkgs.lib.nixosSystem { - inherit system; - - modules = [ - ({ ... }: { config._module.args = { machineConfig = default // config; }; }) - sops-nix.nixosModules.sops - ./lib/configuration.nix - - ( - let - configCandidate = ./lib/machines/${name}.nix; - - machineConfigPath = - if builtins.pathExists configCandidate - then - configCandidate - else - ./lib/hardware/base.nix; - in - machineConfigPath) - ]; - }; - }) - systems); + modules = [ + ( + { pkgs, ... }@args: { + config._module.args = { + machineConfig = (default args) // + (config args) // { + inherit name; + }; + }; + }) + sops-nix.nixosModules.sops + ./lib/configuration.nix + ( + let + configCandidate = ./lib/machines/${name}.nix; + + machineConfigPath = + if builtins.pathExists configCandidate + then + configCandidate + else + ./lib/hardware/base.nix; + in + machineConfigPath) + ]; + }) + systems; }); }