File tree 2 files changed +91
-0
lines changed
2 files changed +91
-0
lines changed Original file line number Diff line number Diff line change 80
80
} ;
81
81
82
82
packages = {
83
+ selfoss-docker = pkgs . callPackage ./utils/docker.nix {
84
+ inherit ( nixpkgs . lib ) nixosSystem ;
85
+ targetPlatform = system ;
86
+ } ;
87
+
83
88
selfoss = pkgs . callPackage ./utils/selfoss.nix {
84
89
src = self . outPath ;
85
90
} ;
Original file line number Diff line number Diff line change
1
+ {
2
+ coreutils ,
3
+ bash ,
4
+ util-linux ,
5
+ dockerTools ,
6
+ unzip ,
7
+ lib ,
8
+ nixosSystem ,
9
+ targetPlatform ,
10
+ } :
11
+
12
+ # We are going to abuse the NixOS module for Apache to create configuration files.
13
+ # Then we will extract them from the instantiated system and add them to the image.
14
+
15
+ let
16
+ # Configuration for NixOS system.
17
+ systemConfiguration = { config , lib , pkgs , ... } : {
18
+ services . httpd = {
19
+ enable = true ;
20
+
21
+ # TODO: make this overridable? Or hidden?
22
+ adminAddr = "admin@selfoss" ;
23
+
24
+ # TODO: is root okay?
25
+ user = "root" ;
26
+ group = "root" ;
27
+
28
+ virtualHosts . "selfoss" = {
29
+ documentRoot = "/var/www" ;
30
+ locations . "/" = {
31
+ index = "index.php index.html" ;
32
+ } ;
33
+ } ;
34
+
35
+ phpPackage = pkgs . php ;
36
+ enablePHP = true ;
37
+ } ;
38
+ } ;
39
+
40
+ # Instantiate the NixOS configuration.
41
+ system = nixosSystem {
42
+ system = targetPlatform ;
43
+
44
+ modules = [
45
+ systemConfiguration
46
+ ] ;
47
+ } ;
48
+
49
+ apacheHttpd = system . config . services . httpd . package ;
50
+
51
+ in
52
+ dockerTools . buildLayeredImage {
53
+ name = "selfoss" ;
54
+ tag = "latest" ;
55
+
56
+ contents = [
57
+ apacheHttpd
58
+
59
+ # TODO: remove, only for debugging
60
+ coreutils
61
+ bash
62
+ util-linux
63
+ ] ;
64
+
65
+ # Cargo-culted from https://sandervanderburg.blogspot.com/2020/07/on-using-nix-and-docker-as-deployment.html
66
+ maxLayers = 100 ;
67
+
68
+ extraCommands = ''
69
+ mkdir -p var/log/httpd var/cache/httpd var/www etc/httpd
70
+ ${ selfoss } -d var/www
71
+ cp ${ system . config . environment . etc . "httpd/httpd.conf" . source } etc/httpd/httpd.conf
72
+ '' ;
73
+
74
+ config = {
75
+ Cmd = [ "${ apacheHttpd } /bin/apachectl" "-D" "FOREGROUND" ] ;
76
+ Expose = {
77
+ "80/tcp" = { } ;
78
+ } ;
79
+ } ;
80
+ }
81
+
82
+ # TODO: add devenv image
83
+ # NOTE: Can be run:
84
+ # nix build -L .#selfoss-docker
85
+ # docker load < result
86
+ # docker run -p 8080:80/tcp -it selfoss:latest
You can’t perform that action at this time.
0 commit comments