Add extraFiles option
This commit is contained in:
parent
6ba2d4800f
commit
2cd689783a
19
builder.nix
19
builder.nix
|
@ -20,8 +20,10 @@
|
|||
, packagesArch ? null
|
||||
# Extra OpenWRT packages (can be prefixed with "-")
|
||||
, packages ? []
|
||||
# Include extra files
|
||||
# Directory of extra files to include
|
||||
, files ? null
|
||||
# Attrset of files to include
|
||||
, extraFiles ? { }
|
||||
# Which services in /etc/init.d/ should be disabled
|
||||
, disabledServices ? []
|
||||
# Add to output name
|
||||
|
@ -95,10 +97,23 @@ stdenv.mkDerivation {
|
|||
# copy files to avoid making etc read-only
|
||||
"cp -r --no-preserve=all ${files} files"
|
||||
}
|
||||
${lib.strings.concatStringsSep "\n" (
|
||||
lib.attrsets.mapAttrsToList (
|
||||
path: { source, text }: ''
|
||||
mkdir -p $(dirname ./files/${path})
|
||||
${
|
||||
if text != null then ''
|
||||
cat << NIX_EOF > ./files/${path}
|
||||
${text}
|
||||
NIX_EOF
|
||||
'' else "cat < ${source} > ./files/${path}"}
|
||||
''
|
||||
) extraFiles)
|
||||
}
|
||||
make image SHELL=${runtimeShell} \
|
||||
PROFILE="${profile}" \
|
||||
PACKAGES="${lib.concatStringsSep " " packages}" \
|
||||
${lib.optionalString (files != null)
|
||||
${lib.optionalString (files != null || extraFiles != { })
|
||||
''FILES=./files''
|
||||
} \
|
||||
DISABLED_SERVICES="${lib.concatStringsSep " " disabledServices}" \
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
system.build.image = import ../../builder.nix {
|
||||
inherit pkgs;
|
||||
inherit (config.system) release target variant profile;
|
||||
inherit (config) files;
|
||||
inherit (config) files extraFiles;
|
||||
packages = config.packages.include
|
||||
++ map (x: "-${x}") config.packages.exclude;
|
||||
disabledServices = config.services.disabled;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{ lib, ... }:
|
||||
|
||||
{
|
||||
options.files = with lib;
|
||||
mkOption {
|
||||
options = with lib; {
|
||||
|
||||
files = mkOption {
|
||||
type = types.path;
|
||||
default = null;
|
||||
example = literalExample ''
|
||||
|
@ -18,4 +19,28 @@
|
|||
'';
|
||||
description = "Directory of files to included in images.";
|
||||
};
|
||||
|
||||
extraFiles = mkOption {
|
||||
default = { };
|
||||
description = ''
|
||||
Set of files to build into the image.
|
||||
'';
|
||||
type = with types;
|
||||
attrsOf (submodule {
|
||||
options = {
|
||||
source = mkOption {
|
||||
default = null;
|
||||
type = types.path;
|
||||
description = "Path of the source file.";
|
||||
};
|
||||
text = mkOption {
|
||||
default = null;
|
||||
type = types.nullOr types.lines;
|
||||
description = "Text of the file.";
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue