~kaction/config

ref: a549523bfb364f9f9d0766477e804d9f020038ea config/flake.nix -rw-r--r-- 5.6 KiB
a549523b — Dmitry Bogatov Merge branch 'snapshot-20.09' 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# On supported architectures
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
# Some code is written in amd64 assembler, so we hard-code arch. I do
# not have access to any non-amd64 device, even virtual one, so fine for
# me. Maybe I will regret it, who knows?
{
  description = "Personal flake of ~kaction";
  inputs.nixpkgs.url = "git+https://github.com/nixos/nixpkgs?tag=20.09";
  outputs = { self, nixpkgs }:
    let
      system = "x86_64-linux"; # See note [On supported architectures]
      pkgs = import nixpkgs { inherit system; };

      # Set of packages provided by nixpkgs with all atrribute names
      # prefixed with "pristine-". Makes writing derivations that need
      # access to both new and pristine version of dependency (for raw
      # rewriting, for example) much more uniform.

      pristine = let
        inherit (pkgs.lib) nameValuePair mapAttrs';
        f = name: value: nameValuePair "pristine-${name}" value;
      in mapAttrs' f pkgs;
    in {
      # This incantaion creates something like overlay: new definitions
      # override values from nixpkgs and used to build dependencies.
      #
      # Unlike overlay (e.g import nixpkgs { overlays = [...]; }) it
      # allows caching of nixpkgs, significantly increasing speed of
      # builds. [https://todo.sr.ht/~kaction/config/1]
      #
      # Also, it allows simple access to pristine versions of packages
      # from nixpkgs.
      packages."${system}" = pkgs.lib.makeScope pkgs.newScope (self':
        let
          inherit (self') callPackage;
          call = f: callPackage f { };
          do-rebuild = packages: path: rec {
            name = builtins.baseNameOf path;
            value = callPackage path { "${name}" = packages."${name}"; };
          };

          # In order of increasing preference and decreasing upstream
          # support. Sigh.
          rebuildGlibc = do-rebuild pkgs;
          rebuildMusl = do-rebuild pkgs.pkgsMusl;
          rebuildStatic = do-rebuild pkgs.pkgsStatic;

          rebuilded = builtins.listToAttrs (map rebuildGlibc [
            ./universe/curl
            ./universe/gdb
            ./universe/gnupg
            ./universe/groff
            ./universe/kpcli
            ./universe/libarchive
            ./universe/libusb1
            ./universe/mpop
            ./universe/msmtp
            ./universe/newsboat
            ./universe/openssh
            ./universe/openvpn
            ./universe/pass
            ./universe/python3
            ./universe/rename
            ./universe/rsync
            ./universe/strace
            ./universe/surfraw
            ./universe/tig
            ./universe/w3m
            ./universe/doas
            ./universe/mutt
            ./universe/hub
            ./universe/findutils
          ]);

          rebuildedStatic = builtins.listToAttrs (map rebuildStatic [
            ./universe/less
            ./universe/htop
            ./universe/vim
            ./universe/busybox
          ]);
        in pkgs // pristine // rebuilded // rebuildedStatic // { # nixfmt: sort
          inherit (pkgs.pkgsStatic) execline;
          inherit system;
          Documentation =
            callPackage ./universe/Documentation { inherit nixpkgs; };
          attach-shell = call ./universe/attach-shell;
          blurdate = callPackage ./universe/blurdate { };
          dhall-latest = call ./universe/dhall-latest;
          diohsc = call ./universe/diohsc;
          dropbox_uploader = call ./universe/dropbox_uploader;
          dvtm =
            import ./universe/dvtm { inherit (pkgs.pkgsStatic) dvtm-unstable; };
          fasm-arch = call ./universe/fasm-arch;
          firewall = call ./universe/firewall;

          font-psf = call ./universe/font-psf;
          git = callPackage ./universe/git {
            # Imperfect, but compatible with old overlay-based code.
            git = pkgs.git.override { inherit (self') openssh curl; };
          };
          git-bug = callPackage ./universe/git-bug {
            inherit (pkgs.gitAndTools) git-bug;
          };
          git-recall = call ./universe/git-recall;
          githooks = call ./universe/githooks;

          mk-runscript = call ./universe/mk-runscript;

          nix = callPackage ./universe/nix { nix = pkgs.nixFlakes; };
          nix-sys = callPackage ./system-v2/nix-sys {
            inherit (pkgs.pkgsStatic) stdenv;
          };

          nix-sys-generate = callPackage ./system-v2/nix-sys-generate { };
          nixfmt = call ./universe/nixfmt;

          perl = callPackage ./universe/perl { inherit (pkgs) perl530; };
          psql =
            callPackage ./universe/psql { postgresql = pkgs.postgresql_10; };
          rewrite-paths =
            { drv, rules ? [ ], buildInputs ? [ ], postBuild ? "" }:
            callPackage ./universe/rewrite-paths {
              inherit drv rules buildInputs postBuild;
            };
          srht-ui = call ./universe/srht-ui;
          ssh-env = call ./universe/ssh-env;
          selectors = call ./universe/selectors;

          system-wide = callPackage ./system-v2 { };
          tempfile = pkgs.pkgsStatic.callPackage ./universe/tempfile { };
          uenv = call ./universe/uenv;
          universe-key = call ./universe/universe-key;
          runx = callPackage ./universe/runx { };

          # This one requires secret key.
          universe-full = import ./universe {
            use-hardware-token = true;
            pkgs = self.packages."${system}";
          };

          universe-public = import ./universe {
            use-hardware-token = false;
            pkgs = self.packages."${system}";
          };

          concession = call ./concession;
        });

      defaultPackage."${system}" = self.packages."${system}".universe-public;
    };
}