style: Switch to nixfmt from nixpkgs-fmt
Most of the ecosystem has moved to this formatter, and many people configured their editors to autoformat it with this formatter. Closes: https://git.snix.dev/snix/snix/issues/62 Change-Id: Icf39e7836c91fc2ae49fbe22a40a639105bfb0bd Reviewed-on: https://cl.snix.dev/c/snix/+/30671 Reviewed-by: Florian Klink <flokli@flokli.de> Tested-by: besadii Autosubmit: Ilan Joselevich <personal@ilanjoselevich.com>
This commit is contained in:
parent
3443e6bd08
commit
91d02d8c84
136 changed files with 39952 additions and 11007 deletions
|
|
@ -15,19 +15,19 @@
|
|||
|
||||
{
|
||||
# root path to use as a reference point
|
||||
root
|
||||
, # list of paths below `root` that should be
|
||||
root,
|
||||
# list of paths below `root` that should be
|
||||
# included in the resulting directory
|
||||
#
|
||||
# If path, need to refer to the actual file / directory to be included.
|
||||
# If a string, it is treated as a string relative to the root.
|
||||
paths
|
||||
, # (optional) name to use for the derivation
|
||||
paths,
|
||||
# (optional) name to use for the derivation
|
||||
#
|
||||
# This should always be set when using roots that do not have
|
||||
# controlled names, such as when passing the top-level of a git
|
||||
# repository (e.g. `depot.path.origSrc`).
|
||||
name ? builtins.baseNameOf root
|
||||
name ? builtins.baseNameOf root,
|
||||
}:
|
||||
|
||||
let
|
||||
|
|
@ -36,12 +36,14 @@ let
|
|||
# Count slashes in a path.
|
||||
#
|
||||
# Type: path -> int
|
||||
depth = path: lib.pipe path [
|
||||
toString
|
||||
(builtins.split "/")
|
||||
(builtins.filter builtins.isList)
|
||||
builtins.length
|
||||
];
|
||||
depth =
|
||||
path:
|
||||
lib.pipe path [
|
||||
toString
|
||||
(builtins.split "/")
|
||||
(builtins.filter builtins.isList)
|
||||
builtins.length
|
||||
];
|
||||
|
||||
# (Parent) directories will be created from deepest to shallowest
|
||||
# which should mean no conflicts are caused unless both a child
|
||||
|
|
@ -52,19 +54,24 @@ let
|
|||
# Create a set which contains the source path to copy / symlink and
|
||||
# it's destination, so the path below the destination root including
|
||||
# a leading slash. Additionally some sanity checking is done.
|
||||
makeSymlink = path:
|
||||
makeSymlink =
|
||||
path:
|
||||
let
|
||||
withLeading = p: if builtins.substring 0 1 p == "/" then p else "/" + p;
|
||||
fullPath =
|
||||
if builtins.isPath path then path
|
||||
else if builtins.isString path then (root + withLeading path)
|
||||
else builtins.throw "Unsupported path type ${builtins.typeOf path}";
|
||||
if builtins.isPath path then
|
||||
path
|
||||
else if builtins.isString path then
|
||||
(root + withLeading path)
|
||||
else
|
||||
builtins.throw "Unsupported path type ${builtins.typeOf path}";
|
||||
strPath = toString fullPath;
|
||||
contextPath = "${fullPath}";
|
||||
belowRoot = builtins.substring rootLength (-1) strPath;
|
||||
prefix = builtins.substring 0 rootLength strPath;
|
||||
in
|
||||
assert toString root == prefix; {
|
||||
assert toString root == prefix;
|
||||
{
|
||||
src = contextPath;
|
||||
dst = belowRoot;
|
||||
};
|
||||
|
|
@ -73,12 +80,13 @@ let
|
|||
in
|
||||
|
||||
# TODO(sterni): teach readTree to also read symlinked directories,
|
||||
# so we ln -sT instead of cp -aT.
|
||||
# so we ln -sT instead of cp -aT.
|
||||
pkgs.runCommand "sparse-${name}" { } (
|
||||
lib.concatMapStrings
|
||||
({ src, dst }: ''
|
||||
lib.concatMapStrings (
|
||||
{ src, dst }:
|
||||
''
|
||||
mkdir -p "$(dirname "$out${dst}")"
|
||||
cp -aT --reflink=auto "${src}" "$out${dst}"
|
||||
'')
|
||||
symlinks
|
||||
''
|
||||
) symlinks
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue