dotfiles

My PC Dotfiles & Website

packages/_module.nix (2330B)


 1## Package Configuration ##
 2{
 3  config,
 4  inputs,
 5  lib,
 6  ...
 7}: let
 8  map = import ../modules/lib/_map.nix lib;
 9  inherit (builtins) any attrValues isPath;
10in {
11  perSystem = {
12    self',
13    system,
14    lib,
15    inputs',
16    pkgs,
17    ...
18  }:
19    rec {
20      _module.args.pkgs = legacyPackages;
21      legacyPackages = with inputs; let
22        nixpkgsConfig = import ./_config.nix;
23      in
24        import (config.flake.patchedPkgs system) {
25          inherit system;
26          config = nixpkgsConfig;
27
28          overlays =
29            (attrValues config.flake.overlays or {})
30            ++ [
31              (final: _: {
32                custom = config.flake.packages."${system}" or {};
33                unstable = import unstable {
34                  inherit system;
35                  config = nixpkgsConfig;
36                };
37
38                disko = disko.packages."${system}";
39                llm = llm.packages."${system}";
40                spicetify = spicetify.legacyPackages."${system}";
41              })
42              minecraft.overlay
43              vscode.overlays.default
44            ];
45        };
46    }
47    // (
48      let
49        call = rec {
50          __functor = _: name: pkg name {};
51          pkg = name: args: pkgs.callPackage name ({inherit lib pkgs;} // {inherit (config) util;} // args);
52          script = name:
53            pkg name {
54              inherit inputs;
55              inherit (config.flake) files;
56            };
57        };
58      in {
59        packages =
60          map.modules ../packages call // map.modules ../scripts call.script // inputs'.proprietary.packages;
61        apps =
62          map.modules ../scripts (
63            name: let
64              drv = call.script name;
65            in {
66              type = "app";
67              program = lib.getExe drv;
68              meta = drv.meta or {};
69            }
70          )
71          // {
72            default = self'.apps.os;
73          };
74      }
75    );
76
77  flake = {
78    patchedPkgs = system: let
79      src = inputs.nixpkgs;
80      patches = map.patches ./patches;
81      pkgs' = import src {inherit system;};
82    in
83      if !(any isPath patches)
84      then src
85      else
86        pkgs'.applyPatches {
87          inherit src patches;
88          name = "nixpkgs-patched-${src.shortRev}";
89        };
90
91    overlays = map.modules ./overlays import;
92  };
93}