Skip to content

Commit 0007710

Browse files
committed
refactor: separate out individual overlays
1 parent 2a481b6 commit 0007710

File tree

9 files changed

+423
-402
lines changed

9 files changed

+423
-402
lines changed

flake.nix

Lines changed: 3 additions & 391 deletions
Large diffs are not rendered by default.

overlays/default.nix

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
1-
self: super: rec {
2-
# deepfry = super.callPackage ./deepfry { };
3-
#imagemagick = super.callPackage ./imagemagick { };
4-
/*firefox = super.callPackage ./firefox {}*/
5-
/*unchromium = super.callPackage ./unchromium {};*/
6-
# trezor-suite = super.callPackage ./trezor-suite { };
7-
#FIXME
8-
#nix-extract-revs-from-cache = super.callPackage ./nix-extract-revs-from-cache { };
1+
# Overlay aggregator
2+
# Usage in flake.nix:
3+
# overlays = import ./overlays { inherit inputs; }
4+
{ inputs }:
5+
let
6+
# Simple overlays that don't need inputs
7+
stdenv = import ./stdenv.nix;
8+
haskell = import ./haskell.nix;
9+
zig = import ./zig.nix;
10+
rust = import ./rust.nix;
11+
python = import ./python.nix;
12+
packages = import ./packages.nix;
913

10-
/*nixFlakes = super.callPackage ./nixFlakes { };*/
11-
#vendor-reset = super.callPackage ./vendor-reset { kernel = super.linuxPackages_5_10.kernel; };
12-
}
14+
# Overlays that need flake inputs
15+
external = import ./external.nix {
16+
inherit (inputs) nix my-nvim nixpkgs-master;
17+
};
18+
in
19+
[
20+
# Order matters: stdenv should be first since other overlays depend on it
21+
stdenv
22+
haskell
23+
zig
24+
rust
25+
python
26+
packages
27+
external
28+
]

overlays/external.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# External packages from other inputs
2+
# This overlay requires inputs to be passed in via a factory function
3+
{ nix, my-nvim, nixpkgs-master }:
4+
final: prev: {
5+
nix = nix.packages.x86_64-linux.default;
6+
nvim = my-nvim.defaultPackage.x86_64-linux;
7+
# TODO fix this -- it's very broken and IDK why
8+
influxdb2 = nixpkgs-master.legacyPackages.x86_64-linux.influxdb2;
9+
}

overlays/haskell.nix

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Haskell-related overlays
2+
# - CPU-specific optimizations for znver3
3+
# - Package-specific fixes
4+
final: prev:
5+
let
6+
inherit (final) lib;
7+
makeGhcOptions = opts: lib.concatStringsSep " " (map (opt: "--ghc-option=${opt}") opts);
8+
in
9+
{
10+
haskell = prev.haskell // {
11+
packageOverrides =
12+
hfinal: hprev:
13+
prev.lib.composeExtensions (prev.haskell.packageOverrides or (_: _: { })) (hfinal: hprev: {
14+
mkDerivation =
15+
args:
16+
hprev.mkDerivation (
17+
args
18+
// {
19+
configureFlags = (args.configureFlags or [ ]) ++ [
20+
(makeGhcOptions [
21+
# "-fllvm"
22+
"-optc=-march=znver3"
23+
"-optlo=-mcpu=znver3"
24+
"-O2"
25+
])
26+
];
27+
# GHC uses ld.gold which doesn't support pack-relative-relocs
28+
# Must run before compileBuildDriverPhase which compiles Setup.hs
29+
preCompileBuildDriver = (args.preCompileBuildDriver or "") + ''
30+
export NIX_CFLAGS_LINK="''${NIX_CFLAGS_LINK//-Wl,-z,pack-relative-relocs/}"
31+
'';
32+
}
33+
);
34+
}) hfinal hprev;
35+
};
36+
37+
haskellPackages = prev.haskellPackages.extend (
38+
hself: hsuper: {
39+
xmobar = final.haskell.lib.compose.overrideCabal (drv: {
40+
enableSeparateBinOutput = false;
41+
}) hsuper.xmobar;
42+
cachix = final.haskell.lib.compose.overrideCabal (drv: {
43+
enableSeparateBinOutput = false;
44+
}) hsuper.cachix;
45+
yaml = final.haskell.lib.compose.overrideCabal (drv: {
46+
enableSeparateBinOutput = false;
47+
}) hsuper.yaml;
48+
}
49+
);
50+
51+
xmobar = final.haskellPackages.xmobar;
52+
}

overlays/packages.nix

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Individual package overrides and custom packages
2+
final: prev: {
3+
prometheus-node-exporter = prev.prometheus-node-exporter.overrideAttrs (oldAttrs: {
4+
src = prev.fetchFromGitHub {
5+
owner = "prometheus";
6+
repo = "node_exporter";
7+
tag = "v${oldAttrs.version}";
8+
hash = "sha256-UaybbRmcvifXNwTNXg7mIYN9JnonSxwG62KfvU5auIE=";
9+
};
10+
});
11+
12+
pam-insults = final.stdenv.mkDerivation {
13+
pname = "pam-insults";
14+
version = "unstable-2025-12-19";
15+
16+
src = final.fetchFromGitHub {
17+
owner = "cgoesche";
18+
repo = "pam-insults";
19+
rev = "2d13ef89640eb57b5e6a64eea080e57d9d936738";
20+
hash = "sha256-VbEJCO7lvTDKvGpTXQrpgeWEpZE4CMdwaRSuv5shsbw=";
21+
};
22+
23+
nativeBuildInputs = [
24+
final.asciidoctor
25+
final.gzip
26+
];
27+
28+
buildInputs = [
29+
final.pam
30+
final.gettext
31+
];
32+
33+
postPatch = ''
34+
substituteInPlace Makefile \
35+
--replace-fail "sudo " "" \
36+
--replace-fail "mandb" ""
37+
'';
38+
39+
makeFlags = [
40+
"PAM_MODULES_DIR=$(out)/lib/security"
41+
"MAN_DATABASE=$(out)/share/man/man8"
42+
];
43+
44+
preInstall = ''
45+
mkdir -p $out/lib/security $out/share/man/man8
46+
'';
47+
48+
meta = with final.lib; {
49+
description = "PAM module that will print an insult to stderr";
50+
homepage = "https://github.com/cgoesche/pam-insults";
51+
license = licenses.gpl3Plus;
52+
platforms = platforms.linux;
53+
};
54+
};
55+
56+
nototools = prev.nototools.overridePythonAttrs (old: {
57+
dontCheckRuntimeDeps = true;
58+
catchConflicts = false;
59+
});
60+
61+
libp11 = prev.libp11.overrideAttrs (oldAttrs: {
62+
src = prev.fetchFromGitHub {
63+
owner = "OpenSC";
64+
repo = "libp11";
65+
rev = "${prev.libp11.pname}-${prev.libp11.version}";
66+
sha256 = "sha256-xH5Ic8HpWB5O2MWXf2A9FUiV10VZajDdPqEVF0Hs6u0=";
67+
};
68+
});
69+
70+
libkate = prev.libkate.overrideAttrs (old: {
71+
src = final.fetchFromGitLab {
72+
domain = "gitlab.xiph.org";
73+
owner = "xiph";
74+
repo = "kate";
75+
rev = "kate-0.4.3";
76+
hash = "sha256-HwDahmjDC+O321Ba7MnHoQdHOFUMpFzaNdLHQeEg11Q=";
77+
};
78+
});
79+
80+
opencv = prev.opencv.overrideAttrs (old: {
81+
postUnpack =
82+
builtins.replaceStrings
83+
[ "$NIX_BUILD_TOP/source/opencv_contrib" ]
84+
[ "$NIX_BUILD_TOP/${old.src.name}/opencv_contrib" ]
85+
old.postUnpack;
86+
preConfigure =
87+
builtins.replaceStrings
88+
[ "$NIX_BUILD_TOP/source/opencv_contrib" ]
89+
[ "$NIX_BUILD_TOP/${old.src.name}/opencv_contrib" ]
90+
old.preConfigure;
91+
});
92+
93+
usbmuxd2 = prev.usbmuxd2.overrideAttrs (oldAttrs: {
94+
src = prev.fetchFromGitHub {
95+
owner = "tihmstar";
96+
repo = "usbmuxd2";
97+
rev = "2ce399ddbacb110bd5a83a6b8232d42c9a9b6e84";
98+
hash = "sha256-u7qRKH5y+Q1HnnumjVm3Ce4SlT3YaEVSPUXYOAiFBes=";
99+
leaveDotGit = true;
100+
};
101+
});
102+
103+
# Fix dcgm-exporter to find ldconfig in PATH instead of hardcoded /sbin/ldconfig
104+
prometheus-dcgm-exporter = prev.prometheus-dcgm-exporter.overrideAttrs (oldAttrs: {
105+
patches = (oldAttrs.patches or [ ]) ++ [ ../patches/dcgm-exporter-fix-ldconfig.patch ];
106+
postInstall = (oldAttrs.postInstall or "") + ''
107+
mkdir -p $out/etc
108+
cp $src/etc/*.csv $out/etc/
109+
'';
110+
});
111+
}

overlays/python.nix

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Python package overlays
2+
# - Disable checks for faster builds
3+
# - Fix broken packages
4+
final: prev: {
5+
pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [
6+
(python-final: python-prev: {
7+
# Python packages don't go through our stdenv overlay, so add the phase here
8+
disableCheckArgs =
9+
args:
10+
let
11+
existingPrePhases = args.prePhases or [ ];
12+
in
13+
args
14+
// {
15+
prePhases =
16+
if builtins.elem "disableChecksPhase" existingPrePhases then
17+
existingPrePhases
18+
else
19+
existingPrePhases ++ [ "disableChecksPhase" ];
20+
disableChecksPhase = ''
21+
unset doCheck
22+
unset doInstallCheck
23+
# Override Python-specific check phases to be no-ops
24+
pytestCheckPhase() { :; }
25+
pythonImportsCheckPhase() { :; }
26+
'';
27+
};
28+
29+
buildPythonPackage = python-prev.buildPythonPackage // {
30+
__functor = self: args: python-prev.buildPythonPackage (python-final.disableCheckArgs args);
31+
};
32+
buildPythonApplication = python-prev.buildPythonApplication // {
33+
__functor = self: args: python-prev.buildPythonApplication (python-final.disableCheckArgs args);
34+
};
35+
36+
# Package-specific fixes
37+
psycopg = python-prev.psycopg.overridePythonAttrs (oldAttrs: {
38+
propagatedBuildInputs = (oldAttrs.propagatedBuildInputs or [ ]) ++ [ python-final.psycopg-pool ];
39+
});
40+
41+
mutatormath = python-prev.mutatormath.overridePythonAttrs (old: {
42+
catchConflicts = false;
43+
});
44+
45+
jeepney = python-prev.jeepney.overridePythonAttrs (old: {
46+
pythonImportsCheck = [ "jeepney" ];
47+
});
48+
49+
fontparts = python-prev.fontparts.overridePythonAttrs (old: {
50+
catchConflicts = false;
51+
dontCheckRuntimeDeps = true;
52+
});
53+
54+
ufoprocessor = python-prev.ufoprocessor.overridePythonAttrs (old: {
55+
catchConflicts = false;
56+
dontCheckRuntimeDeps = true;
57+
});
58+
59+
afdko = python-prev.afdko.overridePythonAttrs (old: {
60+
dontCheckRuntimeDeps = true;
61+
catchConflicts = false;
62+
});
63+
64+
img2pdf = python-prev.img2pdf.overridePythonAttrs (old: {
65+
src = final.fetchFromGitHub {
66+
owner = "josch";
67+
repo = "img2pdf";
68+
rev = "0.6.1";
69+
hash = "sha256-71u6ex+UAEFPDtR9QI8Ezah5zCorn4gMdAnzFz4blsI=";
70+
};
71+
});
72+
73+
pyasn = python-prev.pyasn.overridePythonAttrs (old: {
74+
datasrc = old.datasrc.override {
75+
hash = "sha256-7zpaxDe5qHUy/ekOJLxKawjaPQnByrOVj+m2bsUqfdg=";
76+
};
77+
});
78+
79+
debugpy = python-prev.debugpy.overrideAttrs (oldAttrs: {
80+
src = oldAttrs.src.override {
81+
hash = "sha256-eAiCtSJUqLASapxnYCyq1UCiGz6QmKQum7Vs3MoU1s8=";
82+
};
83+
});
84+
85+
instructor = python-prev.instructor.overridePythonAttrs (old: {
86+
src = final.fetchFromGitHub {
87+
owner = "jxnl";
88+
repo = "instructor";
89+
tag = "v1.11.3";
90+
hash = "sha256-VWFrMgfe92bHUK1hueqJLHQ7G7ATCgK7wXr+eqrVWcw=";
91+
};
92+
});
93+
94+
pypng = python-prev.pypng.overridePythonAttrs (old: {
95+
src = final.fetchFromGitLab {
96+
owner = "drj11";
97+
repo = "pypng";
98+
tag = "pypng-0.20231004.0";
99+
hash = "sha256-xNUI3yGfwmaccCxgljIZzgJ6YgNxcuOzCXDE7RFJP2I=";
100+
};
101+
});
102+
103+
rank-bm25 = python-prev.rank-bm25.overridePythonAttrs (old: {
104+
src = final.fetchFromGitHub {
105+
owner = "dorianbrown";
106+
repo = "rank_bm25";
107+
tag = old.version;
108+
hash = "sha256-+BxQBflMm2AvCLAFFj52Jpkqn+KErwYXU1wztintgOg=";
109+
};
110+
});
111+
112+
# Fix 404 error for 0.42.2 - pin to 0.41.2
113+
sqlalchemy-utils = python-prev.sqlalchemy-utils.overridePythonAttrs (old: rec {
114+
version = "0.41.2";
115+
src = final.fetchFromGitHub {
116+
owner = "kvesteri";
117+
repo = "sqlalchemy-utils";
118+
rev = version;
119+
hash = "sha256-jC8onlCiuzpMlJ3EzpzCnQ128xpkLzrZEuGWQv7pvVE=";
120+
};
121+
});
122+
123+
# Fix opencv source directory name issue
124+
opencv4 = python-prev.opencv4.overrideAttrs (old: {
125+
postUnpack =
126+
builtins.replaceStrings
127+
[ "$NIX_BUILD_TOP/source/opencv_contrib" ]
128+
[ "$NIX_BUILD_TOP/${old.src.name}/opencv_contrib" ]
129+
old.postUnpack;
130+
preConfigure =
131+
builtins.replaceStrings
132+
[ "$NIX_BUILD_TOP/source/opencv_contrib" ]
133+
[ "$NIX_BUILD_TOP/${old.src.name}/opencv_contrib" ]
134+
old.preConfigure;
135+
});
136+
})
137+
];
138+
}

overlays/rust.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Rust platform overlay with znver3 CPU targeting
2+
final: prev: {
3+
makeRustPlatform =
4+
args:
5+
prev.callPackage "${prev.path}/pkgs/development/compilers/rust/make-rust-platform.nix" {
6+
GLOBAL_RUSTFLAGS = "-C target-cpu=znver3";
7+
} args;
8+
}

0 commit comments

Comments
 (0)