1
0
Fork 0
mirror of https://github.com/engineer-man/piston.git synced 2025-05-06 20:06:27 +02:00

Merge pull request from Brikaa/nix-development

Use nodemon and Docker volumes for development
This commit is contained in:
Thomas Hobson 2022-02-26 10:28:36 +13:00 committed by GitHub
commit 16e4f08dfa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 801 additions and 92 deletions

View file

@ -1,4 +1,4 @@
{pkgs, nosocket, ...}:
{pkgs, nosocket, isDev, ...}:
with pkgs; rec {
package = mkYarnPackage {
name = "piston";
@ -25,36 +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";
name = if isDev then "piston" else "ghcr.io/engineer-man/piston";
tag = "base-latest";
contents = with pkgs; [
package
nosocket
bash
nixFlakes
coreutils-full
cacert.out
git
gnutar
gzip
gnugrep
rename
util-linux
];
contents = if isDev 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
chmod 1777 {,var/}tmp/
'';
extraCommands = if isDev then baseCommands + devCommands else baseCommands;
config = {
Cmd = ["${package}/bin/pistond"];
@ -86,4 +104,4 @@ with pkgs; rec {
};
};
};
}
}

View file

@ -8,18 +8,20 @@
"express": "^4.17.1",
"express-ws": "^5.0.2",
"logplease": "^1.2.15",
"nocamel": "git://github.com/HexF/nocamel.git#patch-1",
"node-fetch": "^2.6.1",
"uuid": "^8.3.2",
"nocamel": "git://github.com/HexF/nocamel.git#patch-1",
"waitpid": "git://github.com/HexF/node-waitpid.git"
},
"license": "MIT",
"scripts": {
"dev": "nodemon .",
"lint": "prettier . --write",
"prepack": "yarn2nix > yarn.nix"
},
"devDependencies": {
"node2nix": "^1.6.0",
"nodemon": "^2.0.15",
"prettier": "2.2.1"
},
"bin": {

File diff suppressed because it is too large Load diff