summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2021-10-26 13:05:49 +0200
committertv <tv@krebsco.de>2021-10-26 13:52:25 +0200
commit6ef8900af4bca2901f00c718e3ac8ba457348451 (patch)
tree10040eadad68b8f8287473b1dd2c4ce67bed6853
parent53eda9cafee46a506053099c6ced393aa5675f86 (diff)
populate file: admit derivations
-rw-r--r--README.md2
-rw-r--r--ci.nix4
-rw-r--r--lib/types/populate.nix8
-rw-r--r--pkgs/populate/default.nix19
4 files changed, 25 insertions, 8 deletions
diff --git a/README.md b/README.md
index e9b15b3..d868768 100644
--- a/README.md
+++ b/README.md
@@ -217,6 +217,8 @@ Supported attributes:
whether a file has changed. This is useful when `path` points at files
with mangled timestamps, e.g. the Nix store.
+ The default value is `true` if `path` is a derivation, and `false` otherwise.
+
* `filters` (optional)
List of filters that should be passed to [`rsync`](https://rsync.samba.org/).
Filters are specified as attribute sets with the attributes `type` and
diff --git a/ci.nix b/ci.nix
index 258a4e6..c57f4d7 100644
--- a/ci.nix
+++ b/ci.nix
@@ -5,7 +5,7 @@ let
pkgs = import "${krops}/pkgs" {};
source = lib.evalSource [{
- nixos-config.file = toString (pkgs.writeText "nixos-config" ''
+ nixos-config.file = pkgs.writeText "nixos-config" ''
{ pkgs, ... }: {
fileSystems."/" = { device = "/dev/sda1"; };
@@ -13,7 +13,7 @@ let
services.openssh.enable = true;
environment.systemPackages = [ pkgs.git ];
}
- '');
+ '';
nixpkgs.symlink = toString <nixpkgs>;
}];
in {
diff --git a/lib/types/populate.nix b/lib/types/populate.nix
index 894b8cc..18b5cd8 100644
--- a/lib/types/populate.nix
+++ b/lib/types/populate.nix
@@ -21,11 +21,15 @@
};
file = lib.mkOption {
apply = x:
- if lib.types.absolute-pathname.check x
+ if lib.types.absolute-pathname.check x || lib.types.package.check x
then { path = x; }
else x;
default = null;
- type = lib.types.nullOr (lib.types.either lib.types.absolute-pathname source-types.file);
+ type = lib.types.nullOr (lib.types.oneOf [
+ lib.types.absolute-pathname
+ lib.types.package
+ source-types.file
+ ]);
};
git = lib.mkOption {
default = null;
diff --git a/pkgs/populate/default.nix b/pkgs/populate/default.nix
index d86d949..3be1932 100644
--- a/pkgs/populate/default.nix
+++ b/pkgs/populate/default.nix
@@ -45,10 +45,21 @@ let
'';
pop.file = target: source: let
- config = rsyncDefaultConfig // sourceConfig;
- sourceConfig = getAttrs (attrNames rsyncDefaultConfig) source;
+ config = rsyncDefaultConfig // derivedConfig // sourceConfig;
+ derivedConfig = {
+ useChecksum =
+ if isDerivation source.path
+ then true
+ else rsyncDefaultConfig.useChecksum;
+ };
+ sourceConfig =
+ filterAttrs (name: _: elem name (attrNames rsyncDefaultConfig)) source;
+ sourcePath =
+ if isDerivation source.path
+ then quote (toString source.path)
+ else quote source.path;
in
- rsync' target config (quote source.path);
+ rsync' target config sourcePath;
pop.git = target: source: runShell target /* sh */ ''
set -efu
@@ -198,7 +209,7 @@ let
useChecksum = false;
exclude = [];
filters = [];
- deleteExcluded = true
+ deleteExcluded = true;
};
runShell = target: command: