Add image.enableRecommendedContents for /bin/sh and such

This commit is contained in:
Robert Hensing 2021-05-25 19:28:08 +02:00
parent 48d3d4b0d7
commit e0e7531f7d
4 changed files with 57 additions and 0 deletions

View File

@ -197,6 +197,25 @@ Default::
----
No Example:: {blank}
== services.<name>.image.enableRecommendedContents
Add the `/bin/sh` and `/usr/bin/env` symlinks and some lightweight
files.
[discrete]
=== details
Type:: boolean
Default::
+
----
false
----
No Example:: {blank}
== services.<name>.image.name

View File

@ -4,6 +4,7 @@
config.services = {
webserver = {
image.enableRecommendedContents = true;
service.useHostStore = true;
service.command = [ "sh" "-c" ''
cd "$$WEB_ROOT"

View File

@ -5,6 +5,7 @@
./host-store.nix
./context.nix
./image.nix
./image-recommended.nix
./nixos.nix
./nixos-init.nix
../lib/assert.nix

View File

@ -0,0 +1,36 @@
{ config, lib, pkgs, ... }:
let
inherit (lib)
mkIf
mkOption
types
;
inherit (types)
bool
;
recommendedContents = { runCommand, bash, coreutils }:
runCommand "recommended-contents" {} ''
mkdir -p $out/bin $out/usr/bin $out/var/empty
ln -s ${bash}/bin/sh $out/bin/sh
ln -s ${coreutils}/bin/env $out/usr/bin/env
'';
in
{
options = {
image.enableRecommendedContents = mkOption {
type = bool;
default = false;
description = ''
Add the `/bin/sh` and `/usr/bin/env` symlinks and some lightweight
files.
'';
};
};
config = {
image.contents = mkIf config.image.enableRecommendedContents [
(pkgs.callPackage recommendedContents {})
];
};
}