1- { pkgs , nosocket , ...} :
1+ { pkgs , nosocket , appEnv , ...} :
22with pkgs ; rec {
33 package = mkYarnPackage {
44 name = "piston" ;
@@ -25,45 +25,54 @@ with pkgs; rec {
2525 } ;
2626 } ;
2727 } ;
28+
29+ basePackages = with pkgs ; [
30+ package
31+ nosocket
32+ bash
33+ nixFlakes
34+ coreutils-full
35+ cacert . out
36+ git
37+ gnutar
38+ gzip
39+ gnugrep
40+ rename
41+ util-linux
42+ ] ;
43+ devPackages = with pkgs ; [
44+ nodejs-16_x
45+ yarn
46+ python3
47+ gcc
48+ gnumake
49+ gnused
50+ ] ;
51+
52+ baseCommands = ''
53+ mkdir -p piston/{jobs,runtimes} etc/nix {,var/}tmp run/lock
54+ echo -e "experimental-features = nix-command flakes" >> etc/nix/nix.conf
55+ echo "nixbld:x:30000:nixbld1,nixbld10,nixbld11,nixbld12,nixbld13,nixbld14,nixbld15,nixbld16,nixbld17,nixbld18,nixbld19,nixbld2,nixbld20,nixbld21,nixbld22,nixbld23,nixbld24,nixbld25,nixbld26,nixbld27,nixbld28,nixbld29,nixbld3,nixbld30,nixbld31,nixbld32,nixbld4,nixbld5,nixbld6,nixbld7,nixbld8,nixbld9" >> etc/group
56+ for i in $(seq 1 32)
57+ do
58+ echo "nixbld$i:x:$(( $i + 30000 )):30000:Nix build user $i:/var/empty:/run/current-system/sw/bin/nologin" >> etc/passwd
59+ done
60+
61+ chmod 1777 {,var/}tmp/
62+ '' ;
63+ devCommands = ''
64+ mkdir -p usr/bin
65+ ln -s /bin/env usr/bin/env
66+ chmod -R 1777 usr
67+ '' ;
68+
2869 container = pkgs . dockerTools . buildLayeredImageWithNixDb {
2970 name = "piston" ;
3071 tag = "base-latest" ;
3172
32- contents = with pkgs ; [
33- package
34- nosocket
35- bash
36- nixFlakes
37- coreutils-full
38- cacert . out
39- git
40- gnutar
41- gzip
42- gnugrep
43- rename
44- util-linux
45- nodejs-16_x
46- yarn
47- python3
48- gcc
49- gnumake
50- gnused
51- ] ;
52-
53- extraCommands = ''
54- mkdir -p piston/{jobs,runtimes} etc/nix {,var/}tmp run/lock
55- echo -e "experimental-features = nix-command flakes" >> etc/nix/nix.conf
56- echo "nixbld:x:30000:nixbld1,nixbld10,nixbld11,nixbld12,nixbld13,nixbld14,nixbld15,nixbld16,nixbld17,nixbld18,nixbld19,nixbld2,nixbld20,nixbld21,nixbld22,nixbld23,nixbld24,nixbld25,nixbld26,nixbld27,nixbld28,nixbld29,nixbld3,nixbld30,nixbld31,nixbld32,nixbld4,nixbld5,nixbld6,nixbld7,nixbld8,nixbld9" >> etc/group
57- for i in $(seq 1 32)
58- do
59- echo "nixbld$i:x:$(( $i + 30000 )):30000:Nix build user $i:/var/empty:/run/current-system/sw/bin/nologin" >> etc/passwd
60- done
73+ contents = if appEnv == "dev" then basePackages ++ devPackages else basePackages ;
6174
62- mkdir -p usr/bin
63- ln -s /bin/env usr/bin/env
64- chmod -R 1777 usr
65- chmod 1777 {,var/}tmp/
66- '' ;
75+ extraCommands = if appEnv == "dev" then baseCommands + devCommands else baseCommands ;
6776
6877 config = {
6978 Cmd = [ "${ package } /bin/pistond" ] ;
0 commit comments