1- { pkgs , nosocket , ...} :
1+ { pkgs , nosocket , isDev , ...} :
22with pkgs ; rec {
33 package = mkYarnPackage {
44 name = "piston" ;
@@ -25,36 +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 {
29- name = " piston";
70+ name = if isDev then "piston" else "ghcr.io/engineer-man/ 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- ] ;
46-
47- extraCommands = ''
48- mkdir -p piston/{jobs,runtimes} etc/nix {,var/}tmp run/lock
49- echo -e "experimental-features = nix-command flakes" >> etc/nix/nix.conf
50- 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
51- for i in $(seq 1 32)
52- do
53- echo "nixbld$i:x:$(( $i + 30000 )):30000:Nix build user $i:/var/empty:/run/current-system/sw/bin/nologin" >> etc/passwd
54- done
73+ contents = if isDev then basePackages ++ devPackages else basePackages ;
5574
56- chmod 1777 {,var/}tmp/
57- '' ;
75+ extraCommands = if isDev then baseCommands + devCommands else baseCommands ;
5876
5977 config = {
6078 Cmd = [ "${ package } /bin/pistond" ] ;
@@ -86,4 +104,4 @@ with pkgs; rec {
86104 } ;
87105 } ;
88106 } ;
89- }
107+ }
0 commit comments