-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
85 lines (76 loc) · 2.58 KB
/
flake.nix
File metadata and controls
85 lines (76 loc) · 2.58 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
{
description = "Angular Flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/f597e7e9fcf37d8ed14a12835ede0a7d362314bd";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
pkgs = nixpkgs.legacyPackages.${system};
startScript = pkgs.writeShellScriptBin "start" ''
echo "Starting Angular dev environment"
npm run ng serve
'';
renderScript = pkgs.writeShellScriptBin "render" ''
npm run prerender
echo "Removing weird compilation artifacts..."
rm -r ./dist/atomicmayame/browser/202*
echo "Removed weird compilation artifacts..."
'';
renderTestScript = pkgs.writeShellScriptBin "render-test" ''
python3 -m http.server -d ./dist/atomicmayame/browser/ 4200
'';
deployScript = pkgs.writeShellScriptBin "deploy-pages" ''
echo "Checking ability to push to subtree"
set +e
git status | grep -E "modified|new"
if [ $? -ne 0 ]
then
set -e
echo ""
echo "Pushing to subtree"
# git subtree push --prefix dist/atomicmayame/browser/ origin gh-pages
else
set -e
echo ""
echo "Git tree is unclean, commit to main first"
fi
'';
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
nodejs
nodePackages.npm
python3
startScript
renderScript
renderTestScript
deployScript
];
shellHook = ''
echo "Installing dependencies..."
export PATH="$PWD/node_modules/.bin/:$PATH"
npm install --legacy-peer-deps
echo "Dependencies installed."
echo ""
echo "🚀 Angular (old) development environment!"
echo ""
echo "Available commands:"
echo " start - Start Angular dev instance (http://localhost:4200)"
echo " render - Run Angular pre-render"
echo " render-test - Test pre-rendered output (http://localhost:4200)"
echo " deploy-pages - Push to git subtree"
'';
};
in {
packages = {
default = startScript;
start = startScript;
render = renderScript;
render-test = renderTestScript;
deploy-pages = deployScript;
};
devShells.default = devShell;
}
);
}