~kaction/config

ref: 7453c85b651ca3f003c1ae9c6c5d11520a3c0b6f config/system-v2/nix-sys/default.nix -rw-r--r-- 749 bytes
7453c85b — Dmitry Bogatov nix-sys: do not install during configure phase 8 months ago
                                                                                
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
{ stdenv, tinycdb, nix-sys-generate, manifest ? {} }:
assert manifest != null;
let
in stdenv.mkDerivation {
  name = "nix-sys";
  src = ./.;
  outputs = [ "out" "cdb" ];
  nativeBuildInputs = [ nix-sys-generate ];
  buildInputs = [ tinycdb ];
  configurePhase = ''
    hash=$(echo ${placeholder "out"}|cut -b 12-43)
    nix-sys-generate \
      --manifest "$manifest" \
      --output-config config.h \
      --output-cdb $cdb \
      --staged-output-cdb index.cdb \
      --hash $hash
  '';
  installPhase = ''
    mkdir -p $out/bin
    ${stdenv.hostPlatform.config}-cc -static -O2 -g main.c -lcdb -o $out/bin/nix-sys
    ${stdenv.hostPlatform.config}-strip -s $out/bin/nix-sys
    mv index.cdb $cdb
  '';
  manifest = builtins.toJSON manifest;
}