Skip to content

Wrapping same program twice for different purposes #32

@nialov

Description

@nialov

Hey, firstly, thanks for creating this project!

Problem

I want to wrap a program, taskwarrior, with different versions, twice so that I have two executables that point to different configuration and have different software versions. However, the home-manager environment that is created has collisions as the two programs have similar files from the two different versions in PATH.

Example

  wm-eval = inputs.wrapper-manager.lib {
    pkgs = prev;
    modules =
      let

        mkTaskWrapper =
          {
            pkg,
            dataLocation,
            binName,
          }:
          {
            basePackage = pkg;

            env.TASKRC.value = prev.writeTextFile {
              name = "taskrc";
              text = ''
                data.location=${dataLocation}
                news.version="${pkg.version}";
              '';
            };
            # Same issue whether shell or binary
            wrapperType = "shell";
            postBuild = ''
              # rm -r $out/share/
              # rm $out/bin/.task-wrapped
              mv $out/bin/task $out/bin/${binName}
            '';
          };

      in
      [
        {
          wrappers = {
            taskw =
              let
                pkg = prev.taskwarrior3;
              in
              mkTaskWrapper {
                inherit pkg;
                dataLocation = "/some/location/1";
                binName = "taskw";
              };
            taskh =
              let
                pkg = prev.taskwarrior2;
              in
              mkTaskWrapper {
                inherit pkg;
                dataLocation = "/some/location/2";
                binName = "taskh";
              };
          };
        }
      ];
  };

The collision error:

error: builder for '/nix/store/8aaiwyi4fwrzfksshnyvrqcsa2rd7hxg-home-manager-path.drv' failed with exit code 25;
       last 5 log lines:
       > pkgs.buildEnv error: two given paths contain a conflicting subpath:
       >   `/nix/store/w87wfaa9lzbxkalpjqvrazgsrmmwzdqp-taskwarrior-3.4.1/bin/.task-wrapped' and
       >   `/nix/store/wcr8id8sf400p6fwwmxg04ay16m8sl51-taskwarrior-2.6.2/bin/.task-wrapped'
       > hint: this may be caused by two different versions of the same package in buildEnv's `paths` parameter
       > hint: `pkgs.nix-diff` can be used to compare derivations
       For full logs, run:
         nix log /nix/store/8aaiwyi4fwrzfksshnyvrqcsa2rd7hxg-home-manager-path.drv

Solution?

I can remove contents of $out/share/ in the postBuild step but how to avoid collision with the .task-wrapped file? I tried to use the programs option provided by wrapper-manager but did not understand how to make it work for this use case or even if it is a solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions