diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/envfs.nix | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/modules/envfs.nix b/modules/envfs.nix deleted file mode 100644 index b5b453a5..00000000 --- a/modules/envfs.nix +++ /dev/null | |||
| @@ -1,77 +0,0 @@ | |||
| 1 | { pkgs, config, lib, ... }: | ||
| 2 | |||
| 3 | let | ||
| 4 | cfg = config.services.envfs; | ||
| 5 | mounts = { | ||
| 6 | "/usr/bin" = { | ||
| 7 | device = "none"; | ||
| 8 | fsType = "envfs"; | ||
| 9 | options = [ | ||
| 10 | "bind-mount=/bin" | ||
| 11 | "fallback-path=${pkgs.symlinkJoin { | ||
| 12 | name = "fallback-path"; | ||
| 13 | inherit (cfg) paths; | ||
| 14 | }}" | ||
| 15 | "nofail" | ||
| 16 | ]; | ||
| 17 | }; | ||
| 18 | "/bin" = { | ||
| 19 | device = "/usr/bin"; | ||
| 20 | fsType = "none"; | ||
| 21 | options = [ "bind" "nofail" ]; | ||
| 22 | }; | ||
| 23 | }; | ||
| 24 | in { | ||
| 25 | disabledModules = [ "tasks/filesystems/envfs.nix" ]; | ||
| 26 | |||
| 27 | options = { | ||
| 28 | services.envfs = { | ||
| 29 | enable = lib.mkEnableOption "Envfs filesystem" // { | ||
| 30 | default = true; | ||
| 31 | description = '' | ||
| 32 | Fuse filesystem that returns symlinks to executables based on the PATH | ||
| 33 | of the requesting process. This is useful to execute shebangs on NixOS | ||
| 34 | that assume hard coded locations in locations like /bin or /usr/bin | ||
| 35 | etc. | ||
| 36 | ''; | ||
| 37 | }; | ||
| 38 | |||
| 39 | package = lib.mkOption { | ||
| 40 | type = lib.types.package; | ||
| 41 | default = pkgs.envfs; | ||
| 42 | defaultText = lib.literalExpression "pkgs.envfs"; | ||
| 43 | description = "Which package to use for the envfs."; | ||
| 44 | }; | ||
| 45 | |||
| 46 | paths = lib.mkOption { | ||
| 47 | type = lib.types.listOf lib.types.package; | ||
| 48 | default = [ | ||
| 49 | (pkgs.runCommand "fallback-path-environment" {} '' | ||
| 50 | mkdir -p $out | ||
| 51 | ln -s ${config.environment.usrbinenv} $out/env | ||
| 52 | ln -s ${config.environment.binsh} $out/sh | ||
| 53 | '') | ||
| 54 | ]; | ||
| 55 | defaultText = lib.literalExpression '' | ||
| 56 | [ (pkgs.runCommand "fallback-path-environment" {} ''' | ||
| 57 | mkdir -p $out | ||
| 58 | ln -s ''${config.environment.usrbinenv} $out/env | ||
| 59 | ln -s ''${config.environment.binsh} $out/sh | ||
| 60 | ''') | ||
| 61 | ] | ||
| 62 | ''; | ||
| 63 | description = "Extra packages to join into collection of fallback executables in case not other executable is found"; | ||
| 64 | }; | ||
| 65 | }; | ||
| 66 | }; | ||
| 67 | |||
| 68 | config = lib.mkIf (cfg.enable) { | ||
| 69 | environment.systemPackages = [ cfg.package ]; | ||
| 70 | # we also want these mounts in virtual machines. | ||
| 71 | fileSystems = if config.virtualisation ? qemu then lib.mkVMOverride mounts else mounts; | ||
| 72 | |||
| 73 | # We no longer need those when using envfs | ||
| 74 | system.activationScripts.usrbinenv = lib.mkForce ""; | ||
| 75 | system.activationScripts.binsh = lib.mkForce ""; | ||
| 76 | }; | ||
| 77 | } | ||
