summary refs log tree commit diff
path: root/pkgs/os-specific/linux/minimal-bootstrap/gnused/default.nix
blob: ee566f93c16434c980c0d3b963548d3baed6f705 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{ lib
, buildPlatform
, hostPlatform
, fetchurl
, bash
, gnumake
, tinycc
, gnused
, gnugrep
, gnutar
, gzip
}:

let
  inherit (import ./common.nix { inherit lib; }) meta;
  pname = "gnused";
  # last version that can be bootstrapped with our slightly buggy gnused-mes
  version = "4.2";

  src = fetchurl {
    url = "mirror://gnu/sed/sed-${version}.tar.gz";
    hash = "sha256-20XNY/0BDmUFN9ZdXfznaJplJ0UjZgbl5ceCk3Jn2YM=";
  };
in
bash.runCommand "${pname}-${version}" {
  inherit pname version meta;

  nativeBuildInputs = [
    gnumake
    tinycc.compiler
    gnused
    gnugrep
    gnutar
    gzip
  ];

  passthru.tests.get-version = result:
    bash.runCommand "${pname}-get-version-${version}" {} ''
      ${result}/bin/sed --version
      mkdir ''${out}
    '';
} (''
  # Unpack
  tar xzf ${src}
  cd sed-${version}

  # Configure
  export CC="tcc -B ${tinycc.libs}/lib"
  export LD=tcc
  ./configure \
    --build=${buildPlatform.config} \
    --host=${hostPlatform.config} \
    --disable-shared \
    --disable-nls \
    --disable-dependency-tracking \
    --prefix=$out

  # Build
  make AR="tcc -ar"

  # Install
  make install
'')