Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
8792f1132d |
22
flake.nix
22
flake.nix
|
@ -93,13 +93,20 @@
|
|||
};
|
||||
|
||||
overlays = load ./overlay "overlay";
|
||||
legacyPackages = eachSystem (system: platform:
|
||||
import nixpkgs {
|
||||
localSystem = builtins.currentSystem or platform;
|
||||
legacyPackages = eachSystem (system: platform: let
|
||||
pkgs = import nixpkgs {
|
||||
localSystem = builtins.currentSystem or system;
|
||||
crossSystem = platform;
|
||||
overlays = [ self.overlays.default ];
|
||||
config.allowUnsupportedSystem = true;
|
||||
});
|
||||
};
|
||||
in pkgs // {
|
||||
config = pkgs.config // {
|
||||
replaceStdenv = { pkgs }: self.lib.stdenv pkgs pkgs.stdenv;
|
||||
replaceCrossStdenv = { buildPackages, baseStdenv }:
|
||||
self.lib.stdenv self.legacyPackages.${system} baseStdenv;
|
||||
};
|
||||
});
|
||||
|
||||
packages = eachSystem (system: platform:
|
||||
let pkgs = self.legacyPackages.${system};
|
||||
|
@ -120,6 +127,13 @@
|
|||
targetHost = config.networking.fqdnOrHostName;
|
||||
targetUser = null;
|
||||
};
|
||||
|
||||
nixpkgs = let
|
||||
platform = self.lib.platforms.x86_64-linux;
|
||||
in {
|
||||
buildPlatform = builtins.currentSystem or platform.system;
|
||||
hostPlatform = platform;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -4,13 +4,25 @@ let inherit (nixpkgs) lib;
|
|||
in lib.mapAttrs (system: platform: lib.systems.elaborate platform) {
|
||||
"x86_64-linux" = {
|
||||
system = "x86_64-linux";
|
||||
config = "x86_64-unknown-linux-musl";
|
||||
useLLVM = true;
|
||||
linker = "lld";
|
||||
gcc.arch = "x86-64-v3";
|
||||
};
|
||||
|
||||
"aarch64-linux" = {
|
||||
system = "aarch64-linux";
|
||||
config = "aarch64-unknown-linux-musl";
|
||||
useLLVM = true;
|
||||
linker = "lld";
|
||||
gcc.arch = "armv8-a";
|
||||
};
|
||||
|
||||
"riscv64-linux" = {
|
||||
system = "riscv64-linux";
|
||||
config = "riscv64-unknown-linux-musl";
|
||||
useLLVM = true;
|
||||
linker = "lld";
|
||||
gcc.arch = "rv64imacfd";
|
||||
};
|
||||
}
|
||||
|
|
42
lib/stdenv.nix
Normal file
42
lib/stdenv.nix
Normal file
|
@ -0,0 +1,42 @@
|
|||
{ ... }: pkgs: stdenv:
|
||||
|
||||
let
|
||||
inherit (lib) optionalAttrs optionals toList;
|
||||
inherit (pkgs) lib;
|
||||
inherit (stdenv) targetPlatform;
|
||||
in pkgs.addAttrsToDerivation (prevAttrs: let
|
||||
overrideAlloc = prevAttrs.overrideAlloc or true;
|
||||
|
||||
inputs = optionals overrideAlloc [ pkgs.mimalloc ];
|
||||
|
||||
cflags = [ "-pipe" ];
|
||||
ldflags = [
|
||||
"-O2"
|
||||
"--hash-style=gnu"
|
||||
] ++ optionals overrideAlloc [ "-lmimalloc" ];
|
||||
|
||||
rustflags = [
|
||||
"-C" "opt-level=2"
|
||||
"-C" "linker-flavor=ld.lld"
|
||||
"-C" "lto"
|
||||
"-C" "linker-plugin-lto"
|
||||
"-C" "link-arg=--icf=safe"
|
||||
"-C" "link-arg=--lto-O2"
|
||||
] ++ optionals (targetPlatform.isx86_64 && targetPlatform ? gcc.arch) [
|
||||
"-C" "target-cpu=${targetPlatform.gcc.arch}"
|
||||
] ++ (map (flag: [ "-C" "link-arg=${flag}" ]) ldflags |> lib.flatten);
|
||||
in {
|
||||
buildInputs = prevAttrs.buildInputs or [ ] ++ inputs;
|
||||
|
||||
env = prevAttrs.env or { } // optionalAttrs (!prevAttrs ? NIX_CFLAGS_COMPILE) {
|
||||
NIX_CFLAGS_COMPILE = toList prevAttrs.env.NIX_CFLAGS_COMPILE or [ ] ++ cflags |> toString;
|
||||
} // optionalAttrs (prevAttrs ? env.NIX_LDFLAGS) {
|
||||
NIX_LDFLAGS = toList prevAttrs.NIX_LDFLAGS or [ ] ++ ldflags |> toString;
|
||||
};
|
||||
|
||||
NIX_RUSTFLAGS = prevAttrs.NIX_RUSTFLAGS or [ ] ++ rustflags;
|
||||
} // optionalAttrs (prevAttrs ? NIX_CFLAGS_COMPILE) {
|
||||
NIX_CFLAGS_COMPILE = toList prevAttrs.NIX_CFLAGS_COMPILE or [ ] ++ cflags;
|
||||
} // optionalAttrs (!prevAttrs ? env.NIX_LDFLAGS) {
|
||||
NIX_LDFLAGS = toList prevAttrs.NIX_LDFLAGS or [ ] ++ ldflags;
|
||||
}) stdenv
|
|
@ -11,6 +11,7 @@
|
|||
iosched
|
||||
kernel
|
||||
locale-en_EU
|
||||
musl
|
||||
network
|
||||
nix
|
||||
openssh
|
||||
|
|
7
nixos/module/musl.nix
Normal file
7
nixos/module/musl.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{ ...}: { modulesPath, ... }: {
|
||||
disabledModules = [
|
||||
(modulesPath + "/config/ldso.nix")
|
||||
(modulesPath + "/programs/nix-ld.nix")
|
||||
(modulesPath + "/config/stub-ld.nix")
|
||||
];
|
||||
}
|
|
@ -4,6 +4,14 @@ let
|
|||
inherit (lib) toList;
|
||||
inherit (prev.stdenv) hostPlatform;
|
||||
in {
|
||||
netbsd = prev.netbsd.overrideScope (final: prev: {
|
||||
compatIfNeeded = [ final.compat ];
|
||||
|
||||
compat = prev.compat.overrideAttrs (prevAttrs: {
|
||||
makeFlags = prevAttrs.makeFlags ++ [ "OBJCOPY=:" ];
|
||||
});
|
||||
});
|
||||
|
||||
numactl = prev.numactl.overrideAttrs (prevAttrs: {
|
||||
patches = prevAttrs.patches or [ ] ++ [
|
||||
(final.fetchpatch {
|
||||
|
@ -13,19 +21,21 @@ in {
|
|||
];
|
||||
});
|
||||
|
||||
python3 = prev.python3.overrideAttrs (prevAttrs: {
|
||||
postFixup = let
|
||||
lib = "$out/lib/${prevAttrs.passthru.libPrefix}";
|
||||
prefix = "_sysconfigdata__linux_";
|
||||
suffix = "${hostPlatform.parsed.cpu.name}-${hostPlatform.libc}";
|
||||
in prevAttrs.postFixup + ''
|
||||
test -e "${lib}/${prefix}${suffix}.py" \
|
||||
|| ln -s "${lib}/${prefix}"{,"${suffix}"}.py
|
||||
'';
|
||||
});
|
||||
|
||||
redis = prev.redis.overrideAttrs {
|
||||
doCheck = false;
|
||||
};
|
||||
|
||||
python312 = prev.python312.override {
|
||||
packageOverrides = final: prev: {
|
||||
pywebview = prev.pywebview.overrideAttrs ({
|
||||
doCheck = false;
|
||||
doInstallCheck = false;
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
sioyek = prev.sioyek.overrideAttrs (prevAttrs: {
|
||||
env = prevAttrs.env or { } // {
|
||||
NIX_CFLAGS_COMPILE = toList prevAttrs.env.NIX_CFLAGS_COMPILE or [ ]
|
||||
|
@ -33,6 +43,14 @@ in {
|
|||
};
|
||||
});
|
||||
|
||||
time = prev.time.overrideAttrs (prevAttrs: {
|
||||
env = prevAttrs.env or { } // {
|
||||
CFLAGS = toList prevAttrs.env.CFLAGS or [ ] ++ [
|
||||
"-Wno-error=implicit-function-declaration"
|
||||
] |> toString;
|
||||
};
|
||||
});
|
||||
|
||||
zeromq = prev.zeromq.overrideAttrs (prevAttrs: {
|
||||
postPatch = prevAttrs.postPatch or "" + ''
|
||||
substituteInPlace CMakeLists.txt \
|
||||
|
|
|
@ -4,6 +4,7 @@ let
|
|||
inherit (nixpkgs) lib;
|
||||
in {
|
||||
mimalloc = (prev.mimalloc.overrideAttrs (prevAttrs: {
|
||||
overrideAlloc = false;
|
||||
postPatch = prevAttrs.postPatch or "" + ''
|
||||
sed -E -i \
|
||||
-e 's/(\{ )1(, UNINIT, MI_OPTION_LEGACY\(purge_decommits,reset_decommits\) \})/\10\2/' \
|
||||
|
@ -33,10 +34,6 @@ in {
|
|||
|
||||
fractal = prev.fractal.overrideAttrs (prevAttrs: {
|
||||
nativeBuildInputs = prevAttrs.nativeBuildInputs or [ ] ++ [ final.makeBinaryWrapper ];
|
||||
buildInputs = prevAttrs.buildInputs or [ ] ++ [ final.mimalloc ];
|
||||
|
||||
NIX_RUSTFLAGS = lib.toList prevAttrs.NIX_RUSTFLAGS or [ ] ++ [ "-C" "link-arg=-lmimalloc" ];
|
||||
|
||||
postInstall = prevAttrs.postInstall or "" + ''
|
||||
wrapProgram "$out/bin/fractal" \
|
||||
--set MIMALLOC_RESERVE_HUGE_OS_PAGES 1
|
||||
|
@ -47,47 +44,8 @@ in {
|
|||
mpv = final.mpv-unwrapped;
|
||||
extraMakeWrapperArgs = [ "--set" "MIMALLOC_RESERVE_HUGE_OS_PAGES" "1" ];
|
||||
};
|
||||
} // lib.genAttrs [
|
||||
"bat"
|
||||
"bottom"
|
||||
"cryptsetup"
|
||||
"dbus-broker"
|
||||
"erlang"
|
||||
"fd"
|
||||
"firefox-unwrapped"
|
||||
"fuzzel"
|
||||
"helix"
|
||||
"kitty"
|
||||
"mako"
|
||||
"mpv-unwrapped"
|
||||
"niri"
|
||||
"nix"
|
||||
"nushell"
|
||||
"openssh"
|
||||
"pipewire"
|
||||
"pueue"
|
||||
"ripgrep"
|
||||
"sd"
|
||||
"sioyek"
|
||||
"sudo-rs"
|
||||
"systemd"
|
||||
"swayidle"
|
||||
"swaylock"
|
||||
"swaylock-effects"
|
||||
"thunderbird-unwrapped"
|
||||
"uutils-coreutils"
|
||||
"uutils-coreutils-noprefix"
|
||||
"waybar"
|
||||
"wirepluber"
|
||||
"xdg-desktop-portal-gnome"
|
||||
"xdg-desktop-portal-gtk"
|
||||
] (pkg: prev.${pkg}.overrideAttrs (prevAttrs: {
|
||||
buildInputs = prevAttrs.buildInputs or [ ] ++ [ final.mimalloc ];
|
||||
env = prevAttrs.env or { } // lib.optionalAttrs (prevAttrs ? env.NIX_LDFLAGS) {
|
||||
NIX_LDFLAGS = toString (lib.toList prevAttrs.env.NIX_LDFLAGS or [ ] ++ [ "-lmimalloc" ]);
|
||||
};
|
||||
|
||||
NIX_RUSTFLAGS = lib.toList prevAttrs.NIX_RUSTFLAGS or [ ] ++ [ "-C" "link-arg=-lmimalloc" ];
|
||||
} // lib.optionalAttrs (!prevAttrs ? env.NIX_LDFLAGS) {
|
||||
NIX_LDFLAGS = lib.toList prevAttrs.NIX_LDFLAGS or [ ] ++ [ "-lmimalloc" ];
|
||||
}))
|
||||
perl = prev.perl.overrideAttrs {
|
||||
overrideAlloc = false;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue