Skip to content

Commit 08f5f6b

Browse files
committed
nix/default.nix: make globals into a parameter
1 parent a0bdd0c commit 08f5f6b

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

nix/default.nix

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{ system ? builtins.currentSystem
22
, crossSystem ? null
33
, config ? {}
4+
, deploymentGlobalsFn ? ## :: Pkgs -> GlobalsOverlayOverDefaults
5+
pkgs:
6+
if builtins.pathExists ../globals.nix
7+
then import ../globals.nix pkgs
8+
else builtins.trace "globals.nix missing, please add symlink" {}
49
}:
510
let
611
defaultSourcePaths = import ./sources.nix { inherit pkgs; };
@@ -90,20 +95,20 @@ let
9095
(import ./packages.nix)
9196
];
9297

93-
globals =
94-
if builtins.pathExists ../globals.nix
95-
then [(pkgs: _: with pkgs.lib; let
98+
buildGlobals =
99+
specificGlobalsFn:
100+
101+
[(pkgs: _: with pkgs.lib; let
96102
globalsDefault = import ../globals-defaults.nix pkgs;
97-
globalsSpecific = import ../globals.nix pkgs;
103+
globalsSpecific = specificGlobalsFn pkgs;
98104
in {
99105
globals = globalsDefault // (recursiveUpdate {
100106
inherit (globalsDefault) ec2 libvirtd environmentVariables;
101107
} globalsSpecific);
102-
})]
103-
else builtins.trace "globals.nix missing, please add symlink" [(pkgs: _: {
104-
globals = import ../globals-defaults.nix pkgs;
105108
})];
106109

110+
globals = buildGlobals deploymentGlobalsFn;
111+
107112
# merge upstream sources with our own:
108113
upstream-overlay = self: super: {
109114
inherit iohkNix;
@@ -126,8 +131,8 @@ let
126131
varnish-overlay
127132
];
128133

129-
pkgs = import nixpkgs {
130-
inherit system crossSystem config overlays;
131-
};
134+
pkgs = import nixpkgs {
135+
inherit system crossSystem config overlays;
136+
};
132137
in
133138
pkgs

0 commit comments

Comments
 (0)