1
0
Fork 0
mirror of https://cgit.krebsco.de/krops synced 2024-11-22 19:19:46 +01:00

populate file: admit derivations

This commit is contained in:
tv 2021-10-26 13:05:49 +02:00
parent 53eda9cafe
commit 6ef8900af4
4 changed files with 25 additions and 8 deletions

View file

@ -217,6 +217,8 @@ Supported attributes:
whether a file has changed. This is useful when `path` points at files whether a file has changed. This is useful when `path` points at files
with mangled timestamps, e.g. the Nix store. with mangled timestamps, e.g. the Nix store.
The default value is `true` if `path` is a derivation, and `false` otherwise.
* `filters` (optional) * `filters` (optional)
List of filters that should be passed to [`rsync`](https://rsync.samba.org/). List of filters that should be passed to [`rsync`](https://rsync.samba.org/).
Filters are specified as attribute sets with the attributes `type` and Filters are specified as attribute sets with the attributes `type` and

4
ci.nix
View file

@ -5,7 +5,7 @@ let
pkgs = import "${krops}/pkgs" {}; pkgs = import "${krops}/pkgs" {};
source = lib.evalSource [{ source = lib.evalSource [{
nixos-config.file = toString (pkgs.writeText "nixos-config" '' nixos-config.file = pkgs.writeText "nixos-config" ''
{ pkgs, ... }: { { pkgs, ... }: {
fileSystems."/" = { device = "/dev/sda1"; }; fileSystems."/" = { device = "/dev/sda1"; };
@ -13,7 +13,7 @@ let
services.openssh.enable = true; services.openssh.enable = true;
environment.systemPackages = [ pkgs.git ]; environment.systemPackages = [ pkgs.git ];
} }
''); '';
nixpkgs.symlink = toString <nixpkgs>; nixpkgs.symlink = toString <nixpkgs>;
}]; }];
in { in {

View file

@ -21,11 +21,15 @@
}; };
file = lib.mkOption { file = lib.mkOption {
apply = x: apply = x:
if lib.types.absolute-pathname.check x if lib.types.absolute-pathname.check x || lib.types.package.check x
then { path = x; } then { path = x; }
else x; else x;
default = null; 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 { git = lib.mkOption {
default = null; default = null;

View file

@ -45,10 +45,21 @@ let
''; '';
pop.file = target: source: let pop.file = target: source: let
config = rsyncDefaultConfig // sourceConfig; config = rsyncDefaultConfig // derivedConfig // sourceConfig;
sourceConfig = getAttrs (attrNames rsyncDefaultConfig) source; 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 in
rsync' target config (quote source.path); rsync' target config sourcePath;
pop.git = target: source: runShell target /* sh */ '' pop.git = target: source: runShell target /* sh */ ''
set -efu set -efu
@ -198,7 +209,7 @@ let
useChecksum = false; useChecksum = false;
exclude = []; exclude = [];
filters = []; filters = [];
deleteExcluded = true deleteExcluded = true;
}; };
runShell = target: command: runShell = target: command: