about summary refs log tree commit diff stats
path: root/pkgs/by-name/na/nato/package.nix
blob: 17fe7d1ad1bb878ee64fe038cdd484b0fec2d243 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{
  lib,
  python3,
  runCommandLocal,
  makeWrapper,
}: let
  write_python = {
    name,
    dependencies_system ? [],
    dependencies_python ? _: [],
    keepPath ? false,
  }: let
    src = ./${name}.py;
    dependencies =
      [(python3.withPackages dependencies_python)]
      ++ dependencies_system;
    path_setting =
      if keepPath
      then "--prefix PATH :"
      else "--set PATH";
  in
    runCommandLocal name {
      nativeBuildInputs = [makeWrapper] ++ dependencies;
    }
    ''
      install -m755 ${src} -D "$out/bin/${name}"
      patchShebangs "$out/bin/${name}"
      wrapProgram "$out/bin/${name}" ${path_setting} ${lib.makeBinPath dependencies};
    '';
in
  write_python {
    name = "nato";
    dependencies_python = ps: [];
  }