about summary refs log tree commit diff
path: root/release.nix
blob: 4a1db9a1a017291cb2fec4504d091ff2a12bb860 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
{ vuizvui ? { outPath = ./.; revCount = 12345; shortRev = "abcdefg"; }
, nixpkgs ? { outPath = <nixpkgs>; revCount = 12345; shortRev = "abcdefg"; }
, supportedSystems ? [ "i686-linux" "x86_64-linux" ]
}:

let
  system = "x86_64-linux";
  pkgsUpstream = import <nixpkgs> { inherit system; };
  root = import ./default.nix { inherit system; };

in with pkgsUpstream.lib; with builtins; {

  machines = mapAttrsRecursiveCond (m: !(m ? build)) (path: attrs:
    attrs.build.config.system.build.toplevel
  ) (import ./machines { inherit system; });

  tests = mapAttrsRecursiveCond (t: !(t ? test)) (const id) (import ./tests {
    inherit system;
  });

  pkgs = let
    releaseLib = import <nixpkgs/pkgs/top-level/release-lib.nix> {
      inherit supportedSystems;
      packageSet = attrs: (import ./default.nix attrs).pkgs;
    };
  in with releaseLib; mapTestOn (packagePlatforms releaseLib.pkgs);

  channels = let
    mkChannel = attrs: root.pkgs.mkChannel (rec {
      name = "vuizvui-channel-${attrs.name or "generic"}-${version}";
      version = "${toString vuizvui.revCount}.${vuizvui.shortRev}";
      pkgsVer = "pre${toString nixpkgs.revCount}.${nixpkgs.shortRev}-vuizvui";
      src = vuizvui;
      patchPhase = ''
        cp -r --no-preserve=mode,ownership "${nixpkgs}/" nixpkgs
        find \( -iname '*.nix' -type f \
             -o -path ./nixpkgs/nixos/modules/installer/tools/nixos-rebuild.sh \
             \) -exec sed -i -re 's!<nixpkgs([^>]*)>!<vuizvui/nixpkgs\1>!g' {} +
        echo -n "$pkgsVer" > nixpkgs/.version-suffix
        echo -n ${nixpkgs.rev or nixpkgs.shortRev} > nixpkgs/.git-revision
        touch .update-on-nixos-rebuild
      '';
    } // removeAttrs attrs [ "name" ]);

  in {
    generic = mkChannel {};

    machines = mapAttrsRecursiveCond (m: !(m ? build)) (path: attrs: mkChannel {
      name = "machine-${last path}";
      constituents = singleton attrs.build.config.system.build.toplevel;
    }) (import ./machines { inherit system; });
  };

  manual = let
    modules = import <nixpkgs/nixos/lib/eval-config.nix> {
      modules = import ./modules/module-list.nix;
      check = false;
      inherit system;
    };

    isVuizvui = opt: head (splitString "." opt.name) == "vuizvui";
    filterDoc = filter (opt: isVuizvui opt && opt.visible && !opt.internal);
    optionsXML = toXML (filterDoc (optionAttrSetToDocList modules.options));
    optionsFile = toFile "options.xml" (unsafeDiscardStringContext optionsXML);
  in pkgsUpstream.stdenv.mkDerivation {
    name = "vuizvui-options";

    buildInputs = singleton pkgsUpstream.libxslt;

    xsltFlags = ''
      --param section.autolabel 1
      --param section.label.includes.component.label 1
      --param html.stylesheet 'style.css'
      --param xref.with.number.and.title 1
      --param admon.style '''
    '';

    buildCommand = ''
      xsltproc -o options-db.xml \
        ${<nixpkgs/nixos/doc/manual/options-to-docbook.xsl>} \
        ${optionsFile}

      cat > manual.xml <<XML
      <book xmlns="http://docbook.org/ns/docbook"
            xmlns:xlink="http://www.w3.org/1999/xlink"
            xmlns:xi="http://www.w3.org/2001/XInclude">
        <title>Vuizvui-specific NixOS options</title>
        <para>
          The following NixOS options are specific to Vuizvui:
        </para>
        <xi:include href="options-db.xml" />
      </book>
      XML

      xsltproc -o "$out/manual.html" $xsltFlags -nonet -xinclude \
        ${pkgsUpstream.docbook5_xsl}/xml/xsl/docbook/xhtml/docbook.xsl \
        manual.xml

      cp "${<nixpkgs/nixos/doc/manual/style.css>}" "$out/style.css"

      mkdir -p "$out/nix-support"
      echo "doc manual $out manual.html" \
        > "$out/nix-support/hydra-build-products"
    '';
  };
}