summary refs log tree commit diff
path: root/maintainers/scripts/update-dotnet-lockfiles.nix
blob: 22ceff1ffa996d5aba0b916514498e1e5d60f7a4 (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
/*
  To run:

      nix-shell maintainers/scripts/update-dotnet-lockfiles.nix

  This script finds all the derivations in nixpkgs that have a 'fetch-deps'
  attribute, and runs all of them sequentially. This is useful to test changes
  to 'fetch-deps', 'nuget-to-nix', or other changes to the dotnet build
  infrastructure. Regular updates should be done through the individual packages
  update scripts.
 */
let
  pkgs = import ../.. {};

  inherit (pkgs) lib;

  packagesWith = cond: pkgs:
    let
      packagesWithInner = attrs:
        lib.unique (
          lib.concatLists (
            lib.mapAttrsToList (name: elem:
              let
                result = builtins.tryEval elem;
              in
                if result.success then
                  let
                    value = result.value;
                  in
                    if lib.isDerivation value then
                      lib.optional (cond value) value
                    else
                      if lib.isAttrs value && (value.recurseForDerivations or false || value.recurseForRelease or false) then
                        packagesWithInner value
                      else []
                else []) attrs));
    in
      packagesWithInner pkgs;

  packages =
    packagesWith (pkgs: pkgs ? fetch-deps) pkgs;

  helpText = ''
    Please run:

        % nix-shell maintainers/scripts/update-dotnet-lockfiles.nix
  '';

  fetchScripts = map (p: p.fetch-deps) packages;

in pkgs.stdenv.mkDerivation {
  name = "nixpkgs-update-dotnet-lockfiles";
  buildCommand = ''
    echo ""
    echo "----------------------------------------------------------------"
    echo ""
    echo "Not possible to update packages using \`nix-build\`"
    echo ""
    echo "${helpText}"
    echo "----------------------------------------------------------------"
    exit 1
  '';
  shellHook = ''
    unset shellHook # do not contaminate nested shells
    set -e
    for x in $fetchScripts; do
      $x
    done
    exit
  '';
  inherit fetchScripts;
}