Skip to content

Commit e77adc2

Browse files
Initial commit
0 parents  commit e77adc2

File tree

12 files changed

+800
-0
lines changed

12 files changed

+800
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Dependabot-nix-update
2+
3+
on:
4+
push:
5+
branches:
6+
- "dependabot/npm_and_yarn/*"
7+
8+
jobs:
9+
update_npm_deps_hash:
10+
name: Update NPM dependencies hash
11+
runs-on: ubuntu-latest
12+
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
13+
permissions:
14+
contents: write
15+
steps:
16+
- name: Check Out Code
17+
uses: actions/checkout@v3
18+
19+
- name: Install Nix
20+
uses: DeterminateSystems/nix-installer-action@main
21+
22+
- name: Configure Cache
23+
uses: DeterminateSystems/magic-nix-cache-action@main
24+
25+
- name: Update Hash
26+
run: nix run .#update-nix
27+
28+
- name: Set up Git Config
29+
run: |
30+
# Configure author metadata to look like commits are made by Dependabot
31+
git config user.name "${GITHUB_ACTOR}"
32+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
33+
34+
- name: Commit changes
35+
run: |
36+
git add .
37+
# Skip committing or pushing if there are no changes
38+
if [[ $(git status -s) ]]; then
39+
git commit -m "build(deps): update npm dependencies hash [dependabot skip]" --no-verify
40+
git push
41+
echo "Pushed an update to npm dependencies hash"
42+
else
43+
echo "Npm dependencies hash was not changed"
44+
fi

.github/workflows/nix-build.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Nix build
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build-nix:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: cachix/install-nix-action@v25
14+
with:
15+
nix_path: nixpkgs=channel:nixos-unstable
16+
- uses: DeterminateSystems/magic-nix-cache-action@v2
17+
- run: nix build -L
18+
- run: nix develop --command echo OK

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.env
2+
result/
3+
dist
4+
node_modules
5+
.idea

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
description = "Spacebar server, written in Typescript.";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs =
10+
{
11+
self,
12+
nixpkgs,
13+
flake-utils,
14+
}:
15+
flake-utils.lib.eachSystem flake-utils.lib.allSystems (
16+
system:
17+
let
18+
pkgs = import nixpkgs {
19+
inherit system;
20+
};
21+
hashesFile = builtins.fromJSON (builtins.readFile ./hashes.json);
22+
lib = pkgs.lib;
23+
in
24+
{
25+
packages = {
26+
default = pkgs.buildNpmPackage {
27+
pname = "cisco-element-call-macro";
28+
name = "cisco-element-call-macro";
29+
30+
meta = with lib; {
31+
description = "A call to host element call on a Cisco WebEx device.";
32+
homepage = "https://github.com/spacebarchat/server";
33+
license = licenses.agpl3Plus;
34+
platforms = platforms.all;
35+
mainProgram = "exec";
36+
};
37+
38+
src = ./.;
39+
nativeBuildInputs = with pkgs; [ python3 ];
40+
npmDepsHash = hashesFile.npmDepsHash;
41+
makeCacheWritable = true;
42+
postPatch = ''
43+
substituteInPlace package.json --replace 'npx patch-package' '${pkgs.nodePackages.patch-package}/bin/patch-package'
44+
'';
45+
installPhase = ''
46+
runHook preInstall
47+
set -x
48+
#remove packages not needed for production, or at least try to...
49+
npm prune --omit dev --no-save $npmInstallFlags "''${npmInstallFlagsArray[@]}" $npmFlags "''${npmFlagsArray[@]}"
50+
find node_modules -maxdepth 1 -type d -empty -delete
51+
52+
mkdir -p $out
53+
cp -r assets dist node_modules package.json $out/
54+
makeWrapper ${pkgs.nodejs}/bin/node $out/bin/start-macro --prefix NODE_PATH : $out/node_modules --add-flags $out/$i
55+
56+
set +x
57+
runHook postInstall
58+
'';
59+
};
60+
61+
update-nix = pkgs.writeShellApplication {
62+
name = "update-nix";
63+
runtimeInputs = with pkgs; [
64+
prefetch-npm-deps
65+
nix
66+
jq
67+
];
68+
text = ''
69+
nix flake update --extra-experimental-features 'nix-command flakes'
70+
DEPS_HASH=$(prefetch-npm-deps package-lock.json)
71+
TMPFILE=$(mktemp)
72+
jq '.npmDepsHash = "'"$DEPS_HASH"'"' hashes.json > "$TMPFILE"
73+
mv -- "$TMPFILE" hashes.json
74+
'';
75+
};
76+
};
77+
78+
devShell = pkgs.mkShell {
79+
buildInputs = with pkgs; [
80+
nodejs
81+
nodePackages.typescript
82+
nodePackages.ts-node
83+
#nodePackages.patch-package
84+
nodePackages.prettier
85+
];
86+
};
87+
}
88+
);
89+
}

hashes.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"npmDepsHash": "sha256-AAngnY4gHjJUHyKE84muldzdLp6+0gM6TTq23wOsnNk="
3+
}

0 commit comments

Comments
 (0)