Skip to content

Commit 3aaa676

Browse files
committed
create a nix flake for a simple web application
1 parent eaf8214 commit 3aaa676

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

flake.nix

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
description = "A simple web application";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils }:
10+
flake-utils.lib.eachDefaultSystem (system:
11+
let
12+
pkgs = nixpkgs.legacyPackages.${system};
13+
in
14+
{
15+
# Development environment
16+
devShells.default = pkgs.mkShell {
17+
buildInputs = with pkgs; [
18+
nodejs_20
19+
yarn
20+
];
21+
};
22+
23+
# Build the application
24+
packages.default = pkgs.stdenv.mkDerivation {
25+
name = "my-web-app";
26+
version = "1.0.0";
27+
src = ./src;
28+
29+
buildInputs = with pkgs; [
30+
nodejs_20
31+
yarn
32+
];
33+
34+
buildPhase = ''
35+
yarn install
36+
yarn build
37+
'';
38+
39+
installPhase = ''
40+
mkdir -p $out/bin
41+
cp -r dist/* $out/bin/
42+
'';
43+
};
44+
}
45+
);
46+
}

0 commit comments

Comments
 (0)