diff options
| author | Max Audron <audron@cocaine.farm> | 2024-03-27 12:57:30 +0100 |
|---|---|---|
| committer | Max Audron <audron@cocaine.farm> | 2024-03-27 12:57:30 +0100 |
| commit | 3a88527328952ddffef0bf228f0832e81fcfdf19 (patch) | |
| tree | 8de19b16c5038537a714d2bfe34892d20e6d5626 /flake.nix | |
| parent | release 1.0.4 (diff) | |
implement basic cloning and updating with gix
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 148 |
1 files changed, 40 insertions, 108 deletions
@@ -1,117 +1,49 @@ { - nixConfig = { - substituters = - [ "https://cache.nixos.org/" "https://nix-community.cachix.org" ]; - trusted-public-keys = [ - "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - ]; - }; inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; - - fenix = { - url = "github:nix-community/fenix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - crane = { - url = "github:ipetkov/crane"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - advisory-db = { - url = "github:rustsec/advisory-db"; - flake = false; - }; - - utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nci.url = "github:yusdacra/nix-cargo-integration"; + nci.inputs.nixpkgs.follows = "nixpkgs"; + parts.url = "github:hercules-ci/flake-parts"; + parts.inputs.nixpkgs-lib.follows = "nixpkgs"; }; - outputs = { self, nixpkgs, utils, fenix, crane, advisory-db }: - with nixpkgs.lib; - utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - - rustToolchain = with fenix.packages.${system}; - combine ([ latest.toolchain ] ++ (if system == "x86_64-linux" then - [ targets.x86_64-unknown-linux-musl.latest.rust-std ] - else - [ ])); - - openssl = - (if (system == "aarch64-darwin" || system == "x86_64-darwin") then - pkgs.openssl.override { static = true; } - else - pkgs.pkgsStatic.openssl); - - nativeBuildInputs = with pkgs; - [ - rustToolchain - pkg-config - - openssl - ] ++ lib.optional stdenv.isDarwin [ - pkgs.darwin.libiconv - pkgs.darwin.apple_sdk.frameworks.Security - ]; - - OPENSSL_STATIC = "true"; - OPENSSL_DIR = "${openssl}"; - OPENSSL_LIB_DIR = "${openssl.out}/lib"; - OPENSSL_CRYPTO_LIBRARY = "${openssl.out}/lib"; - OPENSSL_INCLUDE_DIR = "${openssl.dev}/include"; - CARGO_BUILD_TARGET = if system == "x86_64-linux" then - "x86_64-unknown-linux-musl" - else - null; - CARGO_BUILD_RUSTFLAGS = if system == "x86_64-linux" then - "-C target-feature=+crt-static" - else - null; - - graphqlFilter = path: _type: builtins.match ".*graphql$" path != null; - markdownFilter = path: _type: builtins.match ".*md$" path != null; - markdownOrCargo = path: type: - (graphqlFilter path type) || (markdownFilter path type) - || (craneLib.filterCargoSources path type); - - # crane setup - craneLib = crane.lib.${system}.overrideToolchain rustToolchain; - src = nixpkgs.lib.cleanSourceWith { - src = craneLib.path ./.; # The original, unfiltered source - filter = markdownOrCargo; - }; - - cargoArtifacts = self.packages.${system}.cargoArtifacts; - in { - packages = { - cargoArtifacts = craneLib.buildDepsOnly { - inherit src; - inherit nativeBuildInputs OPENSSL_STATIC OPENSSL_DIR OPENSSL_LIB_DIR - OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR CARGO_BUILD_TARGET - CARGO_BUILD_RUSTFLAGS; + outputs = inputs@{ parts, nci, ... }: + parts.lib.mkFlake { inherit inputs; } { + systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + imports = [ nci.flakeModule ]; + perSystem = { pkgs, config, lib, ... }: + let + # shorthand for accessing this crate's outputs + # you can access crate outputs under `config.nci.outputs.<crate name>` (see documentation) + crateOutputs = config.nci.outputs."gtree"; + in + { + nci = { + projects."gtree".path = ./.; + crates.gtree = + let mkDerivation = { + # inputs and most other stuff will automatically merge + buildInputs = lib.optional pkgs.stdenv.isDarwin [ + pkgs.darwin.libiconv + pkgs.darwin.apple_sdk.frameworks.Security + pkgs.darwin.apple_sdk.frameworks.SystemConfiguration + ]; + }; + in + { + drvConfig = { inherit mkDerivation; }; + depsDrvConfig = { inherit mkDerivation; }; + }; + + toolchainConfig = { + channel = "stable"; + components = [ "rustfmt" "rust-src" ]; + }; }; - ##################################### - # Build Binaries - gtree = craneLib.buildPackage { - inherit cargoArtifacts src; - inherit nativeBuildInputs OPENSSL_STATIC OPENSSL_DIR OPENSSL_LIB_DIR - OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR CARGO_BUILD_TARGET - CARGO_BUILD_RUSTFLAGS; - }; - - default = self.packages.${system}.gtree; - }; - devShells.default = pkgs.mkShell { - inherit nativeBuildInputs OPENSSL_STATIC OPENSSL_DIR OPENSSL_LIB_DIR - OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR CARGO_BUILD_TARGET - CARGO_BUILD_RUSTFLAGS; + devShells.default = crateOutputs.devShell; + packages.default = crateOutputs.packages.release; }; - - formatter = pkgs.nixfmt; - }); + }; } |
