diff options
author | Profpatsch <mail@profpatsch.de> | 2024-07-21 22:22:24 +0200 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2024-07-21 22:22:24 +0200 |
commit | 26d77df2bf8600c7cf6ecba4125e1b6b1916a9ba (patch) | |
tree | 826b1597953afc603bb6e48f51fcbcb2a27a0bd5 /pkgs/profpatsch/importDhall.nix | |
parent | 267638857e9b28af86cd2c59b5b754abf750deb3 (diff) |
pkgs/profpatsch/xdg-open: delete all dhall stuff
Diffstat (limited to 'pkgs/profpatsch/importDhall.nix')
-rw-r--r-- | pkgs/profpatsch/importDhall.nix | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/pkgs/profpatsch/importDhall.nix b/pkgs/profpatsch/importDhall.nix deleted file mode 100644 index 88e785ad..00000000 --- a/pkgs/profpatsch/importDhall.nix +++ /dev/null @@ -1,73 +0,0 @@ -{ pkgs, exactSource }: -let - - # import the dhall file as nix expression via dhall-nix. - # Converts the normalized dhall expression to a nix file, - # puts it in the store and imports it. - # Types are erased, functions are converted to nix functions, - # unions values are nix functions that take a record of match - # functions for their alternatives. - importDhall = dhallType: file: importDhall2 { - name = "dhall-to-nix"; - root = builtins.dirOf file; - files = []; - main = builtins.baseNameOf file; - type = dhallType; - deps = []; - }; - - # TODO: document - importDhall2 = { name, root, files, main, deps, type ? null }: - let - src = - exactSource - root - # exactSource wants nix paths, but I think relative paths - # as strings are more intuitive. - (let abs = path: toString root + "/" + path; - in ([ (abs main) ] ++ (map abs files))); - - cache = ".cache"; - cacheDhall = "${cache}/dhall"; - - convert = pkgs.runCommandLocal "${name}-dhall-to-nix" { inherit deps; } '' - mkdir -p ${cacheDhall} - for dep in $deps; do - ${pkgs.xorg.lndir}/bin/lndir -silent $dep/${cacheDhall} ${cacheDhall} - done - - export XDG_CACHE_HOME=$(pwd)/${cache} - # go into the source directory, so that the type can import files. - # TODO: This is a bit of a hack hrm. - cd "${src}" - ${if type != null then '' - printf '%s' ${pkgs.lib.escapeShellArg "${src}/${main} : ${type}"} \ - | ${pkgs.dhall-nix}/bin/dhall-to-nix \ - > $out - '' else '' - printf '%s' ${pkgs.lib.escapeShellArg "${src}/${main}"} \ - | ${pkgs.dhall-nix}/bin/dhall-to-nix \ - > $out - ''} - ''; - in import convert; - - - # read dhall file in as JSON, then import as nix expression. - # The dhall file must not try to import from non-local URLs! - readDhallFileAsJson = dhallType: file: - let - convert = pkgs.runCommandLocal "dhall-to-json" {} '' - printf '%s' ${pkgs.lib.escapeShellArg "${file} : ${dhallType}"} \ - | ${pkgs.dhall-json}/bin/dhall-to-json \ - > $out - ''; - in builtins.fromJSON (builtins.readFile convert); - -in { - inherit - importDhall - importDhall2 - readDhallFileAsJson - ; -} |