Browse Source

More examples and very bad tooling

Signed-off-by: Magic_RB <magic_rb@redalder.org>
master
Magic_RB 1 week ago
parent
commit
5f66546936
Signed by: Magic_RB GPG Key ID: 08D5287CC5DDCA0E
15 changed files with 179 additions and 36 deletions
  1. +11
    -0
      examples/all.sh
  2. +1
    -0
      examples/apache-runit/.gitignore
  3. +6
    -0
      examples/apache-runit/build.sh
  4. +94
    -0
      examples/apache-runit/default.nix
  5. +14
    -0
      examples/apache-runit/run.sh
  6. +1
    -0
      examples/apache/.gitignore
  7. +6
    -0
      examples/apache/build.sh
  8. +10
    -2
      examples/apache/default.nix
  9. +12
    -0
      examples/apache/run.sh
  10. +1
    -1
      examples/gitea/.gitignore
  11. +6
    -0
      examples/gitea/build.sh
  12. +2
    -2
      examples/gitea/default.nix
  13. +1
    -0
      examples/gitea/result
  14. +13
    -0
      examples/gitea/run.sh
  15. +1
    -31
      flake.nix

+ 11
- 0
examples/all.sh View File

@ -0,0 +1,11 @@
#! /usr/bin/env bash
cd "$(dirname "$(readlink -f "$0")")"
./gitea/build.sh
./apache-runit/build.sh
./apache/build.sh
./gitea/run.sh
./apache-runit/run.sh
./apache/run.sh

+ 1
- 0
examples/apache-runit/.gitignore View File

@ -0,0 +1 @@
nixng-apache-runit.tar.xz

+ 6
- 0
examples/apache-runit/build.sh View File

@ -0,0 +1,6 @@
#! /usr/bin/env bash
cd "$(dirname "$(readlink -f "$0")")"
nix build --out-link ./nixng-apache-runit.tar.xz ../..#apacheRunitSystem.ociImage
docker load < ./nixng-apache-runit.tar.xz

+ 94
- 0
examples/apache-runit/default.nix View File

@ -0,0 +1,94 @@
nglib:
(nglib "x86_64-linux").makeSystem {
system = "x86_64-linux";
name = "nixng-apache-runit";
config = ({ pkgs, config, ... }:
let
ids = config.ids;
in
{
config = {
runit = {
enable = true;
};
init.services.apache2 = {
shutdownOnExit = true;
ensureSomething.link."documentRoot" = {
src = "${pkgs.apacheHttpd}/htdocs";
dst = "/var/www";
};
};
users.users."www-data" = {
uid = ids.uids.www-data;
group = "www-data";
};
users.groups."www-data" = {
gid = ids.gids.www-data;
};
services.apache2 = {
enable = true;
configuration = [
{
LoadModule = [
[ "mpm_event_module" "modules/mod_mpm_event.so" ]
[ "log_config_module" "modules/mod_log_config.so" ]
[ "unixd_module" "modules/mod_unixd.so" ]
[ "authz_core_module" "modules/mod_authz_core.so" ]
[ "dir_module" "modules/mod_dir.so" ]
[ "mime_module" "modules/mod_mime.so" ]
];
}
{
Listen = "0.0.0.0:80";
ServerRoot = "/var/www";
ServerName = "blowhole";
PidFile = "/httpd.pid";
User = "www-data";
Group = "www-data";
DocumentRoot = "/var/www";
}
{
ErrorLog = "/dev/stderr";
TransferLog = "/dev/stdout";
LogLevel = "info";
}
{
AddType = [
[ "image/svg+xml" "svg" "svgz" ]
];
AddEncoding = [ "gzip" "svgz" ];
TypesConfig = "${pkgs.apacheHttpd}/conf/mime.types";
}
{
Directory = {
"/" = {
Require = [ "all" "denied" ];
Options = "SymlinksIfOwnerMatch";
};
};
VirtualHost = {
"*:80" = {
Directory = {
"/var/www" = {
Require = [ "all" "granted" ];
Options = [ "-Indexes" "+FollowSymlinks" ];
DirectoryIndex = "index.html";
};
};
};
};
}
];
};
};
});
}

+ 14
- 0
examples/apache-runit/run.sh View File

@ -0,0 +1,14 @@
#! /usr/bin/env bash
cd "$(dirname "$(readlink -f "$0")")"
echo "apache-runit is no going be run since runit still refuses to cooperate!"
#docker run -p 80:80 nixng-apache-runit &
#DOCKER=$!
#sleep 5
#xdg-open http://localhost/
#read
#kill -SIGTERM $DOCKER

+ 1
- 0
examples/apache/.gitignore View File

@ -0,0 +1 @@
nixng-apache.tar.xz

+ 6
- 0
examples/apache/build.sh View File

@ -0,0 +1,6 @@
#! /usr/bin/env bash
cd "$(dirname "$(readlink -f "$0")")"
nix build --out-link ./nixng-apache.tar.xz ../..#apacheSystem.ociImage
docker load < ./nixng-apache.tar.xz

+ 10
- 2
examples/apache/default.nix View File

@ -8,15 +8,19 @@ nglib:
in
{
config = {
runit = {
dumb-init = {
enable = true;
isContainer = true;
};
init.services.apache2 = {
shutdownOnExit = true;
ensureSomething.link."documentRoot" = {
src = "${pkgs.apacheHttpd}/htdocs";
dst = "/var/www";
};
log.syslog = {
type = "uds";
dst = "/dev/log";
};
};
users.users."www-data" = {
uid = ids.uids.www-data;
@ -25,6 +29,10 @@ nglib:
users.groups."www-data" = {
gid = ids.gids.www-data;
};
services.socklog = {
enable = true;
unix = "/dev/log";
};
services.apache2 = {
enable = true;
configuration = [


+ 12
- 0
examples/apache/run.sh View File

@ -0,0 +1,12 @@
#! /usr/bin/env bash
cd "$(dirname "$(readlink -f "$0")")"
docker run -p 80:80 nixng-apache &
DOCKER=$!
sleep 5
xdg-open http://localhost/
read
kill -SIGTERM $DOCKER

+ 1
- 1
examples/gitea/.gitignore View File

@ -3,4 +3,4 @@ jwt_secret
lfs_jwt_secret
secret_key
result
nixng-gitea.tar.xz

+ 6
- 0
examples/gitea/build.sh View File

@ -0,0 +1,6 @@
#! /usr/bin/env bash
cd "$(dirname "$(readlink -f "$0")")"
nix build --out-link ./nixng-gitea.tar.xz ../..#giteaSystem.ociImage
docker load < ./nixng-gitea.tar.xz

+ 2
- 2
examples/gitea/default.nix View File

@ -4,10 +4,10 @@ nglib:
name = "nixng-gitea";
config = ({ pkgs, ... }:
{
runit = {
dumb-init = {
enable = true;
isContainer = true;
};
init.services.gitea.shutdownOnExit = true;
services.gitea = {
enable = true;


+ 1
- 0
examples/gitea/result View File

@ -0,0 +1 @@
/nix/store/vmxl7izng52kgfg8sw5m8873a9rajdgg-nixng-gitea.tar.gz

+ 13
- 0
examples/gitea/run.sh View File

@ -0,0 +1,13 @@
#! /usr/bin/env bash
cd "$(dirname "$(readlink -f "$0")")"
docker run -v $PWD/internal_token:/internal_token -v $PWD/jwt_secret:/jwt_secret -v $PWD/lfs_jwt_secret:/lfs_jwt_secret -v $PWD/secret_key:/secret_key -p 3000:3000 nixng-gitea &
DOCKER=$!
sleep 5
xdg-open http://localhost:3000/
read
kill -SIGTERM $DOCKER

+ 1
- 31
flake.nix View File

@ -31,39 +31,9 @@
writeSubstitutedShellScript = callPackage ./lib/write-substituted-shell-script.nix {};
};
testSystem = (self.lib "x86_64-linux").makeSystem {
system = "x86_64-linux";
name = "nixng-system";
config = ({ pkgs, ... }: {
system.environment.files = [
{
source = "${pkgs.hello}/bin/hello";
destination = "/bin/hello";
}
];
runit.enable = true;
bootloader = {
enable = true;
initrdCompression = [ "gzip" ];
};
initramfs = {
enable = true;
config = {
# system.environment.files = [
# {
# source = "${pkgs.vim}/bin/vim";
# destination = "/bin/vim";
# }
# ];
initrd.enable = true;
};
};
});
};
giteaSystem = import ./examples/gitea self.lib;
apacheSystem = import ./examples/apache self.lib;
apacheRunitSystem = import ./examples/apache-runit self.lib;
overlay = import ./overlay;
packages = nixpkgs.lib.genAttrs


Loading…
Cancel
Save