nix fuckery
This commit is contained in:
parent
1b49477c4e
commit
017aadcf35
7 changed files with 159 additions and 79 deletions
51
flake.lock
51
flake.lock
|
@ -1,20 +1,20 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-utils": {
|
"flake-parts": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems"
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726560853,
|
"lastModified": 1727826117,
|
||||||
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
"narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=",
|
||||||
"owner": "numtide",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-parts",
|
||||||
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
"rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "numtide",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-parts",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -22,37 +22,34 @@
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1728492678,
|
"lastModified": 1728492678,
|
||||||
"narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=",
|
"narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=",
|
||||||
"owner": "nixos",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "5633bcff0c6162b9e4b5f1264264611e950c8ec7",
|
"rev": "5633bcff0c6162b9e4b5f1264264611e950c8ec7",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nixos",
|
"owner": "NixOS",
|
||||||
"ref": "nixos-unstable",
|
"ref": "nixos-unstable",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"nixpkgs-lib": {
|
||||||
"inputs": {
|
|
||||||
"flake-utils": "flake-utils",
|
|
||||||
"nixpkgs": "nixpkgs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems": {
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681028828,
|
"lastModified": 1727825735,
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
"narHash": "sha256-0xHYkMkeLVQAMa7gvkddbPqpxph+hDzdu1XdGPJR+Os=",
|
||||||
"owner": "nix-systems",
|
"type": "tarball",
|
||||||
"repo": "default",
|
"url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz"
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nix-systems",
|
"type": "tarball",
|
||||||
"repo": "default",
|
"url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz"
|
||||||
"type": "github"
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-parts": "flake-parts",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
99
flake.nix
99
flake.nix
|
@ -1,60 +1,57 @@
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = {
|
outputs = {
|
||||||
self,
|
self,
|
||||||
nixpkgs,
|
flake-parts,
|
||||||
flake-utils,
|
...
|
||||||
}:
|
} @ inputs:
|
||||||
flake-utils.lib.eachDefaultSystem (system: let
|
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
systems = ["x86_64-linux"];
|
||||||
stdenv = pkgs.llvmPackages_19.libcxxStdenv;
|
perSystem = {
|
||||||
cmake-version = "3.30.4";
|
self',
|
||||||
|
inputs',
|
||||||
gooey = stdenv.mkDerivation {
|
system,
|
||||||
pname = "gooey";
|
config,
|
||||||
version = "0.0.1";
|
pkgs,
|
||||||
# inherit system;
|
lib,
|
||||||
|
...
|
||||||
src = ./.;
|
}: let
|
||||||
nativeBuildInputs = [
|
inherit (pkgs) callPackage;
|
||||||
(pkgs.cmake.overrideAttrs {
|
|
||||||
version = "3.30.4";
|
|
||||||
src = pkgs.fetchurl {
|
|
||||||
url = "https://cmake.org/files/v${pkgs.lib.versions.majorMinor cmake-version}/cmake-${cmake-version}.tar.gz";
|
|
||||||
hash = "sha256-x1nJcnTx56qq/LHw0mH53pvzpdbst+LfYWMkpG/nBLI=";
|
|
||||||
};
|
|
||||||
})
|
|
||||||
pkgs.ninja
|
|
||||||
];
|
|
||||||
|
|
||||||
buildInputs = [
|
|
||||||
(pkgs.callPackage ./nix/SDL3.nix {})
|
|
||||||
pkgs.llvmPackages_19.clang-tools
|
|
||||||
];
|
|
||||||
|
|
||||||
configurePhase = ''
|
|
||||||
cmake -GNinja .
|
|
||||||
'';
|
|
||||||
|
|
||||||
buildPhase = ''
|
|
||||||
ninja
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out/bin
|
|
||||||
mv gooey $out/bin
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
in {
|
in {
|
||||||
packages.default = gooey;
|
# Customize the pkgs instance with our desired features
|
||||||
devShells.default = pkgs.mkShell.override {inherit stdenv;} {
|
# and overlays.
|
||||||
name = "gooey";
|
legacyPackages = import inputs.nixpkgs {
|
||||||
inputsFrom = [gooey];
|
inherit system;
|
||||||
CMAKE_GENERATOR = "Ninja";
|
config = {
|
||||||
|
overlays = [self.overlays.default]; # consume local overlay
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Set pkgs to the updated value, which is also exposed
|
||||||
|
# as legacyPackages in the flake schema.
|
||||||
|
_module.args.pkgs = config.legacyPackages;
|
||||||
|
|
||||||
|
# Generate packages automagically from ./nix/packages
|
||||||
|
# for each package that contains a package.nix - this
|
||||||
|
# is a flake-parts feature that makes our life easier.
|
||||||
|
packages = {
|
||||||
|
sdl3-custom = callPackage ./nix/packages/SDL3 {};
|
||||||
|
# cursed-libcxx-stdenv = callPackage ./nix/packages/cursed-libcxx-stdenv {};
|
||||||
|
gooey = callPackage ./nix/packages/gooey {
|
||||||
|
inherit self;
|
||||||
|
sdl3 = self'.packages.sdl3-custom;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Generate an overlay containing each one of our packages that are collected
|
||||||
|
# from ./nix/packages.
|
||||||
|
# overlayAttrs = self.packages;
|
||||||
|
|
||||||
|
devShells.default = callPackage ./shells/default.nix {inherit (self'.packages) gooey;};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,17 +79,17 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
xorg.libXi
|
xorg.libXi
|
||||||
xorg.libXrandr
|
xorg.libXrandr
|
||||||
]
|
]
|
||||||
++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Cocoa ]);
|
++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [Cocoa]);
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
tests.pkg-config = testers.hasPkgConfigModules { package = finalAttrs.finalPackage; };
|
tests.pkg-config = testers.hasPkgConfigModules {package = finalAttrs.finalPackage;};
|
||||||
};
|
};
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "Cross-platform development library (Pre-release version)";
|
description = "Cross-platform development library (Pre-release version)";
|
||||||
homepage = "https://libsdl.org";
|
homepage = "https://libsdl.org";
|
||||||
license = lib.licenses.zlib;
|
license = lib.licenses.zlib;
|
||||||
maintainers = with lib.maintainers; [ getchoo ];
|
maintainers = with lib.maintainers; [getchoo];
|
||||||
pkgConfigModules = [ "sdl3" ];
|
pkgConfigModules = ["sdl3"];
|
||||||
};
|
};
|
||||||
})
|
})
|
11
nix/packages/cursed-libcxx-stdenv/default.nix
Normal file
11
nix/packages/cursed-libcxx-stdenv/default.nix
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{llvmPackages_19, ...}: let
|
||||||
|
cursed-libcxx-stdenv = llvmPackages_19.libcxxStdenv.overrideAttrs (oa: {
|
||||||
|
postFixup =
|
||||||
|
(oa.postFixup or "")
|
||||||
|
+ ''
|
||||||
|
ln -sf ${llvmPackages_19.libcxx}/lib/libc++.modules.json $out/resource-root/libc++.modules.json
|
||||||
|
ln -sf ${llvmPackages_19.libcxx}/share $out
|
||||||
|
'';
|
||||||
|
});
|
||||||
|
in
|
||||||
|
cursed-libcxx-stdenv
|
64
nix/packages/gooey/default.nix
Normal file
64
nix/packages/gooey/default.nix
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
{
|
||||||
|
self,
|
||||||
|
sdl3, # from self.packages
|
||||||
|
lib,
|
||||||
|
fetchurl,
|
||||||
|
cmake,
|
||||||
|
ninja,
|
||||||
|
llvmPackages_19,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
pname = "gooey";
|
||||||
|
version = "0.0.1";
|
||||||
|
in
|
||||||
|
llvmPackages_19.libcxxStdenv.mkDerivation {
|
||||||
|
inherit pname version;
|
||||||
|
src = builtins.path {
|
||||||
|
# reproducible source path
|
||||||
|
path = self;
|
||||||
|
name = "${pname}-${version}";
|
||||||
|
};
|
||||||
|
|
||||||
|
enableParallelBuilding = true;
|
||||||
|
strictDeps = true;
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
ninja
|
||||||
|
(cmake.overrideAttrs {
|
||||||
|
version = "3.30.4";
|
||||||
|
src = let
|
||||||
|
cmake-version = "3.30.4";
|
||||||
|
in
|
||||||
|
fetchurl {
|
||||||
|
url = "https://cmake.org/files/v${lib.versions.majorMinor cmake-version}/cmake-${cmake-version}.tar.gz";
|
||||||
|
hash = "sha256-x1nJcnTx56qq/LHw0mH53pvzpdbst+LfYWMkpG/nBLI=";
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
sdl3
|
||||||
|
llvmPackages_19.clang-tools
|
||||||
|
];
|
||||||
|
|
||||||
|
configurePhase = ''
|
||||||
|
runHook preConfigure
|
||||||
|
cmake -GNinja .
|
||||||
|
runHook postConfiguree
|
||||||
|
'';
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
ninja
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
mkdir -p $out/bin
|
||||||
|
mv gooey $out/bin
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
}
|
11
nix/shells/default.nix
Normal file
11
nix/shells/default.nix
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
mkShell,
|
||||||
|
llvmPackages_19,
|
||||||
|
gooey,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
mkShell.override {stdenv = llvmPackages_19.libcxxStdenv;} {
|
||||||
|
name = "gooey-dev-env";
|
||||||
|
inputsFrom = [gooey];
|
||||||
|
CMAKE_GENERATOR = "Ninja";
|
||||||
|
}
|
Loading…
Reference in a new issue