generated from stubbfel/nix-project-template
add bare metal runtime
This commit is contained in:
@@ -1,7 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "Alpine",
|
"name": "Alpine",
|
||||||
"image": "mcr.microsoft.com/devcontainers/base:alpine",
|
"image": "mcr.microsoft.com/devcontainers/base:alpine",
|
||||||
"postCreateCommand": "sudo apk add nix nix-dev nix-doc nix-manual nix-bash-completion && sudo chown -R vscode:vscode /nix && echo 'experimental-features = nix-command flakes' | sudo tee -a /etc/nix/nix.conf",
|
"features": {
|
||||||
|
"ghcr.io/devcontainers/features/nix:1": {
|
||||||
|
"extraNixConfig": "experimental-features = nix-command flakes",
|
||||||
|
"packages": "nixpkgs-fmt"
|
||||||
|
}
|
||||||
|
},
|
||||||
"runArgs": [
|
"runArgs": [
|
||||||
"--userns=keep-id"
|
"--userns=keep-id"
|
||||||
],
|
],
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
result
|
result
|
||||||
|
nohup.out
|
||||||
@@ -19,15 +19,15 @@
|
|||||||
{
|
{
|
||||||
packages = rec {
|
packages = rec {
|
||||||
playground = space.playground.package;
|
playground = space.playground.package;
|
||||||
default = playground;
|
default = pkgs.callPackage ./playground/runtime/engines/baremetal { services = [ space.playground.package ]; };
|
||||||
};
|
};
|
||||||
apps = rec {
|
apps = rec {
|
||||||
playground = flake-utils.lib.mkApp { drv = space.playground.package; exePath = ""; };
|
playground = flake-utils.lib.mkApp { drv = space.playground.package; exePath = ""; };
|
||||||
default = playground;
|
default = flake-utils.lib.mkApp { drv = self.packages.${system}.default; };
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
packages = [ pkgs.nixpkgs-fmt pkgs.nixpkgs-lint ];
|
packages = [ pkgs.nixpkgs-fmt ];
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
{ config ? import ../../config { } }:
|
{ config ? import ../../config { } }:
|
||||||
|
|
||||||
config.nixpkgs.writeScript "python-example-web-server" ''
|
config.nixpkgs.writeScript "python-example-web-server" ''
|
||||||
|
#! /usr/bin/env sh
|
||||||
|
|
||||||
${config.nixpkgs.python3}/bin/python -m http.server ${config.playground.port}
|
${config.nixpkgs.python3}/bin/python -m http.server ${config.playground.port}
|
||||||
''
|
''
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
{ config ? import ../../config { } }:
|
{ config ? import ../../config { } }:
|
||||||
|
|
||||||
config.nixpkgs.writeScript "rust-example-web-server" ''
|
config.nixpkgs.writeScript "rust-example-web-server" ''
|
||||||
|
#! /usr/bin/env sh
|
||||||
|
|
||||||
${config.nixpkgs.simple-http-server}/bin/simple-http-server --port ${config.playground.port}
|
${config.nixpkgs.simple-http-server}/bin/simple-http-server --port ${config.playground.port}
|
||||||
''
|
''
|
||||||
|
|
||||||
|
|||||||
28
playground/runtime/engines/baremetal/default.nix
Normal file
28
playground/runtime/engines/baremetal/default.nix
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{ pkgs, lib, services ? [ ] }:
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
backgroundServices = lib.forEach services (s: " exec nohup 2>&1 ${s} &");
|
||||||
|
launchBackgroundServices = lib.strings.concatLines backgroundServices;
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
pkgs.writeScriptBin "run" ''
|
||||||
|
#! /usr/bin/env sh
|
||||||
|
|
||||||
|
echo start services
|
||||||
|
|
||||||
|
${launchBackgroundServices}
|
||||||
|
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
read -r -p "to stop press any key:"
|
||||||
|
|
||||||
|
echo stop services
|
||||||
|
|
||||||
|
for job in `jobs -p`
|
||||||
|
do
|
||||||
|
pkill -P $job
|
||||||
|
kill $job
|
||||||
|
done
|
||||||
|
''
|
||||||
Reference in New Issue
Block a user