-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
98 lines (86 loc) · 2.6 KB
/
flake.nix
File metadata and controls
98 lines (86 loc) · 2.6 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
86
87
88
89
90
91
92
93
94
95
96
97
98
{
description = "Spring92 Challenge";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
nim-pkgs.url = "path:./nimpkgs";
};
outputs =
{
self,
nixpkgs,
flake-utils,
nim-pkgs,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
packages.default = pkgs.stdenv.mkDerivation {
pname = "spring92";
version = "0.0.1";
src = ./.;
buildInputs = with pkgs; [
nim-2_0
sqlite
openssl
imagemagick
];
nativeBuildInputs = with pkgs; [ makeWrapper ];
buildPhase = ''
mkdir -p $out/bin
# Setup nim package path
export HOME=$(pwd)
export PATH=$PATH:${pkgs.imagemagick}/bin
mkdir -p packages
for pkg in ${nim-pkgs.packages.${system}.default}/pkgs/*; do
# Copy package to local packages directory
if [ -d $pkg ]; then
cp -r $pkg packages/
else
cp $pkg packages/
fi
done
cd src && ${pkgs.nim-2_0}/bin/nim c -d:release -d:ssl --mm:none --path:../packages -o:$out/bin/app main.nim
'';
postInstall = ''
wrapProgram $out/bin/app \
--prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.imagemagick ]}
'';
};
devShells.default = pkgs.mkShell {
packages = with pkgs; [
nim-2_0
sqlite
openssl
imagemagick
];
shellHook = ''
# Set up nim package path from nimpkgs flake
if [ ! -d packages ] || [ -z "$(ls -A packages 2>/dev/null)" ]; then
echo "Setting up Nim packages..."
mkdir -p packages
for pkg in ${nim-pkgs.packages.${system}.default}/pkgs/*; do
if [ -d "$pkg" ]; then
cp -r "$pkg" packages/
else
cp "$pkg" packages/
fi
done
fi
dev-build() {
(cd src && nim c -d:ssl --mm:none --path:../packages -o:../app main.nim)
}
dev-run() {
dev-build && ./app
}
echo "Spring92 dev shell"
echo " dev-build — compile the app"
echo " dev-run — compile and run (static files served live from ./static/)"
'';
};
}
);
}