-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathflake.nix
88 lines (81 loc) · 2.5 KB
/
flake.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
{
description = "Nix flake that provides sfdx.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
};
sfPackage = let
name = "salesforce-cli";
version = "2.80.2";
src = pkgs.fetchFromGitHub {
owner = "salesforcecli";
repo = "cli";
rev = version;
hash = "sha256-E41UApJR6V3rkcMcr6DMCHcXLk3gFtk5EEjsTSwGnNc=";
};
lib = pkgs.lib;
offlineCache = pkgs.fetchYarnDeps {
yarnLock = "${src}/yarn.lock";
hash = "sha256-m4v8M5priqSDtek6il/55Rgi6pbEJXjUB3934YqzSvc=";
};
in
pkgs.stdenv.mkDerivation {
inherit version src;
pname = name;
nativeBuildInputs = with pkgs; [nodejs yarn prefetch-yarn-deps fixup-yarn-lock];
phases = ["unpackPhase" "configurePhase" "buildPhase" "installPhase" "distPhase"];
configurePhase = ''
export HOME=$PWD/yarn_home
yarn --offline config set yarn-offline-mirror ${offlineCache}
'';
buildPhase = ''
export HOME=$PWD/yarn_home
export SF_HIDE_RELEASE_NOTES=true
fixup-yarn-lock ./yarn.lock
chmod -R +rw $PWD/scripts
yarn --offline install --ignore-scripts
chmod -R +rw $PWD/node_modules
patchShebangs --build node_modules
yarn --offline --production=true run build
'';
installPhase = ''
mkdir $out
mv node_modules $out/
mv dist $out/
mkdir -p $out/bin
mv bin/run.js $out/bin/sf
# necessary for some runtime configuration
cp ./package.json $out
patchShebangs $out
'';
distPhase = ''
mkdir -p $out/tarballs/
yarn pack --offline --ignore-scripts --production=true --filename $out/tarballs/sf/.tgz
'';
};
in {
packages = rec {
sf = sfPackage;
default = sf;
};
apps = rec {
sf = flake-utils.lib.mkApp {
drv = self.packages.${system}.sf;
exePath = "/bin/sf";
};
default = sf;
};
formatter = pkgs.alejandra;
devShells.default =
pkgs.mkShell {buildInputs = with pkgs; [nodejs yarn];};
});
}