From 09a9dba96347a9c6a326d393b33b515eb6f55ecb Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Mon, 26 Sep 2022 18:27:43 +0100 Subject: [PATCH] export "dir" and "symlink" from pseudofiles package --- modules/base.nix | 4 +++- pkgs/pseudofile/default.nix | 9 +++++---- pkgs/s6-init-files/default.nix | 5 ++--- tests/pseudofiles/run.sh | 3 +-- tests/pseudofiles/{structure.nix => test.nix} | 8 +++++--- 5 files changed, 16 insertions(+), 13 deletions(-) rename tests/pseudofiles/{structure.nix => test.nix} (90%) diff --git a/modules/base.nix b/modules/base.nix index 99c68a6..7ac3a77 100644 --- a/modules/base.nix +++ b/modules/base.nix @@ -1,6 +1,8 @@ -{ lib, ...}: +{ lib, pkgs, ...}: let inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ; + inherit (pkgs.pseudofile) dir symlink; + type_service = types.package // { name = "service"; description = "s6-rc service"; diff --git a/pkgs/pseudofile/default.nix b/pkgs/pseudofile/default.nix index 52d6821..bb775f8 100644 --- a/pkgs/pseudofile/default.nix +++ b/pkgs/pseudofile/default.nix @@ -2,9 +2,7 @@ writeText , lib }: -filename : attrset : let - inherit (lib.debug) traceSeqN; inherit (lib.attrsets) mapAttrsToList; visit = prefix: attrset: let @@ -33,5 +31,8 @@ let line) attrset; in builtins.concatStringsSep "\n" l; - res = (visit "" attrset); -in writeText filename res +in { + write = filename : attrset : writeText filename (visit "" attrset); + dir = contents: { type = "d"; inherit contents; }; + symlink = target: { type = "s"; inherit target; }; +} diff --git a/pkgs/s6-init-files/default.nix b/pkgs/s6-init-files/default.nix index f4ac72d..0108e12 100644 --- a/pkgs/s6-init-files/default.nix +++ b/pkgs/s6-init-files/default.nix @@ -21,8 +21,7 @@ let patchShebangs $out/scripts ''; }; - dir = contents: { type = "d"; inherit contents; }; - symlink = target: { type = "s"; inherit target; }; + inherit (pseudofile) dir symlink; scripts = symlink "${initscripts}/scripts"; env = dir {}; run-image = dir { @@ -141,4 +140,4 @@ let inherit scripts env run-image; };};};}; -in pseudofile "pseudo.s6-init" structure +in pseudofile.write "pseudo.s6-init" structure diff --git a/tests/pseudofiles/run.sh b/tests/pseudofiles/run.sh index 6e515ad..81f407e 100755 --- a/tests/pseudofiles/run.sh +++ b/tests/pseudofiles/run.sh @@ -4,8 +4,7 @@ expr=$(cat <<"EXPR" let overlay = import ; nixpkgs = import { overlays = [overlay]; }; - structure = import ./structure.nix; -in nixpkgs.pkgs.pseudofile "pseudo.s6-init" structure +in nixpkgs.pkgs.callPackage ./test.nix {} EXPR ) diff --git a/tests/pseudofiles/structure.nix b/tests/pseudofiles/test.nix similarity index 90% rename from tests/pseudofiles/structure.nix rename to tests/pseudofiles/test.nix index a762aa0..043b23d 100644 --- a/tests/pseudofiles/structure.nix +++ b/tests/pseudofiles/test.nix @@ -1,5 +1,7 @@ -let - dir = contents: { type = "d"; inherit contents; }; +{ + pseudofile +}: let + inherit (pseudofile) dir; structure = { service = dir { s6-linux-init-runleveld = dir { @@ -42,4 +44,4 @@ let }; uncaught-logs = (dir {}) // {mode = "2750";}; }; -in structure +in pseudofile.write "pseudo.s6-init" structure