summary refs log tree commit diff
path: root/pkgs/tools/misc/arch-install-scripts/default.nix
blob: a872683092526f6d23c4ccfe86448093ca5bebf4 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{ lib
, resholve
, fetchFromGitHub
, asciidoc
, bash
, coreutils
, gawk
, gnugrep
, gnum4
, pacman
, util-linux
, chrootPath ? [
    "/usr/local/sbin"
    "/usr/local/bin"
    "/usr/bin"
    "/usr/bin/site_perl"
    "/usr/bin/vendor_perl"
    "/usr/bin/core_perl"
  ]
}:

resholve.mkDerivation rec {
  pname = "arch-install-scripts";
  version = "28";

  src = fetchFromGitHub {
    owner = "archlinux";
    repo = "arch-install-scripts";
    rev = "v${version}";
    hash = "sha256-TytCeejhjWYDzWFjGubUl08OrsAQa9fFULoamDfbdDY=";
  };

  nativeBuildInputs = [ asciidoc gnum4 ];

  postPatch = ''
    substituteInPlace ./Makefile \
      --replace "PREFIX = /usr/local" "PREFIX ?= /usr/local"
    substituteInPlace ./pacstrap.in \
      --replace "cp -a" "cp -LR --no-preserve=mode" \
      --replace "unshare pacman" "unshare ${pacman}/bin/pacman" \
      --replace 'gnupg "$newroot/etc/pacman.d/"' 'gnupg "$newroot/etc/pacman.d/" && chmod 700 "$newroot/etc/pacman.d/gnupg"'
    echo "export PATH=${lib.strings.makeSearchPath "" chrootPath}:\$PATH" >> ./common
  '';

  installFlags = [ "PREFIX=$(out)" ];

  doCheck = true;

  solutions = {
    # Give each solution a short name. This is what you'd use to
    # override its settings, and it shows in (some) error messages.
    profile = {
      # the only *required* arguments are the 3 below

      # Specify 1 or more $out-relative script paths. Unlike many
      # builders, resholve.mkDerivation modifies the output files during
      # fixup (to correctly resolve in-package sourcing).
      scripts = [ "bin/arch-chroot" "bin/genfstab" "bin/pacstrap" ];

      # "none" for no shebang, "${bash}/bin/bash" for bash, etc.
      interpreter = "${bash}/bin/bash";

      # packages resholve should resolve executables from
      inputs = [ coreutils gawk gnugrep pacman util-linux ];

      execer = [ "cannot:${pacman}/bin/pacman-key" ];

      # TODO: no good way to resolve mount/umount in Nix builds for now
      # see https://github.com/abathur/resholve/issues/29
      fix = {
        mount = true;
        umount = true;
      };

      keep = [ "$setup" "$pid_unshare" "$mount_unshare" "${pacman}/bin/pacman" ];
    };
  };

  meta = with lib; {
    description = "Useful scripts for installing Arch Linux";
    longDescription = ''
      A small suite of scripts aimed at automating some menial tasks when installing Arch Linux.
    '';
    homepage = "https://github.com/archlinux/arch-install-scripts";
    license = licenses.gpl2Only;
    maintainers = with maintainers; [ samlukeyes123 ];
    platforms = platforms.linux;
  };
}