feat(nix-reuse): Add installPath option
This allows installing the REUSE.toml file in a distinct directory from the git toplevel
This commit is contained in:
parent
2f45f2e7e6
commit
45633dc6a0
1 changed files with 35 additions and 19 deletions
|
@ -64,6 +64,14 @@ in
|
|||
readOnly = true;
|
||||
};
|
||||
|
||||
installPath = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = ''
|
||||
Where to place the REUSE.toml generated file, if `null`, the file will be placed in the git toplevel directory.
|
||||
'';
|
||||
};
|
||||
|
||||
defaultLicense = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
|
@ -188,8 +196,9 @@ in
|
|||
}
|
||||
];
|
||||
|
||||
installationScript =
|
||||
# bash
|
||||
installationScript = builtins.concatStringsSep "\n" [
|
||||
(
|
||||
if cfg.installPath == null then
|
||||
''
|
||||
if ! type -t git >/dev/null; then
|
||||
# This happens in pure shells, including lorri
|
||||
|
@ -205,8 +214,15 @@ in
|
|||
cp --no-preserve=mode,ownership ${result} "$GIT_WC/REUSE.toml" && echo "nix-reuse: Updated REUSE.toml"
|
||||
fi
|
||||
fi
|
||||
|
||||
${optionalString config.downloadLicenses "${getExe pkgs.reuse} download --all"}
|
||||
'';
|
||||
''
|
||||
else
|
||||
''
|
||||
if [ ! -f "${cfg.installPath}/REUSE.toml" ] || ! ${getExe' pkgs.diffutils "cmp"} -s "${cfg.installPath}/REUSE.toml" ${result} ; then
|
||||
cp --no-preserve=mode,ownership ${result} "${cfg.installPath}/REUSE.toml" && echo "nix-reuse: Updated REUSE.toml"
|
||||
fi
|
||||
''
|
||||
)
|
||||
(optionalString config.downloadLicenses "${getExe pkgs.reuse} download --all")
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue