-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
115 lines (108 loc) · 3.05 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Deon Digital common Nix configuration
rec {
pins = {
nixpkgs = pins/nixpkgs-src.json;
haskell-nix = pins/haskell-nix-src.json;
};
pkgs = let
p = builtins.fromJSON (builtins.readFile pins.nixpkgs);
in
import (builtins.fetchGit {
name = "nixos-unstable-2019-09-11";
inherit (p) url rev;
}) {
overlays = [
(import overlays/jdk.nix { inherit pkgs; })
];
};
filters = import ./filters.nix { inherit pkgs; };
haskell-nix = let
p = builtins.fromJSON (builtins.readFile pins.haskell-nix);
in
import (builtins.fetchGit {
name = "haskell-nix-lib";
inherit (p) url rev;
}) {
inherit pkgs;
};
/*
* Download/build all NPM dependencies for a Node package ('npm install').
*/
buildNodeDependencies = { name, srcPath, gitRootDir }: let
call-node2nix = pkgs.stdenv.mkDerivation {
name = "${name}-node2nix";
src = filters.gitTrackedFiles {
inherit gitRootDir;
extraFilter = p: t: filters.isFileWithName p t [ "package.json" "package-lock.json" ];
} srcPath;
nativeBuildInputs = [ pkgs.nodePackages.node2nix ];
buildPhase = ''
node2nix --nodejs-10 --include-peer-dependencies --development -l package-lock.json
'';
installPhase = ''
mkdir $out
cp node-packages.nix node-env.nix default.nix package.json $out/
'';
};
node-packages = builtins.mapAttrs (name: spec:
spec.override {
dontNpmInstall = true;
}) (pkgs.callPackage call-node2nix { inherit pkgs; });
package-name = (builtins.fromJSON (builtins.readFile (srcPath + "/package.json"))).name;
in
pkgs.stdenv.mkDerivation {
name = "${name}-dependencies";
unpackPhase = "true";
dontBuild = true;
installPhase = ''
mkdir $out
ln -s ${node-packages.package}/lib/node_modules/${package-name}/node_modules $out/node_modules
'';
};
gradle2nix = pkgs.callPackage (
builtins.fetchGit {
name = "gradle2nix-src";
url = "https://github.com/bjornbugge/gradle2nix";
ref = "master";
rev = "3f7dbf68cdb0059ffe8aca338e66031d8f571ecb";
}
) {};
gradle2nix-shell = pkgs.stdenv.mkDerivation {
name = "gradle2nix-shell";
buildInputs =
[ pkgs.openjdk
gradle2nix
];
};
buildGradle =
{ name
, src
, nixFile
, credentials ? []
, ...
}@args:
let
builder = pkgs.callPackage nixFile {
fetchurl = let
netrc-file = pkgs.writeTextFile {
name = "netrc";
text = builtins.concatStringsSep "" (map (
m: ''
machine ${m.machine}
login ${m.login}
password ${m.password}
'') credentials);
};
in
args: pkgs.fetchurl (args // {
curlOpts =
if credentials != []
then "--netrc-file ${netrc-file}"
else "";
});
};
in builder (builtins.removeAttrs args
[ "credentials"
"nixFile"
]);
}