summaryrefslogtreecommitdiff
path: root/default.nix
blob: 81e43a7f81e1ae92c7afaf6d43dafb2239ab8537 (plain)
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
{

  hostConfig,

  pkgs ? (import ./pkgs.nix).stable {},

}: let

  recursiveMerge = with pkgs.lib; attrList:
    let f = attrPath:
      zipAttrsWith (n: values:
        if tail values == []
          then head values
        else if all isList values
          then unique (concatLists values)
        else if all isAttrs values
          then f (attrPath ++ [n]) values
        else last values
      );
    in f [] attrList;

  config = recursiveMerge [ (import ./config/default.nix) hostConfig ];

in rec {

  gitConfig = pkgs.stdenv.mkDerivation {
    name = "mediocregopher-git-config";

    gitConfigBase = ./base/gitconfig;
    gitConfigCustom = builtins.toFile "mediocregopher-git-config-custom"
      (pkgs.lib.generators.toGitINI config.git);

    builder = builtins.toFile "builder.sh" ''
      source $stdenv/setup

      dir="$out"/git
      mkdir -p "$dir"

      cp "$gitConfigBase" "$dir"/config
      cp "$gitConfigCustom" "$dir"/custom
    '';

  };

  gitWrapped = pkgs.writeShellScript "git" ''
    export XDG_CONFIG_HOME=${gitConfig}
    exec ${pkgs.git}/bin/git "$@"
  '';

  git = pkgs.runCommand "mediocregopher-git" {} ''
    cp -rL "${pkgs.git}" "$out"
    chmod -R +rwX "$out"
    cp "${gitWrapped}" "$out"/bin/git
  '';

  bin = pkgs.buildEnv {
    name = "mediocregopher-bin";
    paths = [
      (pkgs.runCommand "mediocregopher-default-bin" {} ''
          mkdir -p "$out"
          cp -rL "${./bin}" "$out"/bin
      '')
    ] ++ (
      builtins.map (cFn: cFn pkgs) config.binExtra
    );
  };

  zsh = ((import ./zsh) { inherit config; }).zsh;
  awesome = ((import ./awesome) { inherit config; });

  loadout = pkgs.buildEnv {
    name = "loadout";
    paths = [
      pkgs.dosfstools
      pkgs.hdparm
      pkgs.smartmontools

      pkgs.gnugrep
      pkgs.silver-searcher
      pkgs.gawk
      pkgs.tree
      pkgs.pv
      pkgs.less
      pkgs.tmux
      pkgs.calc
      pkgs.units

      pkgs.strace

      pkgs.man
      pkgs.man-pages
      pkgs.man-pages-posix

      git
      pkgs.mercurial
      pkgs.breezy # bzr
      pkgs.nano
      pkgs.gnumake

      pkgs.curl
      pkgs.wget
      pkgs.rsync

      pkgs.hostname
      pkgs.netcat
      pkgs.nmap
      pkgs.dnsutils
      pkgs.openssh
      pkgs.sshfs
      pkgs.fuse3
      pkgs.usbutils
      pkgs.tcpdump

      pkgs.ncdu
      pkgs.htop
      pkgs.jnettop
      pkgs.iotop

      pkgs.zip
      pkgs.unzip
      pkgs.unrar
      pkgs.gzip

      pkgs.jq
      pkgs.yq
      pkgs.rsbkb

      pkgs.tomb
      pkgs.udiskie

      pkgs.xterm # nice to have a backup
      pkgs.libreoffice
      pkgs.gimp
      pkgs.inkscape
      pkgs.vlc
      pkgs.sylpheed
      pkgs.calibre
      pkgs.lagrange
      pkgs.pavucontrol
      pkgs.xdg-utils
      pkgs.arandr
      pkgs.xsel
      pkgs.xorg.xrandr
      pkgs.wireshark
      pkgs.electrum

      (pkgs.callPackage ./nix/bandcamp-dl.nix {})

      bin
      ((import ./nvim) {}).nvim
      zsh
      ((import ./alacritty) { inherit config zsh; }).alacritty
      ((import ./alacritty) { inherit config zsh; }).alacrittyLight
      awesome.env

      pkgs.nixgl
    ];
  };

  fonts = pkgs.buildEnv {
    name = "fonts";
    paths = [
      pkgs.nerdfonts
      pkgs.source-code-pro
    ];
  };
}