-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
83 lines (70 loc) · 2.75 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
packageJSON = builtins.fromJSON (builtins.readFile ./package.json);
version = packageJSON.dependencies."@shopify/cli";
cli = self.packages.${system}.cli-node;
in
{
checks = {
bundle = cli;
version = pkgs.testers.testVersion {
package = cli;
command = "shopify version";
};
themeCheckVersion = pkgs.testers.testVersion {
package = cli;
command = "HOME=/tmp shopify theme check --version";
version = "2.2.2";
};
};
packages = {
default = self.packages.${system}.cli-node;
cli-node = pkgs.callPackage ./cli-node.nix { version = version; cli-ruby = self.packages.${system}.cli-ruby; };
cli-ruby = pkgs.callPackage ./cli-ruby.nix { version = version; };
};
devShells.default = pkgs.mkShell {
buildInputs = [
(pkgs.writeShellScriptBin "update-hashes"
''
set -e
set -o pipefail
ROOT=$PWD
export PATH="${pkgs.jq}/bin:$PATH"
export PATH="${pkgs.nodejs}/bin:$PATH"
export PATH="${pkgs.bundix}/bin:$PATH"
export PATH="${pkgs.prefetch-npm-deps}/bin:$PATH"
export PATH="${pkgs.nix-prefetch-github}/bin:$PATH"
rm -f package-lock.json
npm update
npm install
rm -rf node_modules
prefetch-npm-deps ./package-lock.json | jq -R . > $ROOT/cli-node-deps.nix
nix-prefetch-github --rev ${version} Shopify cli | jq .hash > $ROOT/cli-ruby-src.nix
nix build .#cli-ruby
pushd $(nix eval .#cli-ruby.source | jq -r .)
bundix --gemset=$ROOT/cli-ruby-gemset.nix
popd
'')
(pkgs.writeShellScriptBin "do-release"
''
nix flake check
bare_version="$(nix run . -- version | ${pkgs.gnused}/bin/sed 's|Current Shopify CLI version: ||')"
version="v$bare_version"
${pkgs.gh}/bin/gh release create "$version" \
--draft \
--target "$(${pkgs.git}/bin/git rev-parse HEAD)" \
--title "$version" \
--notes "Updated to version [\`$version\`](https://github.com/Shopify/cli/releases/tag/$bare_version)"
'')
];
};
}
);
}