Skip to content

Commit 1911e31

Browse files
committed
chore: packaged with nix + test build action
1 parent 463d5d8 commit 1911e31

File tree

6 files changed

+5233
-3941
lines changed

6 files changed

+5233
-3941
lines changed

.github/workflows/test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Test CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test-flake:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Check out the repository
11+
uses: actions/checkout@v4
12+
13+
- name: Install Nix
14+
uses: DeterminateSystems/nix-installer-action@main
15+
16+
- name: Check up flake configuration
17+
run: nix flake check --all-systems --show-trace
18+
19+
- name: Build website
20+
run: nix build

default.nix

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
pkgs ? let
3+
lock = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.nixpkgs.locked;
4+
nixpkgs = fetchTarball {
5+
url = "https://github.com/nixos/nixpkgs/archive/${lock.rev}.tar.gz";
6+
sha256 = lock.narHash;
7+
};
8+
in
9+
import nixpkgs {overlays = [];},
10+
...
11+
}: let
12+
# Manifest data
13+
manifest = pkgs.lib.importJSON ./package.json;
14+
15+
# All source codes
16+
source = ./.;
17+
18+
# Executable
19+
exec = pkgs.writeShellScript "${manifest.name}-start.sh" ''
20+
# Change working directory to script
21+
cd "$(dirname "$0")/../lib"
22+
23+
${pkgs.lib.getExe pkgs.nodejs} ./server.js
24+
'';
25+
in
26+
pkgs.stdenv.mkDerivation {
27+
pname = manifest.name;
28+
version = manifest.version;
29+
30+
src = source;
31+
32+
nativeBuildInputs = [
33+
pkgs.nodejs_22
34+
pkgs.pnpm.configHook
35+
pkgs.typescript
36+
];
37+
38+
buildPhase = ''
39+
pnpm next build
40+
'';
41+
42+
installPhase = ''
43+
# Create output directory
44+
mkdir -p $out
45+
46+
# Copy standalone as library
47+
cp -R ./.next/standalone $out/lib
48+
49+
# Copy static contents
50+
if [ -d "./.next/static" ]; then
51+
cp -R ./.next/static $out/lib/.next/static
52+
fi
53+
54+
# Copy public assets
55+
if [ -d "./public" ]; then
56+
cp -R ./public $out/lib/public
57+
fi
58+
59+
# Create executable directory
60+
mkdir -p $out/bin
61+
62+
# Copy shell script to executables
63+
cp -r ${exec} $out/bin/${manifest.name}-start
64+
'';
65+
66+
pnpmDeps = pkgs.pnpm.fetchDeps {
67+
pname = manifest.name;
68+
version = manifest.version;
69+
src = source;
70+
hash = "sha256-tPQhuySUKG+IYFleagKSSTx0IDv9RGDFYHlaHoan32s=";
71+
};
72+
73+
meta = with pkgs.lib; {
74+
homepage = "https://devops-journey.uz";
75+
mainProgram = "${manifest.name}-start";
76+
description = "Website of DevOps Journey";
77+
license = with licenses; [cc-by-40];
78+
platforms = with platforms; linux ++ darwin;
79+
maintainers = with maintainers; [orzklv];
80+
};
81+
}

flake.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
# Development environment
3030
devShells.default = import ./shell.nix {inherit pkgs;};
31+
32+
packages.default = pkgs.callPackage ./default.nix {inherit pkgs;};
3133
}
3234
);
3335
}

next.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const withNextra = require('nextra')({
1111

1212
/** @type {import('next').NextConfig} */
1313
const config = {
14+
output: 'standalone',
1415
i18n: {
1516
locales: ['en-UZ'],
1617
defaultLocale: 'en-UZ',
@@ -46,4 +47,4 @@ if (process.env.NODE_ENV === 'development') {
4647
console.warn('Warning: @next/bundle-analyzer not found, skipping bundle analysis');
4748
module.exports = withNextra(config);
4849
}
49-
}
50+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "devops-journey",
3+
"description": "Website of Devops Journey!",
34
"version": "0.0.1",
45
"private": true,
56
"packageManager": "pnpm@8.15.4",
@@ -86,4 +87,4 @@
8687
"react-dom": "$react-dom"
8788
}
8889
}
89-
}
90+
}

0 commit comments

Comments
 (0)