feat(hive): Add function to instantiate patched nixpkgs in specialArgs

This commit is contained in:
sinavir 2024-04-03 19:21:40 +02:00
parent c2bafcbc65
commit 39d1d2999b

View file

@ -16,21 +16,23 @@ let
];
};
mkNixpkgs =
node:
patch.mkNixpkgsSrc rec {
mkPatchedNixpkgs =
version:
patch.mkNixpkgsSrc {
src = sources.${version};
version = "nixos-${nodes'.${node}.nixpkgs or (import ./meta/nixpkgs.nix)}";
inherit version;
};
mkNixpkgs' = node: import (mkNixpkgs node) { };
mkNixpkgs = version: import (mkPatchedNixpkgs version) { };
mkNixpkgsVersion = node: "nixos-${nodes'.${node}.nixpkgs or (import ./meta/nixpkgs.nix)}";
###
# Function to create arguments based on the node
#
mkArgs = node: rec {
lib = import sources.nix-lib {
inherit (mkNixpkgs' node) lib;
inherit (mkNixpkgs (mkNixpkgsVersion node)) lib;
keysRoot = ./keys;
};
@ -41,10 +43,11 @@ in
# nodes = builtins.attrNames metadata.nodes;
{
meta = {
nodeNixpkgs = lib.mapSingleFuse mkNixpkgs' nodes;
nodeNixpkgs = lib.mapSingleFuse (n: mkNixpkgs (mkNixpkgsVersion n)) nodes;
specialArgs = {
inherit sources;
inherit mkNixpkgs;
};
nodeSpecialArgs = lib.mapSingleFuse mkArgs nodes;
@ -63,7 +66,7 @@ in
inherit (meta.nodes.${name}) deployment;
# Set NIX_PATH to the patched version of nixpkgs
nix.nixPath = [ "nixpkgs=${mkNixpkgs name}" ];
nix.nixPath = [ "nixpkgs=${mkPatchedNixpkgs (mkNixpkgsVersion name)}" ];
nix.optimise.automatic = true;
# Allow unfree packages