Skip to content

Commit a47a0da

Browse files
committed
setup ci
1 parent ce40621 commit a47a0da

File tree

7 files changed

+6846
-7
lines changed

7 files changed

+6846
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,5 @@ dist
131131

132132
# nix stuff
133133
.pre-commit-config.yaml
134+
result
135+
result-*

flake.lock

Lines changed: 20 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,91 @@
55
flake-parts.url = "github:hercules-ci/flake-parts";
66
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
77
pre-commit-hooks-nix.url = "github:cachix/pre-commit-hooks.nix";
8+
gitignore = {
9+
url = "github:hercules-ci/gitignore.nix";
10+
inputs.nixpkgs.follows = "nixpkgs";
11+
};
812
};
913

1014
outputs = inputs @ {
1115
flake-parts,
1216
pre-commit-hooks-nix,
17+
gitignore,
1318
...
1419
}:
1520
flake-parts.lib.mkFlake {inherit inputs;} {
1621
imports = [
1722
inputs.pre-commit-hooks-nix.flakeModule
1823
];
19-
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
24+
systems = [
25+
"x86_64-linux"
26+
"aarch64-linux"
27+
"aarch64-darwin"
28+
"x86_64-darwin"
29+
];
2030
perSystem = {
2131
config,
2232
self',
2333
inputs',
2434
pkgs,
2535
system,
2636
...
27-
}: {
37+
}: let
38+
nodeMajorVersion = 18;
39+
runNode2Nix = pkgs.writeShellScriptBin "runNode2Nix" ''
40+
${pkgs.node2nix}/bin/node2nix \
41+
-${builtins.toString nodeMajorVersion} \
42+
--input package.json \
43+
--lock package-lock.json \
44+
--node-env ./nix/node-env.nix \
45+
--composition ./nix/default.nix \
46+
--output ./nix/node-package.nix \
47+
--development \
48+
--include-peer-dependencies
49+
'';
50+
nodejs = pkgs."nodejs-${builtins.toString nodeMajorVersion}_x";
51+
node2nixOutput = import ./nix {inherit pkgs nodejs system;};
52+
nodeDependencies = node2nixOutput.nodeDependencies;
53+
minAuth = pkgs.stdenv.mkDerivation {
54+
name = "MinAuth";
55+
version = "0.1.0";
56+
src = gitignore.lib.gitignoreSource ./.;
57+
buildInputs = [nodejs];
58+
buildPhase = ''
59+
runHook preBuild
60+
ln -sf ${nodeDependencies}/lib/node_modules ./node_modules
61+
export PATH="${nodeDependencies}/bin:$PATH"
62+
npm run build
63+
runHook postBuild
64+
'';
65+
installPhase = ''
66+
runHook preInstall
67+
mkdir -p $out
68+
cp package.json $out/package.json
69+
cp -r dist $out/dist
70+
ln -sf ${nodeDependencies}/lib/node_modules $out/node_modules
71+
runHook postInstall
72+
'';
73+
};
74+
in {
2875
pre-commit.settings.hooks = {
2976
eslint.enable = true;
3077
prettier.enable = true;
3178
alejandra.enable = true;
3279
};
3380
devShells.default = pkgs.mkShell {
34-
packages = with pkgs; [
81+
packages = [
3582
nodejs
36-
nodePackages.typescript
37-
nodePackages.typescript-language-server
3883
config.pre-commit.settings.package
84+
runNode2Nix
3985
];
4086
shellHook = config.pre-commit.installationScript;
4187
};
88+
checks.default = self'.checks.pre-commit;
89+
packages = {
90+
inherit minAuth;
91+
default = minAuth;
92+
};
4293
};
4394
flake = {
4495
};

nix/default.nix

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This file has been generated by node2nix 1.11.1. Do not edit!
2+
{
3+
pkgs ?
4+
import <nixpkgs> {
5+
inherit system;
6+
},
7+
system ? builtins.currentSystem,
8+
nodejs ? pkgs."nodejs_18",
9+
}: let
10+
nodeEnv = import ./node-env.nix {
11+
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
12+
inherit pkgs nodejs;
13+
libtool =
14+
if pkgs.stdenv.isDarwin
15+
then pkgs.darwin.cctools
16+
else null;
17+
};
18+
in
19+
import ./node-package.nix {
20+
inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
21+
inherit nodeEnv;
22+
}

0 commit comments

Comments
 (0)