nixos-option: rewrite as a nix script, 2nd try (#369151)
[NixPkgs.git] / pkgs / by-name / aw / aws-azure-login / package.nix
blob86ff83af091a788bea24562e6e928a413a32a612
2   lib,
3   callPackage,
4   stdenv,
5   chromium,
6   fetchFromGitHub,
7   fetchYarnDeps,
8   makeWrapper,
9   nodejs,
10   fixup-yarn-lock,
11   yarn,
13 stdenv.mkDerivation (finalAttrs: {
14   pname = "aws-azure-login";
15   version = "3.6.1";
17   src = fetchFromGitHub {
18     owner = "aws-azure-login";
19     repo = "aws-azure-login";
20     rev = "v${finalAttrs.version}";
21     hash = "sha256-PvPnqaKD98h3dCjEOwF+Uc86xCJzn2b9XNHHn13h/2Y=";
22   };
24   offlineCache = fetchYarnDeps {
25     yarnLock = "${finalAttrs.src}/yarn.lock";
26     hash = "sha256-SXQPRzF6b1FJl5HkyXNm3kGoNSDXux+0RYXBX93mOts=";
27   };
29   nativeBuildInputs = [
30     makeWrapper
31     nodejs
32     fixup-yarn-lock
33     yarn
34   ];
36   configurePhase = ''
37     runHook preConfigure
39     export HOME=$(mktemp -d)
40     yarn config --offline set yarn-offline-mirror "$offlineCache"
41     fixup-yarn-lock yarn.lock
42     yarn --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive install
43     patchShebangs node_modules
45     runHook postConfigure
46   '';
48   buildPhase = ''
49     runHook preBuild
51     yarn --offline build
53     runHook postBuild
54   '';
56   installPhase = ''
57     runHook preInstall
59     yarn --offline --production install
61     mkdir -p "$out/lib/node_modules/aws-azure-login"
62     cp -r . "$out/lib/node_modules/aws-azure-login"
64     makeWrapper "${nodejs}/bin/node" "$out/bin/aws-azure-login" \
65       --add-flags "$out/lib/node_modules/aws-azure-login/lib/index.js" \
66       --set PUPPETEER_EXECUTABLE_PATH "${lib.getExe chromium}"
68     runHook postInstall
69   '';
71   passthru.tests.aws-azure-login = callPackage ./tests.nix {
72     package = finalAttrs.finalPackage;
73   };
75   meta = {
76     description = "Use Azure AD SSO to log into the AWS via CLI";
77     homepage = "https://github.com/aws-azure-login/aws-azure-login";
78     license = lib.licenses.mit;
79     mainProgram = "aws-azure-login";
80     maintainers = with lib.maintainers; [ l0b0 ];
81     platforms = lib.platforms.all;
82   };