From c38fc8ef170bcf05bf90a2fa6f216524cd332e3a Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Tue, 27 May 2025 17:00:34 +0200 Subject: [PATCH] Integrate nixify and update flake configurations Added nixify as an input and refactored flake outputs using nixify utilities. Updated dependencies and build configurations, including platform-specific enhancements and new package sources for streamlined builds. --- .envrc | 1 + flake.lock | 472 +++++++++++++++++++++++++++++++++++++++++++++++++++-- flake.nix | 96 +++++++---- 3 files changed, 519 insertions(+), 50 deletions(-) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..f92f568 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/flake.lock b/flake.lock index 4c81142..01df060 100644 --- a/flake.lock +++ b/flake.lock @@ -1,53 +1,457 @@ { "nodes": { + "advisory-db": { + "flake": false, + "locked": { + "lastModified": 1747937073, + "narHash": "sha256-52H8P6jAHEwRvg7rXr4Z7h1KHZivO8T1Z9tN6R0SWJg=", + "owner": "rustsec", + "repo": "advisory-db", + "rev": "bccf313a98c034573ac4170e6271749113343d97", + "type": "github" + }, + "original": { + "owner": "rustsec", + "repo": "advisory-db", + "type": "github" + } + }, + "crane": { + "locked": { + "lastModified": 1748047550, + "narHash": "sha256-t0qLLqb4C1rdtiY8IFRH5KIapTY/n3Lqt57AmxEv9mk=", + "owner": "ipetkov", + "repo": "crane", + "rev": "b718a78696060df6280196a6f992d04c87a16aef", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "crane_2": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": [ + "nixify", + "nix-log", + "nixify", + "flake-utils" + ], + "nixpkgs": [ + "nixify", + "nix-log", + "nixify", + "nixpkgs" + ], + "rust-overlay": [ + "nixify", + "nix-log", + "nixify", + "rust-overlay" + ] + }, + "locked": { + "lastModified": 1679255352, + "narHash": "sha256-nkGwGuNkhNrnN33S4HIDV5NzkzMLU5mNStRn9sZwq8c=", + "owner": "rvolosatovs", + "repo": "crane", + "rev": "cec65880599a4ec6426186e24342e663464f5933", + "type": "github" + }, + "original": { + "owner": "rvolosatovs", + "ref": "feat/wit", + "repo": "crane", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "nixify", + "nixpkgs-nixos" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1747392669, + "narHash": "sha256-zky3+lndxKRu98PAwVK8kXPdg+Q1NVAhaI7YGrboKYA=", + "owner": "nix-community", + "repo": "fenix", + "rev": "c3c27e603b0d9b5aac8a16236586696338856fbb", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "fenix_2": { + "inputs": { + "nixpkgs": [ + "nixify", + "nix-log", + "nixify", + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src_2" + }, + "locked": { + "lastModified": 1679552560, + "narHash": "sha256-L9Se/F1iLQBZFGrnQJO8c9wE5z0Mf8OiycPGP9Y96hA=", + "owner": "nix-community", + "repo": "fenix", + "rev": "fb49a9f5605ec512da947a21cc7e4551a3950397", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1678901627, + "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "macos-sdk": { + "flake": false, + "locked": { + "lastModified": 1694769349, + "narHash": "sha256-TEvVJy+NMPyzgWSk/6S29ZMQR+ICFxSdS3tw247uhFc=", + "type": "tarball", + "url": "https://github.com/roblabla/MacOSX-SDKs/releases/download/macosx14.0/MacOSX14.0.sdk.tar.xz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/roblabla/MacOSX-SDKs/releases/download/macosx14.0/MacOSX14.0.sdk.tar.xz" + } + }, + "nix-filter": { + "locked": { + "lastModified": 1731533336, + "narHash": "sha256-oRam5PS1vcrr5UPgALW0eo1m/5/pls27Z/pabHNy2Ms=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "f7653272fd234696ae94229839a99b73c9ab7de0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, + "nix-filter_2": { + "locked": { + "lastModified": 1678109515, + "narHash": "sha256-C2X+qC80K2C1TOYZT8nabgo05Dw2HST/pSn6s+n6BO8=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "aa9ff6ce4a7f19af6415fb3721eaa513ea6c763c", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, + "nix-flake-tests": { + "locked": { + "lastModified": 1677844186, + "narHash": "sha256-ErJZ/Gs1rxh561CJeWP5bohA2IcTq1rDneu1WT6CVII=", + "owner": "antifuchs", + "repo": "nix-flake-tests", + "rev": "bbd9216bd0f6495bb961a8eb8392b7ef55c67afb", + "type": "github" + }, + "original": { + "owner": "antifuchs", + "repo": "nix-flake-tests", + "type": "github" + } + }, + "nix-log": { + "inputs": { + "nix-flake-tests": "nix-flake-tests", + "nixify": "nixify_2", + "nixlib": "nixlib_2" + }, + "locked": { + "lastModified": 1733747205, + "narHash": "sha256-8BRnYXnl0exUL/sRD2I382KHiY5TKWzVBQw6+6YO4yw=", + "owner": "rvolosatovs", + "repo": "nix-log", + "rev": "354b9acbdb08a5567a97791546c1e23c9f476ef6", + "type": "github" + }, + "original": { + "owner": "rvolosatovs", + "repo": "nix-log", + "type": "github" + } + }, + "nixify": { + "inputs": { + "advisory-db": "advisory-db", + "crane": "crane", + "fenix": "fenix", + "flake-utils": "flake-utils", + "macos-sdk": "macos-sdk", + "nix-filter": "nix-filter", + "nix-log": "nix-log", + "nixlib": "nixlib_3", + "nixpkgs-darwin": [ + "nixpkgs-darwin" + ], + "nixpkgs-nixos": [ + "nixpkgs" + ], + "rust-overlay": "rust-overlay_2" + }, + "locked": { + "lastModified": 1748273866, + "narHash": "sha256-MsUtTm9Ir7BsoOpJOxEEYm4mWG4azixX88ck/3AeQBE=", + "owner": "rvolosatovs", + "repo": "nixify", + "rev": "6a25811b02d7ff648f46d0dbeb2e8641e1a9401a", + "type": "github" + }, + "original": { + "owner": "rvolosatovs", + "repo": "nixify", + "type": "github" + } + }, + "nixify_2": { + "inputs": { + "crane": "crane_2", + "fenix": "fenix_2", + "flake-utils": "flake-utils_2", + "nix-filter": "nix-filter_2", + "nixlib": "nixlib", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1679748566, + "narHash": "sha256-yA4yIJjNCOLoUh0py9S3SywwbPnd/6NPYbXad+JeOl0=", + "owner": "rvolosatovs", + "repo": "nixify", + "rev": "80e823959511a42dfec4409fef406a14ae8240f3", + "type": "github" + }, + "original": { + "owner": "rvolosatovs", + "repo": "nixify", + "type": "github" + } + }, + "nixlib": { + "locked": { + "lastModified": 1679187309, + "narHash": "sha256-H8udmkg5wppL11d/05MMzOMryiYvc403axjDNZy1/TQ=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "44214417fe4595438b31bdb9469be92536a61455", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixlib_2": { + "locked": { + "lastModified": 1679791877, + "narHash": "sha256-tTV1Mf0hPWIMtqyU16Kd2JUBDWvfHlDC9pF57vcbgpQ=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "cc060ddbf652a532b54057081d5abd6144d01971", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixlib_3": { + "locked": { + "lastModified": 1748135671, + "narHash": "sha256-PIkcBpddXRAGWstWV7zTwRZ9EAPqgzFNssux17p1NTg=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "6194ba204e5b188965da97ebb16e05191e560427", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1743315132, - "narHash": "sha256-6hl6L/tRnwubHcA4pfUUtk542wn2Om+D4UnDhlDW9BE=", + "lastModified": 1679577639, + "narHash": "sha256-7u7bsNP0ApBnLgsHVROQ5ytoMqustmMVMgtaFS/P7EU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "52faf482a3889b7619003c0daec593a1912fddc1", + "rev": "8f1bcd72727c5d4cd775545595d068be410f2a7e", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-unstable", + "ref": "nixpkgs-22.11-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-darwin": { + "locked": { + "lastModified": 1748192983, + "narHash": "sha256-FpKC8sZCzNoeCtHJmYiqafYt5A1JzQ44opT46M/qe4I=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b26c8c4da0fe0b4e496f2a432140795dabe2c8e2", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-25.05-darwin", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_2": { "locked": { - "lastModified": 1736320768, - "narHash": "sha256-nIYdTAiKIGnFNugbomgBJR+Xv5F1ZQU+HfaBqJKroC0=", - "owner": "NixOS", + "lastModified": 1748162331, + "narHash": "sha256-rqc2RKYTxP3tbjA+PB3VMRQNnjesrT0pEofXQTrMsS8=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "4bc9c909d9ac828a039f288cf872d16d38185db8", + "rev": "7c43f080a7f28b2774f3b3f43234ca11661bf334", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", + "owner": "nixos", + "ref": "nixos-25.05", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" + "nixify": "nixify", + "nixpkgs": "nixpkgs_2", + "nixpkgs-darwin": "nixpkgs-darwin" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1747323949, + "narHash": "sha256-G4NwzhODScKnXqt2mEQtDFOnI0wU3L1WxsiHX3cID/0=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "f8e784353bde7cbf9a9046285c1caf41ac484ebe", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "rust-analyzer-src_2": { + "flake": false, + "locked": { + "lastModified": 1679520343, + "narHash": "sha256-AJGSGWRfoKWD5IVTu1wEsR990wHbX0kIaolPqNMEh0c=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "eb791f31e688ae00908eb75d4c704ef60c430a92", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" } }, "rust-overlay": { "inputs": { - "nixpkgs": "nixpkgs_2" + "flake-utils": [ + "nixify", + "nix-log", + "nixify", + "flake-utils" + ], + "nixpkgs": [ + "nixify", + "nix-log", + "nixify", + "nixpkgs" + ] }, "locked": { - "lastModified": 1743475035, - "narHash": "sha256-uLjVsb4Rxnp1zmFdPCDmdODd4RY6ETOeRj0IkC0ij/4=", + "lastModified": 1679537973, + "narHash": "sha256-R6borgcKeyMIjjPeeYsfo+mT8UdS+OwwbhhStdCfEjg=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "bee11c51c2cda3ac57c9e0149d94b86cc1b00d13", + "rev": "fbc7ae3f14d32e78c0e8d7865f865cc28a46b232", "type": "github" }, "original": { @@ -55,6 +459,42 @@ "repo": "rust-overlay", "type": "github" } + }, + "rust-overlay_2": { + "inputs": { + "nixpkgs": [ + "nixify", + "nixpkgs-nixos" + ] + }, + "locked": { + "lastModified": 1748140821, + "narHash": "sha256-GZcjWLQtDifSYMd1ueLDmuVTcQQdD5mONIBTqABooOk=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "476b2ba7dc99ddbf70b1f45357dbbdbdbdfb4422", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 3624143..b1d4cc6 100644 --- a/flake.nix +++ b/flake.nix @@ -1,39 +1,67 @@ { inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - rust-overlay.url = "github:oxalica/rust-overlay"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05"; + nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-25.05-darwin"; + nixify.url = "github:rvolosatovs/nixify"; + nixify.inputs.nixpkgs-nixos.follows = "nixpkgs"; + nixify.inputs.nixpkgs-darwin.follows = "nixpkgs-darwin"; }; - outputs = { self, nixpkgs, rust-overlay, ... }: - let - namespace = "hello"; - overlays = [ rust-overlay.overlays.default ]; - forEachSystem = systems: f: nixpkgs.lib.genAttrs systems f; - forAllSystems = function: - nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed - (system: function (import nixpkgs { inherit system overlays; })); - in { - packages = - forAllSystems (pkgs: (self.overlays.default pkgs pkgs).${namespace}); - cross = forAllSystems (pkgs: - (forEachSystem (nixpkgs.lib.filter (sys: sys != pkgs.system) - nixpkgs.lib.systems.flakeExposed) (crossSystem: - let - crossPkgs = import nixpkgs { - localSystem = pkgs.system; - inherit crossSystem; + + outputs = + { nixify, ... }: + with nixify.lib; + rust.mkFlake { + src = ./.; + + withDevShells = + { devShells + , pkgs + , ... + }: + extendDerivations + { + env.LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${ + with pkgs; + pkgs.lib.makeLibraryPath [ + openssl + ] + }"; + buildInputs = with pkgs; [ + openssl + ]; + } + devShells; + + buildOverrides = + { pkgs + , pkgsCross ? pkgs + , ... + }: + { buildInputs ? [ ] + , nativeBuildInputs ? [ ] + , depsBuildBuild ? [ ] + , env ? { } + , ... + }: + with pkgs.lib; + { + nativeBuildInputs = + nativeBuildInputs + ++ optional (pkgs.stdenv.hostPlatform.isLinux) [ pkgs.pkg-config ]; + + buildInputs = + buildInputs + ++ optional pkgs.stdenv.hostPlatform.isDarwin pkgs.libiconv + ++ optional (pkgs.stdenv.hostPlatform.isLinux) [ + pkgs.openssl.dev + ]; + + depsBuildBuild = + depsBuildBuild + ++ optional pkgsCross.stdenv.hostPlatform.isDarwin pkgsCross.xcbuild.xcrun; + env = env // { + OPENSSL_NO_VENDOR = "1"; }; - in (self.overlays.default crossPkgs crossPkgs).${namespace}))); - devShells = - forAllSystems (pkgs: (self.overlays.default pkgs pkgs).devShells); - formatter = forAllSystems (pkgs: pkgs.nixpkgs-fmt); - overlays.default = final: prev: - let pkgs = final; - in { - devShells.default = pkgs.callPackage ./shell.nix { }; - ${namespace} = { - hello = pkgs.callPackage ./default.nix { }; - default = pkgs.callPackage ./default.nix { }; - }; - }; - }; + }; + }; }