forked from wolfadex/elm-open-api-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
150 lines (125 loc) · 3.76 KB
/
Copy pathflake.nix
File metadata and controls
150 lines (125 loc) · 3.76 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
{
description = "Elm OpenAPI CLI";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/release-25.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib;
packageJson = builtins.fromJSON (builtins.readFile ./package.json);
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./CHANGELOG.md
./LICENSE
./README.md
./bun.lock
./cli
./codegen
./docs
./elm.json
./helpers
./openapitools.json
./package.json
./review
./src
./tests
];
};
registryDat = ./cli/registry.dat;
securityShim = pkgs.writeShellScriptBin "security" ''
exec /usr/bin/security "$@"
'';
bunDeps = pkgs.stdenvNoCC.mkDerivation {
pname = "${packageJson.name}-bun-deps";
version = packageJson.version;
inherit src;
nativeBuildInputs = [
pkgs.bun
pkgs.nodejs_20
pkgs.writableTmpDirAsHomeHook
];
dontConfigure = true;
buildPhase = ''
runHook preBuild
export BUN_INSTALL_CACHE_DIR=$(mktemp -d)
bun install --frozen-lockfile --no-progress
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out
cp -R node_modules $out/
runHook postInstall
'';
dontFixup = true;
outputHash = "sha256-fl59fFEyLAdAZynW3o0YR+YexLPMn7mYKw8EM/LB0IE=";
outputHashAlgo = "sha256";
outputHashMode = "recursive";
};
elmOpenApi = pkgs.stdenv.mkDerivation {
pname = packageJson.name;
version = packageJson.version;
inherit src;
__impureHostDeps = lib.optionals pkgs.stdenv.hostPlatform.isDarwin [
"/bin/sh"
"/usr/bin/security"
];
nativeBuildInputs = [
pkgs.bash
pkgs.bun
pkgs.curl
pkgs.elmPackages.elm
pkgs.git
pkgs.nodejs_20
pkgs.writableTmpDirAsHomeHook
securityShim
];
configurePhase =
(pkgs.elmPackages.fetchElmDeps {
elmPackages = import ./cli/elm-srcs.nix;
elmVersion = pkgs.elmPackages.elm.version;
inherit registryDat;
})
+ ''
cp -R ${bunDeps}/node_modules .
chmod -R +w node_modules
ln -sf ${lib.getExe pkgs.elmPackages.elm} node_modules/.bin/elm
'';
buildPhase = ''
runHook preBuild
export BUN_INSTALL_CACHE_DIR=$(mktemp -d)
bun run build
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -Dm755 dist/elm-open-api.js "$out/bin/elm-open-api"
runHook postInstall
'';
meta = {
description = packageJson.description;
homepage = "https://github.com/wolfadex/elm-open-api-cli";
license = lib.licenses.mit;
mainProgram = "elm-open-api";
platforms = lib.platforms.unix;
};
};
in
{
packages.default = elmOpenApi;
packages.elm-open-api = elmOpenApi;
apps.default = flake-utils.lib.mkApp { drv = elmOpenApi; };
devShells.default = import ./shell.nix { inherit pkgs; };
}
);
}