~kaction/config

ref: 569cada1bc5709b76d4fd05eb2696044ad68c338 config/flake.nix -rw-r--r-- 6.5 KiB
569cada1 — Dmitry Bogatov Configure email fetching 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# 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 = "github:nixos/nixpkgs";

  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 { };
          rebuild = path: rec {
            name = builtins.baseNameOf path;
            value = callPackage path { "${name}" = pkgs."${name}"; };
          };

          rebuilded = builtins.listToAttrs (map rebuild [
            ./universe/busybox
            ./universe/curl
            ./universe/gdb
            ./universe/gnupg
            ./universe/groff
            ./universe/htop
            ./universe/kpcli
            ./universe/less
            ./universe/libarchive
            ./universe/libusb1
            ./universe/mpop
            ./universe/msmtp
            ./universe/newsboat
            ./universe/openssh
            ./universe/pass
            ./universe/python3
            ./universe/rename
            ./universe/rsync
            ./universe/strace
            ./universe/surfraw
            ./universe/tig
            ./universe/vim
            ./universe/w3m
          ]);
        in pkgs // pristine // rebuilded // { # nixfmt: sort
          inherit system;

          Documentation =
            callPackage ./universe/Documentation { inherit nixpkgs; };
          attach-shell = call ./universe/attach-shell;
          blurdate = callPackage ./universe/blurdate { };
          diohsc = call ./universe/diohsc;
          dvtm = call ./universe/dvtm;
          dhall-latest = call ./universe/dhall-latest;

          font-psf = call ./universe/font-psf;
          fasm-arch = call ./universe/fasm-arch;
          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;
          };
          githooks = call ./universe/githooks;
          nix = callPackage ./universe/nix { nix = pkgs.nixFlakes; };
          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;
          tempfile = call ./universe/tempfile;
          uenv = call ./universe/uenv;
        });
      defaultPackage."${system}" = with self.packages."${system}";
        let
          inherit (pkgs.lib) isDerivation filterAttrs attrValues;
          outputs = drv:
            [ drv ] ++ attrValues (filterAttrs (_: isDerivation) drv);
          evil = [ systemd pam kerberos dbus coreutils man acl attr libusb1 ];
          banished = builtins.concatLists (map outputs evil);
          drv = buildEnv {
            name = "universe-13";
            paths = [
              Documentation
              acpi # Check battery status
              attach-shell
              bmake # Not GNU Make, to learn about Make portability
              busybox # simpler than coreutils
              curl
              diohsc
              dvtm
              dhall-latest.dhall
              dhall-latest.dhall-bash
              dhall-latest.dhall-docs
              dhall-latest.dhall-json
              dhall-latest.dhall-yaml
              dhall-latest.dhall-lsp-server
              dhall-latest.dhall-nixpkgs
              fasm
              fasm-arch
              file # This is part of base system.
              gdb
              git
              git-bug
              gitAndTools.hub
              gnupg
              groff
              kpcli
              htop
              jq # json dominated web, and it is probably good
              less
              man-pages # syscall and libc library reference.
              msmtp
              mpop
              newsboat
              nix # unstable Nix with flakes support
              nixfmt
              nnn # file manager for poorly named files
              openssh
              par # Like fmt(1), but better.
              pass
              posix_man_pages # busybox does not provide manpages
              postgresql_10.doc # My ${dayjob} uses Postgres-10
              postgresql_10.man
              psql # client-only
              pstree # overview of processes running on the system.
              python3.pkgs.trezor
              python3.pkgs.trezor_agent
              python3.pkgs.md2gemini
              rename # mass rename of files
              reuse # automatic management of copyright headers.
              rsync
              srht-ui
              strace # When things break, and they break all the time.
              surfraw
              tig
              tree # Useful to inspect result of Nix derivation build
              trezord
              uenv
              urlview # open links in email
              vim
              w3m # Web-browser that supports tables
            ];
          };
        in drv.overrideAttrs (_: { disallowedRequisites = banished; });
    };
}