liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 09a9dba96347a9c6a326d393b33b515eb6f55ecb
parent 1c14bb63fac64bcfd3f51d4dd65b565c0c0aafe0
Author: Daniel Barlow <dan@telent.net>
Date:   Mon, 26 Sep 2022 18:27:43 +0100

export "dir" and "symlink" from pseudofiles package

Diffstat:
Mmodules/base.nix | 4+++-
Mpkgs/pseudofile/default.nix | 9+++++----
Mpkgs/s6-init-files/default.nix | 5++---
Mtests/pseudofiles/run.sh | 3+--
Dtests/pseudofiles/structure.nix | 45---------------------------------------------
Atests/pseudofiles/test.nix | 47+++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 58 insertions(+), 55 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -4,8 +4,7 @@ expr=$(cat <<"EXPR" let overlay = import <liminix/overlay.nix>; nixpkgs = import <nixpkgs> { 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/structure.nix @@ -1,45 +0,0 @@ -let - dir = contents: { type = "d"; inherit contents; }; - structure = { - service = dir { - s6-linux-init-runleveld = dir { - notification-fd = { file = "3"; }; - run = { - file = '' - hello - world - ''; - mode = "0755"; - }; - }; - s6-linux-init-shutdownd = dir { - fifo = { - type = "i"; - subtype = "f"; - mode = "0600"; - }; - run = { - file = '' - s6-linux-init/bin/s6-linux-init-shutdownd -c "/etc/s6-linux-init/current" -g 3000 - ''; - mode = "0755"; - }; - - }; - s6-svscan-log = dir { - fifo = { - type = "i"; - subtype = "f"; - mode = "0600"; - }; - notification-fd = { file = "3"; }; - run = { - file = '' - gdsgdfgsdgf - ''; - }; - }; - }; - uncaught-logs = (dir {}) // {mode = "2750";}; - }; -in structure diff --git a/tests/pseudofiles/test.nix b/tests/pseudofiles/test.nix @@ -0,0 +1,47 @@ +{ + pseudofile +}: let + inherit (pseudofile) dir; + structure = { + service = dir { + s6-linux-init-runleveld = dir { + notification-fd = { file = "3"; }; + run = { + file = '' + hello + world + ''; + mode = "0755"; + }; + }; + s6-linux-init-shutdownd = dir { + fifo = { + type = "i"; + subtype = "f"; + mode = "0600"; + }; + run = { + file = '' + s6-linux-init/bin/s6-linux-init-shutdownd -c "/etc/s6-linux-init/current" -g 3000 + ''; + mode = "0755"; + }; + + }; + s6-svscan-log = dir { + fifo = { + type = "i"; + subtype = "f"; + mode = "0600"; + }; + notification-fd = { file = "3"; }; + run = { + file = '' + gdsgdfgsdgf + ''; + }; + }; + }; + uncaught-logs = (dir {}) // {mode = "2750";}; + }; +in pseudofile.write "pseudo.s6-init" structure