allow extraFiles to contain paths
This commit is contained in:
parent
8d74fade2b
commit
1d5ebbce46
2 changed files with 15 additions and 7 deletions
|
@ -51,7 +51,9 @@ it accepts an attrset of:
|
||||||
- `extraArgs` - an attrset of additional arguments passed to all entries and templates
|
- `extraArgs` - an attrset of additional arguments passed to all entries and templates
|
||||||
- `entries` - a list of all entry files to be processed
|
- `entries` - a list of all entry files to be processed
|
||||||
- `templates` - a list of all template files to be applied
|
- `templates` - a list of all template files to be applied
|
||||||
- `extraFiles` - a list of attrsets of `source` and `destination`:
|
- `extraFiles` - a list of either:
|
||||||
|
- a path to the source file - will be copied to `$out` in the `installPhase`
|
||||||
|
- attrset of `source` and `destination`:
|
||||||
- `source` - a path, if relative `$PWD` is `$src` in the `installPhase`
|
- `source` - a path, if relative `$PWD` is `$src` in the `installPhase`
|
||||||
- `destination` - a path, never absolute, appended to `$out` in the `installPhase`
|
- `destination` - a path, never absolute, appended to `$out` in the `installPhase`
|
||||||
|
|
||||||
|
@ -86,6 +88,7 @@ mkNteDerivation {
|
||||||
];
|
];
|
||||||
|
|
||||||
extraFiles = [
|
extraFiles = [
|
||||||
|
./data.txt # equivalent to { source = ./data.txt; destination = "/"; }
|
||||||
{ source = ./image.png; destination = "/assets/"; }
|
{ source = ./image.png; destination = "/assets/"; }
|
||||||
{ source = ./image2.png; destination = "/assets/dupa.png"; }
|
{ source = ./image2.png; destination = "/assets/dupa.png"; }
|
||||||
{ source = "./data/*"; destination = "/assets/data/"; }
|
{ source = "./data/*"; destination = "/assets/data/"; }
|
||||||
|
|
13
nte-drv.nix
13
nte-drv.nix
|
@ -8,6 +8,7 @@ pkgs: engine: {
|
||||||
extraFiles ? []
|
extraFiles ? []
|
||||||
}: let
|
}: let
|
||||||
inherit (pkgs) lib;
|
inherit (pkgs) lib;
|
||||||
|
inherit (lib.attrsets) isAttrs;
|
||||||
inherit (lib.lists) forEach init;
|
inherit (lib.lists) forEach init;
|
||||||
inherit (lib.strings) concatStrings concatStringsSep match normalizePath optionalString splitString;
|
inherit (lib.strings) concatStrings concatStringsSep match normalizePath optionalString splitString;
|
||||||
in pkgs.stdenv.mkDerivation {
|
in pkgs.stdenv.mkDerivation {
|
||||||
|
@ -28,12 +29,16 @@ in pkgs.stdenv.mkDerivation {
|
||||||
|
|
||||||
${concatStrings (forEach extraFiles
|
${concatStrings (forEach extraFiles
|
||||||
(extraFile: let
|
(extraFile: let
|
||||||
isInSubdir = (match ".+/.*" extraFile.destination) != null;
|
fileAttrs = if isAttrs extraFile
|
||||||
outDir = normalizePath "$out/${concatStringsSep "/" (init (splitString "/" extraFile.destination))}";
|
then extraFile
|
||||||
outPath = normalizePath "$out/${extraFile.destination}";
|
else { source = extraFile; destination = "/"; };
|
||||||
|
|
||||||
|
isInSubdir = (match ".+/.*" fileAttrs.destination) != null;
|
||||||
|
outDir = normalizePath "$out/${concatStringsSep "/" (init (splitString "/" fileAttrs.destination))}";
|
||||||
|
outPath = normalizePath "$out/${fileAttrs.destination}";
|
||||||
in /*sh*/''
|
in /*sh*/''
|
||||||
${optionalString isInSubdir /*sh*/"mkdir -p ${outDir}"}
|
${optionalString isInSubdir /*sh*/"mkdir -p ${outDir}"}
|
||||||
cp -r ${extraFile.source} ${outPath}
|
cp -r ${fileAttrs.source} ${outPath}
|
||||||
''))
|
''))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue