-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathflake.nix
More file actions
149 lines (125 loc) · 4.17 KB
/
Copy pathflake.nix
File metadata and controls
149 lines (125 loc) · 4.17 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
{
description = "Knuts Theme für seine neue Webseite";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
server = {
url = "github:fscs/website-server";
inputs.nixpkgs.follows = "nixpkgs";
};
# theme dependencies
icons = {
url = "github:tabler/tabler-icons/v3.1.0";
flake = false;
};
bootstrap = {
url = "github:twbs/bootstrap/v5.3.3";
flake = false;
};
hugo-jslibs-dist = {
url = "github:gohugoio/hugo-mod-jslibs-dist";
flake = false;
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
icons,
server,
bootstrap,
hugo-jslibs-dist,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
rec {
packages = rec {
default = pkgs.stdenv.mkDerivation {
name = "fscs-website-theme";
src = self;
buildInputs = with pkgs; [
hugo
];
buildPhase = ''
mkdir -p assets/js/ assets/scss/ assets/@popperjs
ln -s ${hugo-jslibs-dist}/popperjs/package/dist/cjs/popper.js assets/@popperjs/core.js
ln -s ${icons}/icons assets/icons
ln -s ${bootstrap}/js assets/js/bootstrap
ln -s ${bootstrap}/scss assets/scss/bootstrap
'';
installPhase = ''
cp -r . $out
'';
};
demoSite = pkgs.stdenv.mkDerivation {
name = "demoSite";
src = ./demo;
buildInputs = with pkgs; [
hugo
pagefind
];
buildPhase = ''
mkdir themes
ln -s ${default} themes/knut
hugo -e nix -d public
hugo -e nix-hidden -d hidden
hugo -e nix-private -d protected
pagefind --site public
pagefind --site hidden
pagefind --site protected
'';
installPhase = ''
mkdir $out
cp -r public hidden protected $out
'';
};
runDemoSite = pkgs.writeScriptBin "run.sh" ''
#!/usr/bin/env bash
DATA_DIR="$PWD/data"
POSTGRES_DATA_DIR="$DATA_DIR/db/data"
SOCKET_DIR="$DATA_DIR/db/sockets"
SOCKET_URL="$(echo $SOCKET_DIR | sed 's/\//%2f/g')"
export DATABASE_URL="postgresql://$SOCKET_URL:5432/postgres"
mkdir -p "$POSTGRES_DATA_DIR" "$SOCKET_DIR"
echo Initializing the Database
${pkgs.postgresql_16}/bin/initdb -D "$POSTGRES_DATA_DIR" --locale=C.utf8
echo Starting the Database
${pkgs.postgresql_16}/bin/pg_ctl -D $POSTGRES_DATA_DIR -o "-k $SOCKET_DIR -h \"\"" start
trap "${pkgs.postgresql_16}/bin/pg_ctl -D $POSTGRES_DATA_DIR stop; exit" SIGINT
echo Starting the server
${server.packages.${system}.default}/bin/fscs-website-backend \
--host 0.0.0.0 \
--content-dir ${demoSite} \
--database-url $DATABASE_URL \
--oauth-source-name authentik \
--group FS_Rat_Informatik=Admin \
--auth-url https://auth.inphima.de/application/o/authorize/ \
--user-info https://auth.inphima.de/application/o/userinfo/ \
--token-url https://auth.inphima.de/application/o/token/ \
--calendar events=https://nextcloud.inphima.de/remote.php/dav/public-calendars/CAx5MEp7cGrQ6cEe?export \
--data-dir $DATA_DIR \
$@
echo Stopping the Database
${pkgs.pkgs.postgresql_16}/bin/pg_ctl -D "$DATA_DIR" stop
'';
};
apps.default = flake-utils.lib.mkApp {
drv = packages.runDemoSite;
exePath = "/bin/run.sh";
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
hugo
go
git
pagefind
simple-http-server
];
};
}
);
}