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": {
|
||||
"flake-utils": {
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1726560853,
|
||||
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
||||
"lastModified": 1727826117,
|
||||
"narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
|
@ -22,37 +22,34 @@
|
|||
"locked": {
|
||||
"lastModified": 1728492678,
|
||||
"narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=",
|
||||
"owner": "nixos",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "5633bcff0c6162b9e4b5f1264264611e950c8ec7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
"lastModified": 1727825735,
|
||||
"narHash": "sha256-0xHYkMkeLVQAMa7gvkddbPqpxph+hDzdu1XdGPJR+Os=",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
99
flake.nix
99
flake.nix
|
@ -1,60 +1,57 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
stdenv = pkgs.llvmPackages_19.libcxxStdenv;
|
||||
cmake-version = "3.30.4";
|
||||
|
||||
gooey = stdenv.mkDerivation {
|
||||
pname = "gooey";
|
||||
version = "0.0.1";
|
||||
# inherit system;
|
||||
|
||||
src = ./.;
|
||||
nativeBuildInputs = [
|
||||
(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
|
||||
'';
|
||||
};
|
||||
flake-parts,
|
||||
...
|
||||
} @ inputs:
|
||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||
systems = ["x86_64-linux"];
|
||||
perSystem = {
|
||||
self',
|
||||
inputs',
|
||||
system,
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (pkgs) callPackage;
|
||||
in {
|
||||
packages.default = gooey;
|
||||
devShells.default = pkgs.mkShell.override {inherit stdenv;} {
|
||||
name = "gooey";
|
||||
inputsFrom = [gooey];
|
||||
CMAKE_GENERATOR = "Ninja";
|
||||
# Customize the pkgs instance with our desired features
|
||||
# and overlays.
|
||||
legacyPackages = import inputs.nixpkgs {
|
||||
inherit system;
|
||||
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;};
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
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