-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathflake.nix
60 lines (53 loc) · 1.9 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
{
description = "A Nix-flake-based development environment for command-server";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs { inherit system; };
});
in
{
packages = forEachSupportedSystem
({ pkgs, ... }:
let
attrs = with builtins; fromJSON (readFile ./package.json);
name = attrs.name;
version = attrs.version;
in
{
default = pkgs.mkYarnPackage {
pname = "${name}-${version}";
src = ./.;
buildPhase = ''
# yarn tries to create a .yarn file in $HOME. There's probably a
# better way to fix this but setting HOME to cwd works for now.
export HOME="."
yarn --offline run compile
# non-existent symlink errors during packaging
rm ./deps/command-server/command-server
# need node_modules for vsce, so don't use symlink
rm ./deps/command-server/node_modules
cp -R ./node_modules ./deps/command-server
pushd ./deps/command-server
echo y | yarn --offline vsce package --yarn -o ./$pname.vsix
popd
'';
installPhase = ''
mkdir $out
mv ./deps/command-server/$pname.vsix $out;
'';
distPhase = "true";
};
});
devShells = forEachSupportedSystem
({ pkgs }: {
default = pkgs.mkShell
{
packages = with pkgs;
[ yarn typescript ];
};
});
};
}