mirror of
https://github.com/engineer-man/piston.git
synced 2025-04-20 20:16:26 +02:00
Add dev/prod conditions in the nix files
This commit is contained in:
parent
b8e2af412e
commit
97fd8a16d4
3 changed files with 60 additions and 42 deletions
|
@ -1,4 +1,4 @@
|
|||
{pkgs, nosocket, ...}:
|
||||
{pkgs, nosocket, appEnv, ...}:
|
||||
with pkgs; rec {
|
||||
package = mkYarnPackage {
|
||||
name = "piston";
|
||||
|
@ -25,45 +25,54 @@ with pkgs; rec {
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
basePackages = with pkgs; [
|
||||
package
|
||||
nosocket
|
||||
bash
|
||||
nixFlakes
|
||||
coreutils-full
|
||||
cacert.out
|
||||
git
|
||||
gnutar
|
||||
gzip
|
||||
gnugrep
|
||||
rename
|
||||
util-linux
|
||||
];
|
||||
devPackages = with pkgs; [
|
||||
nodejs-16_x
|
||||
yarn
|
||||
python3
|
||||
gcc
|
||||
gnumake
|
||||
gnused
|
||||
];
|
||||
|
||||
baseCommands = ''
|
||||
mkdir -p piston/{jobs,runtimes} etc/nix {,var/}tmp run/lock
|
||||
echo -e "experimental-features = nix-command flakes" >> etc/nix/nix.conf
|
||||
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
|
||||
for i in $(seq 1 32)
|
||||
do
|
||||
echo "nixbld$i:x:$(( $i + 30000 )):30000:Nix build user $i:/var/empty:/run/current-system/sw/bin/nologin" >> etc/passwd
|
||||
done
|
||||
|
||||
chmod 1777 {,var/}tmp/
|
||||
'';
|
||||
devCommands = ''
|
||||
mkdir -p usr/bin
|
||||
ln -s /bin/env usr/bin/env
|
||||
chmod -R 1777 usr
|
||||
'';
|
||||
|
||||
container = pkgs.dockerTools.buildLayeredImageWithNixDb {
|
||||
name = "piston";
|
||||
tag = "base-latest";
|
||||
|
||||
contents = with pkgs; [
|
||||
package
|
||||
nosocket
|
||||
bash
|
||||
nixFlakes
|
||||
coreutils-full
|
||||
cacert.out
|
||||
git
|
||||
gnutar
|
||||
gzip
|
||||
gnugrep
|
||||
rename
|
||||
util-linux
|
||||
nodejs-16_x
|
||||
yarn
|
||||
python3
|
||||
gcc
|
||||
gnumake
|
||||
gnused
|
||||
];
|
||||
contents = if appEnv == "dev" then basePackages ++ devPackages else basePackages;
|
||||
|
||||
extraCommands = ''
|
||||
mkdir -p piston/{jobs,runtimes} etc/nix {,var/}tmp run/lock
|
||||
echo -e "experimental-features = nix-command flakes" >> etc/nix/nix.conf
|
||||
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
|
||||
for i in $(seq 1 32)
|
||||
do
|
||||
echo "nixbld$i:x:$(( $i + 30000 )):30000:Nix build user $i:/var/empty:/run/current-system/sw/bin/nologin" >> etc/passwd
|
||||
done
|
||||
|
||||
mkdir -p usr/bin
|
||||
ln -s /bin/env usr/bin/env
|
||||
chmod -R 1777 usr
|
||||
chmod 1777 {,var/}tmp/
|
||||
'';
|
||||
extraCommands = if appEnv == "dev" then baseCommands + devCommands else baseCommands;
|
||||
|
||||
config = {
|
||||
Cmd = ["${package}/bin/pistond"];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue