Add image.enableRecommendedContents for /bin/sh and such
This commit is contained in:
parent
48d3d4b0d7
commit
e0e7531f7d
4 changed files with 57 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
config.services = {
|
||||
|
||||
webserver = {
|
||||
image.enableRecommendedContents = true;
|
||||
service.useHostStore = true;
|
||||
service.command = [ "sh" "-c" ''
|
||||
cd "$$WEB_ROOT"
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
./host-store.nix
|
||||
./context.nix
|
||||
./image.nix
|
||||
./image-recommended.nix
|
||||
./nixos.nix
|
||||
./nixos-init.nix
|
||||
../lib/assert.nix
|
||||
|
|
36
src/nix/modules/service/image-recommended.nix
Normal file
36
src/nix/modules/service/image-recommended.nix
Normal 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 {})
|
||||
];
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue