File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,11 +19,15 @@ RUN nix-shell -p dos2unix --run 'find . -exec dos2unix {} +'
1919# itselves) using the default nix binary cache.
2020RUN nix-build
2121
22+ # Build required fonts and their cache.
23+ RUN mkdir -p /etc/fonts && nix-build nix/fontconfig.nix --out-link /etc/fonts/fonts.conf
24+ RUN mkdir -p /var/cache/fontconfig && nix-shell -p fontconfig --run fc-cache
25+
2226# Copy DiffDetective with all runtime dependencies (ignoring build-time
2327# dependencies) to a separate folder. Such a subset of the Nix store is called a
2428# closure and enables us to create a minimal Docker container.
2529RUN mkdir closure
26- RUN nix-store -qR result | xargs cp -Rt closure
30+ RUN nix-store -qR result /etc/fonts/fonts.conf | xargs cp -Rt closure
2731
2832# Start building the final container.
2933FROM scratch
@@ -40,5 +44,9 @@ COPY --from=builder /home/user/result /DiffDetective
4044# Copy the necessary data. Beware that this directory might have impure files.
4145COPY data /home/user/data
4246
47+ # Install fonts
48+ COPY --from=builder /etc/fonts/fonts.conf /etc/fonts/fonts.conf
49+ COPY --from=builder /var/cache/fontconfig /var/cache/fontconfig
50+
4351ENV DISPLAY=:0 HOME=/home/user
4452CMD ["/DiffDetective/bin/DiffDetective-Demo" ]
Original file line number Diff line number Diff line change 1616
1717 copyToRoot = pkgs . buildEnv {
1818 name = "DiffDetective-Demo-image-root" ;
19- paths = [ ( DiffDetectiveDemo . src + "/data" ) ] ;
19+ paths = [ ( DiffDetectiveDemo . src + "/data" ) ] ;
2020 extraPrefix = config . WorkingDir + "/data" ;
2121 } ;
2222
2323 runAsRoot = ''
24- mkdir -p /etc/fonts
25-
26- cat >/etc/fonts/fonts.conf <<"EOF"
27- <?xml version="1.0" encoding="UTF-8"?>
28- <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
29- <fontconfig>
30- <description>Configuration file</description>
31- <dir>${ pkgs . dejavu_fonts } /share/fonts</dir>
32- <cachedir>/var/cache/fontconfig</cachedir>
33- </fontconfig>
34- EOF
35-
24+ install -Dm644 ${ import ./fontconfig.nix { inherit sources system pkgs ; } } /etc/fonts/fonts.conf
3625 mkdir -p /var/cache/fontconfig
3726 ${ pkgs . fontconfig } /bin/fc-cache
3827 '' ;
Original file line number Diff line number Diff line change 1+ {
2+ sources ? import ./sources.nix ,
3+ system ? builtins . currentSystem ,
4+ pkgs ?
5+ import sources . nixpkgs {
6+ overlays = [ ] ;
7+ config = { } ;
8+ inherit system ;
9+ } ,
10+ } :
11+ pkgs . writeTextFile {
12+ name = "fonts.conf" ;
13+ text = ''
14+ <?xml version="1.0" encoding="UTF-8"?>
15+ <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
16+ <fontconfig>
17+ <description>Configuration file</description>
18+ <dir>${ pkgs . dejavu_fonts } /share/fonts</dir>
19+ <cachedir>/var/cache/fontconfig</cachedir>
20+ </fontconfig>
21+ '' ;
22+ }
You can’t perform that action at this time.
0 commit comments