summaryrefslogtreecommitdiff
path: root/nix_archive/flake.nix
blob: ca1992f729e2355f0c077e07f8739fcdf8591610 (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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
{
  inputs = {
    nixpkgs = {
      url = "github:NixOS/nixpkgs/nixos-unstable";
    };
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    nixos-hardware = {
      url = "github:NixOS/nixos-hardware/master";
    };
    nur = {
      url = "github:nix-community/NUR";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    #chaotic = {
    #  url = "github:chaotic-cx/nyx/nyxpkgs-unstable";
    #};
    camu = {
      url = "git+https://git.akon.city/camu";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.home-manager.follows = "home-manager";
      inputs.nixos-hardware.follows = "nixos-hardware";
    };
    mauri = {
      url = "git+https://git.akon.city/mauri";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, nixos-hardware, home-manager, nur, camu, mauri }: let
    local-fonts = {
      name = "Local Fonts";
      src = ./../files/fonts;
      installPhase = ''
        mkdir -p $out/share/fonts/local
        cp * $out/share/fonts/local
      '';
    };
    optimizeWithFlags = (pkg: flags:
      pkg.overrideAttrs (oldAttrs: {
        env.NIX_CFLAGS_COMPILE = (oldAttrs.env.NIX_CFLAGS_COMPILE or "") + " ${flags}";
      })
    );
  in {
    settingsModule = { lib, ... }:
      with lib;
      let
        fontSettings = types.submodule {
          options = {
            name = mkOption { type = types.str; };
            size = mkOption { type = types.int; };
            baseline = mkOption { type = types.int; };
            cell-height-offset = mkOption { type = types.int; };
          };
        };
        scriptSettings = types.submodule {
          options = {
            imports = mkOption { type = types.listOf types.str; };
          };
        };
        themeSettings = types.submodule {
          options = {
            lightness = mkOption { type = types.str; }; # light/dark
            background = mkOption { type = types.str; };
            background-alt = mkOption { type = types.str; }; # solid color wallpaper
            foreground = mkOption { type = types.str; };
            # bright black and white should be different from black and white.
            color0 = mkOption { type = types.str; }; # black
            color1 = mkOption { type = types.str; }; # red
            color2 = mkOption { type = types.str; }; # green
            color3 = mkOption { type = types.str; }; # yellow
            color4 = mkOption { type = types.str; }; # blue
            color5 = mkOption { type = types.str; }; # magenta
            color6 = mkOption { type = types.str; }; # cyan
            color7 = mkOption { type = types.str; }; # white
            color8 = mkOption { type = types.str; }; # bright black
            color9 = mkOption { type = types.str; }; # bright red
            color10 = mkOption { type = types.str; }; # bright green
            color11 = mkOption { type = types.str; }; # bright yellow
            color12 = mkOption { type = types.str; }; # bright blue
            color13 = mkOption { type = types.str; }; # bright magenta
            color14 = mkOption { type = types.str; }; # bright cyan
            color15 = mkOption { type = types.str; }; # bright white
            alpha = mkOption { type = types.float; };
          };
        };
        starterPadSettings = types.submodule {
          options = {
            left = mkOption { type = types.int; };
            top = mkOption { type = types.int; };
            text = mkOption { type = types.int; };
          };
        };
        starterSettings = types.submodule {
          options = {
            top_padding = mkOption { type = types.int; };
            picture = mkOption { type = types.path; };
            width = mkOption { type = types.int; };
            padding = mkOption { type = starterPadSettings; };
            position = mkOption { type = types.str; };
            header = mkOption { type = types.str; };
            footer = mkOption { type = types.str; };
            footer-offset = mkOption { type = types.int; };
          };
        };
        monitorSettings = types.submodule {
          options = {
            monitor1 = mkOption { type = types.str; };
            monitor2 = mkOption { type = types.str; };
            monitor3 = mkOption { type = types.str; };
          };
        };
    in {
      options.local = {
        font = mkOption { type = fontSettings; };
        ui-font = mkOption { type = fontSettings; };
        emoji-font = mkOption { type = fontSettings; };
        scripts = mkOption { type = scriptSettings; };
        scheme = mkOption { type = themeSettings; };
        starter = mkOption { type = starterSettings; };
        monitors = mkOption { type = monitorSettings; };
      };
    };

    nixosConfigurations.sofue = let
      system = "x86_64-linux";
      source-pkgs = nixpkgs.legacyPackages.${system};
      nixpkgs-patched = source-pkgs.applyPatches {
        name = "nixpkgs-patched";
        src = nixpkgs;
        patches = [];
      };
      nixosSystem = import (nixpkgs-patched + "/nixos/lib/eval-config.nix");
    in nixosSystem {
      system = system;
      modules = [
        self.settingsModule
        ({ lib, ... }: { nixpkgs.overlays = [
          nur.overlays.default
          (self: super: {
            asNeeded = (pkg: commands:
              (lib.lists.forEach commands (command: super.writeShellScriptBin "${command}" ''
                install-as-needed "${pkg}" ${command} "$@"
              ''))
            );
          })
          (self: super: { local-fonts = super.stdenv.mkDerivation local-fonts; })
          (self: super: {
            camu = camu.packages.${system}.default;
            camu-devshell = camu.packages.${system}.shellWrapper;
          })
          (self: super: { mauri = mauri.packages.${system}.default; })
          (self: super: {
            mpv-unwrapped = super.mpv-unwrapped.override { cddaSupport = true; };
          })
          (self: super: {
            mesa = (optimizeWithFlags super.mesa "-O3 -march=znver2 -mtune=znver2 -fno-semantic-interposition").overrideAttrs (oldAttrs: {
              patches = oldAttrs.patches ++ [
              ];
            });
          })
          (self: super: {
            mesa_git = (optimizeWithFlags super.mesa_git "-O3 -march=znver2 -mtune=znver2 -fno-semantic-interposition").overrideAttrs (oldAttrs: {
              patches = oldAttrs.patches ++ [
              ];
            });
          })
          (self: super: {
            kitty = (optimizeWithFlags super.kitty "-O3 -march=znver2 -mtune=znver2 -fno-semantic-interposition").overrideAttrs (oldAttrs: {
              patches = oldAttrs.patches ++ [
              ];
            });
          })
          (self: super: {
            adw-gtk3 = super.adw-gtk3.overrideAttrs (oldAttrs: {
              patches = [
                ../files/patches/adw-gtk3-non-blue-accent.diff
              ];
            });
          })
          (self: super: {
            neovim-unwrapped = (optimizeWithFlags super.neovim-unwrapped "-O3 -march=znver2 -mtune=znver2 -fno-semantic-interposition -flto");
          })
          (self: super: {
            gamescope = super.gamescope.overrideAttrs (oldAttrs: {
              patches = oldAttrs.patches ++ [
                ./files/gamescope_1826.diff
              ];
            });
          })
          #(self: super: {
          #  sway-unwrapped = super.sway-unwrapped.overrideAttrs (oldAttrs: {
          #    patches = oldAttrs.patches ++ [
          #      ./files/sway_background_covered.diff
          #    ];
          #  });
          #})
          (self: super: {
            python = super.python.override ({
              packageOverrides = (python-self: python-super: {
              });
            });
          })
          (self: super: {
            vimPlugins = super.vimPlugins.extend (final: prev: {
              mini-nvim = prev.mini-nvim.overrideAttrs (oldAttrs: {
                patches = [
                  ./files/nvim/mini_starter_picture.diff
                  ./files/nvim/mini_completion_no_title.diff
                ];
              });
              fzf-vim = prev.fzf-vim.overrideAttrs (oldAttrs: {
                patches = [
                  ./files/nvim/fzf_no_linenum.diff
                ];
              });
            });
          })
          (self: super: {
            dia = super.dia.overrideAttrs (oldAttrs: {
              nativeBuildInputs = with super; [
                gobject-introspection
                python3.pkgs.wrapPython
              ] ++ old.nativeBuildInputs;
              pythonPath = with super.python3.pkgs; [ pygobject3 ];
              # https://github.com/NixOS/nixpkgs/pull/273060/files#diff-b78e5b1234a71c390023923ab5e62fc67b8e7d4371bc6687b7c7de4f392d1facR56
              postFixup = ''
                buildPythonPath "$pythonPath"
                patchPythonScript $out/share/dia/python/scascale.py
              '';
            });
          })
        ];})
        home-manager.nixosModules.home-manager {
          home-manager.useGlobalPkgs = true;
          home-manager.useUserPackages = true;
        }
        nur.modules.nixos.default
        #chaotic.nixosModules.default
        ./hosts/sofue/configuration.nix
      ];
    };

    nixosConfigurations.palm = let
      system = "x86_64-linux";
      source-pkgs = nixpkgs.legacyPackages.${system};
      nixpkgs-patched = source-pkgs.applyPatches {
        name = "nixpkgs-patched";
        src = nixpkgs;
        patches = [];
      };
      nixosSystem = import (nixpkgs-patched + "/nixos/lib/eval-config.nix");
    in nixosSystem {
      system = system;
      modules = [
        self.settingsModule
        ({ lib, ... }: { nixpkgs.overlays = [
          nur.overlays.default
          (self: super: {
            asNeeded = (pkg: commands:
              (lib.lists.forEach commands (command: super.writeShellScriptBin "${command}" ''
                install-as-needed "${pkg}" ${command} ''$@
              ''))
            );
          })
          (self: super: { local-fonts = super.stdenv.mkDerivation local-fonts; })
          (self: super: {
            camu = camu.packages.${system}.default;
            camu-devshell = camu.packages.${system}.shellWrapper;
          })
          (self: super: { mauri = mauri.packages.${system}.default; })
          #(self: super: {
          #  sway-unwrapped = super.sway-unwrapped.overrideAttrs (oldAttrs: {
          #    patches = oldAttrs.patches ++ [];
          #  });
          #})
          (self: super: {
            adw-gtk3 = super.adw-gtk3.overrideAttrs (oldAttrs: {
              patches = [
                ../files/patches/adw-gtk3-non-blue-accent.diff
              ];
            });
          })
          (self: super: {
            vimPlugins = super.vimPlugins.extend (final: prev: {
              mini-nvim = prev.mini-nvim.overrideAttrs (oldAttrs: {
                patches = [
                  ./files/nvim/mini_starter_picture.diff
                  ./files/nvim/mini_completion_no_title.diff
                ];
              });
              fzf-vim = prev.fzf-vim.overrideAttrs (oldAttrs: {
                patches = [
                  ./files/nvim/fzf_no_linenum.diff
                ];
              });
            });
          })
   	    ];})
        home-manager.nixosModules.home-manager {
          home-manager.useGlobalPkgs = true;
          home-manager.useUserPackages = true;
        }
        nur.modules.nixos.default
        nixos-hardware.nixosModules.common-pc-laptop
        nixos-hardware.nixosModules.common-pc-laptop-ssd
        nixos-hardware.nixosModules.common-cpu-intel
        nixos-hardware.nixosModules.common-gpu-nvidia-disable
        nixos-hardware.nixosModules.common-gpu-intel-kaby-lake
        ./hosts/palm/configuration.nix
      ];
    };

    nixosConfigurations.the-p = let
      system = "x86_64-linux";
      source-pkgs = nixpkgs.legacyPackages.${system};
      nixpkgs-patched = source-pkgs.applyPatches {
        name = "nixpkgs-patched";
        src = nixpkgs;
        patches = [ ];
      };
      nixosSystem = import (nixpkgs-patched + "/nixos/lib/eval-config.nix");
    in nixosSystem {
      system = system;
      modules = [
        ({ ... }: { nixpkgs.overlays = [
          #(self: super: { jdk21 = (optimizeWithFlags super.jdk21 "-O2 -march=znver1 -mtune=znver1 -fno-semantic-interposition -flto"); })
        ]; })
        ./hosts/moyo/container.nix
      ];
    };
  };
}