Skip to content

Instantly share code, notes, and snippets.

@apraga
Created August 26, 2022 21:29
Show Gist options
  • Save apraga/1b1175e96822efa5cbfc329c4a2833d7 to your computer and use it in GitHub Desktop.
Save apraga/1b1175e96822efa5cbfc329c4a2833d7 to your computer and use it in GitHub Desktop.
PATH issue with Nextflow
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
};
description = "test";
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
generateConfig = pkgs.runCommand "generateConfig" {
propagatedBuildInputs = [ pkgs.nextflow pkgs.bwa ];
} ''
mkdir $out
cat << EOF > $out/main.nf
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
process Bwa {
output:
file "test.txt"
"""
bwa
"""
}
workflow {
Bwa() | view
}
EOF
'';
in {
packages.${system}.default = generateConfig;
apps.${system}.default = {
type = "app";
name = "nextflowRun";
program = "${pkgs.nextflow}/bin/nextflow";
};
};
}
@pennae
Copy link

pennae commented Aug 26, 2022

or this for a generic solution that makes stuff available to all calls of the default app

{

  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
  };

  description = "test";

  outputs = { self, nixpkgs }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs { inherit system; };

      generateConfig = pkgs.runCommand "generateConfig" {
        propagatedBuildInputs = [ pkgs.nextflow pkgs.bwa ];
      } ''
        mkdir $out
        cat << EOF > $out/main.nf
        #!/usr/bin/env nextflow
        nextflow.enable.dsl=2
        process Bwa {
            output:
            file "test.txt"

            """
            bwa
            """
        }
        workflow {
            Bwa() | view
        }
        EOF
      '';
    in {
      packages.${system}.default = generateConfig;
      apps.${system}.default = {
        type = "app";
        name = "nextflowRun";
        program = "${pkgs.writeShellScript "nextflow" ''
          export PATH="${pkgs.lib.makeBinPath generateConfig.propagatedBuildInputs}:$PATH"
          exec ${pkgs.nextflow}/bin/nextflow "$@"
        ''}";
      };
    };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment