-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdefault.nix
43 lines (42 loc) · 1.59 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# WARNING: It's best that you set impureNix to "true" when importing this repository from somewhere else
# the reason for this is that fetchGit tries to fetch repositories with all their commit history, in the case
# nixpkgs, this is about 1,3GB as of writing.
# you can also provide your own packages with the "pkgs" parameter
{ includeOverlays ? false, impureNix ? false, overlays ? [ ], ... }@args:
let
inherit (builtins) attrValues sort;
ensureModules = import ./lib/importFromSubmodule.nix { root = ./.; };
# impure Nix is faster than pinned nix
nixpkgsSrc = if impureNix then <nixpkgs> else (ensureModules ./dep/nixpkgs/default.nix);
pkgs = args.pkgs or (import nixpkgsSrc { });
localOverlays = import ./overlays;
basePackageSet = self: {
callPackage = pkgs.lib.callPackageWith self;
callNixPackage = pkgs.callPackage;
lib = {
inherit ensureModules;
srcs = import ./dep { inherit ensureModules; };
overlays = pkgs.lib.mapAttrs (k: v: v.function) localOverlays;
pkgsrc = {
outPath = ./.;
__functor = self: import self.outPath;
};
};
# bare necessities
pkgs = self;
inherit (pkgs)
nix
runCommand
;
};
# Adapted from https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/stage.nix
packages =
let
overlayDataSet = attrValues localOverlays;
sorted = sort (a: b: a.priority < b.priority) overlayDataSet;
toFix = with pkgs.lib; foldl' (flip extends) basePackageSet
((if includeOverlays then (map (x: x.function) sorted) else []) ++ overlays);
in
pkgs.lib.fix toFix;
in
packages