export "dir" and "symlink" from pseudofiles package

This commit is contained in:
Daniel Barlow 2022-09-26 18:27:43 +01:00
parent 1c14bb63fa
commit 09a9dba963
5 changed files with 16 additions and 13 deletions

View file

@ -1,6 +1,8 @@
{ lib, ...}: { lib, pkgs, ...}:
let let
inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ; inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ;
inherit (pkgs.pseudofile) dir symlink;
type_service = types.package // { type_service = types.package // {
name = "service"; name = "service";
description = "s6-rc service"; description = "s6-rc service";

View file

@ -2,9 +2,7 @@
writeText writeText
, lib , lib
}: }:
filename : attrset :
let let
inherit (lib.debug) traceSeqN;
inherit (lib.attrsets) mapAttrsToList; inherit (lib.attrsets) mapAttrsToList;
visit = prefix: attrset: visit = prefix: attrset:
let let
@ -33,5 +31,8 @@ let
line) line)
attrset; attrset;
in builtins.concatStringsSep "\n" l; in builtins.concatStringsSep "\n" l;
res = (visit "" attrset); in {
in writeText filename res write = filename : attrset : writeText filename (visit "" attrset);
dir = contents: { type = "d"; inherit contents; };
symlink = target: { type = "s"; inherit target; };
}

View file

@ -21,8 +21,7 @@ let
patchShebangs $out/scripts patchShebangs $out/scripts
''; '';
}; };
dir = contents: { type = "d"; inherit contents; }; inherit (pseudofile) dir symlink;
symlink = target: { type = "s"; inherit target; };
scripts = symlink "${initscripts}/scripts"; scripts = symlink "${initscripts}/scripts";
env = dir {}; env = dir {};
run-image = dir { run-image = dir {
@ -141,4 +140,4 @@ let
inherit scripts env run-image; inherit scripts env run-image;
};};};}; };};};};
in pseudofile "pseudo.s6-init" structure in pseudofile.write "pseudo.s6-init" structure

View file

@ -4,8 +4,7 @@ expr=$(cat <<"EXPR"
let let
overlay = import <liminix/overlay.nix>; overlay = import <liminix/overlay.nix>;
nixpkgs = import <nixpkgs> { overlays = [overlay]; }; nixpkgs = import <nixpkgs> { overlays = [overlay]; };
structure = import ./structure.nix; in nixpkgs.pkgs.callPackage ./test.nix {}
in nixpkgs.pkgs.pseudofile "pseudo.s6-init" structure
EXPR EXPR
) )

View file

@ -1,5 +1,7 @@
let {
dir = contents: { type = "d"; inherit contents; }; pseudofile
}: let
inherit (pseudofile) dir;
structure = { structure = {
service = dir { service = dir {
s6-linux-init-runleveld = dir { s6-linux-init-runleveld = dir {
@ -42,4 +44,4 @@ let
}; };
uncaught-logs = (dir {}) // {mode = "2750";}; uncaught-logs = (dir {}) // {mode = "2750";};
}; };
in structure in pseudofile.write "pseudo.s6-init" structure