commit f02efa3fe3934deb0fb5aafc6a05bf8bec4c523c
parent 342c87b256eda345c354e42d08ff49b730b37135
Author: Daniel Barlow <dan@telent.net>
Date: Tue, 4 Apr 2023 21:11:28 +0100
refactor
Diffstat:
1 file changed, 24 insertions(+), 22 deletions(-)
diff --git a/pkgs/pseudofile/default.nix b/pkgs/pseudofile/default.nix
@@ -12,30 +12,32 @@ let
msg;
l =
mapAttrsToList
- (filename: attrs:
+ (filename: {
+ type ? "f"
+ , mode ? null
+ , target ? null
+ , contents ? null
+ , file ? null
+ , major ? null
+ , minor ? null
+ , subtype ? null
+ }:
let
- attrs' = {type = "f"; } // attrs;
- mode = if attrs ? mode then attrs.mode else
- (if attrs'.type == "d" then "0755" else "0644");
- line = "${prefix}/${filename} ${attrs'.type} ${mode} 0 0";
+ mode' = if mode != null then mode else
+ (if type == "d" then "0755" else "0644");
+ pathname = "${prefix}/${filename}";
+ line = "${pathname} ${type} ${mode'} 0 0";
in
- if attrs'.type == "f" then
- "${line} echo -n \"${qprint attrs'.file}\" |qprint -d"
- else if attrs'.type == "d" then
- (visit "${prefix}/${filename}" attrs.contents) +
- "\n" + line
- else if attrs'.type == "c" then
- with attrs'; "${line} ${major} ${minor}"
- else if attrs'.type == "b" then
- with attrs'; "${line} ${major} ${minor}"
- else if attrs'.type == "s" then
- "${line} ${attrs'.target}"
- else if attrs'.type == "l" then
- "${prefix}/${filename} l ${attrs'.target}"
- else if attrs'.type == "i" then
- "${line} ${attrs.subtype}"
- else
- line)
+ if type == "f" then
+ "${line} echo -n \"${qprint file}\" |qprint -d"
+ else if type == "d" then
+ (visit pathname contents) + "\n" + line
+ else if type == "c" then "${line} ${major} ${minor}"
+ else if type == "b" then "${line} ${major} ${minor}"
+ else if type == "s" then "${line} ${target}"
+ else if type == "l" then "${pathname} l ${target}"
+ else if type == "i" then "${line} ${subtype}"
+ else line)
attrset;
in builtins.concatStringsSep "\n" l;
in {