aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.envrc1
-rw-r--r--flake.lock173
-rw-r--r--flake.nix166
3 files changed, 225 insertions, 115 deletions
diff --git a/.envrc b/.envrc
new file mode 100644
index 0000000..c4b17d7
--- /dev/null
+++ b/.envrc
@@ -0,0 +1 @@
+use_flake
diff --git a/flake.lock b/flake.lock
index ab2cf07..ee5e611 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,76 +1,158 @@
{
"nodes": {
- "flake-utils": {
+ "advisory-db": {
+ "flake": false,
"locked": {
- "lastModified": 1637014545,
- "narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=",
- "owner": "numtide",
- "repo": "flake-utils",
- "rev": "bba5dcc8e0b20ab664967ad83d24d64cb64ec4f4",
+ "lastModified": 1690651200,
+ "narHash": "sha256-0aDZUueboXYxKy/ckHQYA6zkvLOVsb2wyzJjSuEdJzE=",
+ "owner": "rustsec",
+ "repo": "advisory-db",
+ "rev": "98e8483ac17d42eeeeee51d4d02ad8a690bd12c7",
"type": "github"
},
"original": {
- "owner": "numtide",
- "repo": "flake-utils",
+ "owner": "rustsec",
+ "repo": "advisory-db",
"type": "github"
}
},
- "naersk": {
+ "crane": {
"inputs": {
+ "flake-compat": "flake-compat",
+ "flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
- ]
+ ],
+ "rust-overlay": "rust-overlay"
+ },
+ "locked": {
+ "lastModified": 1688772518,
+ "narHash": "sha256-ol7gZxwvgLnxNSZwFTDJJ49xVY5teaSvF7lzlo3YQfM=",
+ "owner": "ipetkov",
+ "repo": "crane",
+ "rev": "8b08e96c9af8c6e3a2b69af5a7fa168750fcf88e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "ipetkov",
+ "repo": "crane",
+ "type": "github"
+ }
+ },
+ "fenix": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ],
+ "rust-analyzer-src": "rust-analyzer-src"
+ },
+ "locked": {
+ "lastModified": 1690957271,
+ "narHash": "sha256-//ItnqqVI6M5nrnQbpZ/a93S65YosvSSn8ozqEQOgQo=",
+ "owner": "nix-community",
+ "repo": "fenix",
+ "rev": "90aba0cc6f4c30a8f4111a0c4baf548bae5d9510",
+ "type": "github"
},
+ "original": {
+ "owner": "nix-community",
+ "repo": "fenix",
+ "type": "github"
+ }
+ },
+ "flake-compat": {
+ "flake": false,
"locked": {
- "lastModified": 1653413650,
- "narHash": "sha256-wojDHjb+eU80MPH+3HQaK0liUy8EgR95rvmCl24i58Y=",
- "owner": "nmattia",
- "repo": "naersk",
- "rev": "69daaceebe12c070cd5ae69ba38f277bbf033695",
+ "lastModified": 1673956053,
+ "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
- "owner": "nmattia",
- "repo": "naersk",
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
+ "flake-utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1687709756,
+ "narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
- "lastModified": 1654595132,
- "narHash": "sha256-Te8d7qAUzTumXbby9sthEuTBpFprikjiyphyNV3GdhI=",
+ "lastModified": 1690835256,
+ "narHash": "sha256-SZy/Nvwbf6CorhEsvmjqgjoYNLnRfaKVZMfSnpUDPnc=",
"owner": "nixos",
"repo": "nixpkgs",
- "rev": "ab7173f6db30fcffe01a23d85138449fa990cabf",
+ "rev": "b7cde1c47b7316f6138a2b36ef6627f3d16d645c",
"type": "github"
},
"original": {
"owner": "nixos",
+ "ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
- "naersk": "naersk",
+ "advisory-db": "advisory-db",
+ "crane": "crane",
+ "fenix": "fenix",
"nixpkgs": "nixpkgs",
- "rust-overlay": "rust-overlay",
"utils": "utils"
}
},
+ "rust-analyzer-src": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1690888982,
+ "narHash": "sha256-MQniEaKbxsewuXGo+DaFE1IODeodExYHolPhUTrMoLc=",
+ "owner": "rust-lang",
+ "repo": "rust-analyzer",
+ "rev": "151c750dac8d2a03a4a1f9c20d2fc29ad2042f02",
+ "type": "github"
+ },
+ "original": {
+ "owner": "rust-lang",
+ "ref": "nightly",
+ "repo": "rust-analyzer",
+ "type": "github"
+ }
+ },
"rust-overlay": {
"inputs": {
- "flake-utils": "flake-utils",
+ "flake-utils": [
+ "crane",
+ "flake-utils"
+ ],
"nixpkgs": [
+ "crane",
"nixpkgs"
]
},
"locked": {
- "lastModified": 1654396786,
- "narHash": "sha256-stM8eWx51WDwptsByQFwmAvPBT1N0XUhcGaMq5Nx7T8=",
+ "lastModified": 1688351637,
+ "narHash": "sha256-CLTufJ29VxNOIZ8UTg0lepsn3X03AmopmaLTTeHDCL4=",
"owner": "oxalica",
"repo": "rust-overlay",
- "rev": "2d306305e1a52d3e18bf10a5d88f3eca99033ba8",
+ "rev": "f9b92316727af9e6c7fee4a761242f7f46880329",
"type": "github"
},
"original": {
@@ -79,13 +161,46 @@
"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"
+ }
+ },
+ "systems_2": {
+ "locked": {
+ "lastModified": 1681028828,
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
+ },
"utils": {
+ "inputs": {
+ "systems": "systems_2"
+ },
"locked": {
- "lastModified": 1653893745,
- "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
+ "lastModified": 1687171271,
+ "narHash": "sha256-BJlq+ozK2B1sJDQXS3tzJM5a+oVZmi1q0FlBK/Xqv7M=",
"owner": "numtide",
"repo": "flake-utils",
- "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
+ "rev": "abfb11bd1aec8ced1c9bb9adfe68018230f4fb3c",
"type": "github"
},
"original": {
diff --git a/flake.nix b/flake.nix
index de34969..f616506 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,116 +1,110 @@
{
nixConfig = {
substituters =
- [ "https://cache.nixos.org/" "https://nix-community.cachix.org" "https://nix.cache.vapor.systems" ];
+ [ "https://cache.nixos.org/" "https://nix-community.cachix.org" ];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
- "nix.cache.vapor.systems-1:OjV+eZuOK+im1n8tuwHdT+9hkQVoJORdX96FvWcMABk="
];
};
inputs = {
- nixpkgs.url = "github:nixos/nixpkgs";
- rust-overlay = {
- url = "github:oxalica/rust-overlay";
+ nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
+
+ fenix = {
+ url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
- naersk = {
- url = "github:nmattia/naersk";
+
+ crane = {
+ url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
+
+ advisory-db = {
+ url = "github:rustsec/advisory-db";
+ flake = false;
+ };
+
utils.url = "github:numtide/flake-utils";
};
- outputs = { self, nixpkgs, rust-overlay, utils, naersk }:
+ outputs = { self, nixpkgs, utils, fenix, crane, advisory-db }:
with nixpkgs.lib;
- recursiveUpdate (utils.lib.eachDefaultSystem (system:
+ utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
- rust = rust-overlay.packages."${system}".rust;
-
- naersk-lib = naersk.lib."${system}".override {
- cargo = rust;
- rustc = rust;
- };
- in rec {
- packages.default = packages.gtree;
-
- packages.gtree = naersk-lib.buildPackage {
- pname = "gtree";
- root = ./.;
-
- nativeBuildInputs = [ pkgs.perl ];
-
- cargoBuildOptions = prev:
- prev ++ [ "--features=vendored-libgit2,vendored-openssl" ];
- };
-
- apps.default = utils.lib.mkApp { drv = packages.default; };
-
- devShell = pkgs.mkShell { nativeBuildInputs = [ rust pkgs.perl ]; };
- })) (utils.lib.eachSystem [
- utils.lib.system.x86_64-linux
- utils.lib.system.aarch64-linux
- ] (system:
- let
- pkgs = nixpkgs.legacyPackages.${system};
-
- staticInputs = with pkgs; [
- pkgsStatic.stdenv.cc
- pkgsStatic.openssl.dev
- rust
- perl
+ rustToolchain = with fenix.packages.${system};
+ combine ([ latest.toolchain ] ++ (if system == "x86_64-linux" then
+ [ targets.x86_64-unknown-linux-musl.latest.rust-std ]
+ else
+ [ ]));
+
+ nativeBuildInputs = with pkgs;
+ [
+ rustToolchain
+ pkg-config
+
+ pkgsStatic.openssl
+ ] ++ lib.optional stdenv.isDarwin [
+ pkgs.libiconv
+ pkgs.darwin.apple_sdk.frameworks.Security
];
- target =
- "${elemAt (strings.splitString "-" system) 0}-unknown-linux-musl";
-
- rust = rust-overlay.packages."${system}".rust.override {
- extensions = [ "rust-src" ];
- targets = [ target ];
- };
+ OPENSSL_DIR = "${pkgs.pkgsStatic.openssl}";
+ OPENSSL_LIB_DIR = "${pkgs.pkgsStatic.openssl.out}/lib";
+ OPENSSL_CRYPTO_LIBRARY = "${pkgs.pkgsStatic.openssl.out}/lib";
+ OPENSSL_INCLUDE_DIR = "${pkgs.pkgsStatic.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;
+ };
- naersk-lib = naersk.lib."${system}".override {
- cargo = rust;
- rustc = rust;
+ cargoArtifacts = self.packages.${system}.cargoArtifacts;
+ in {
+ packages = {
+ cargoArtifacts = craneLib.buildDepsOnly {
+ inherit src;
+ inherit nativeBuildInputs OPENSSL_DIR OPENSSL_LIB_DIR
+ OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR CARGO_BUILD_TARGET
+ CARGO_BUILD_RUSTFLAGS;
};
- gitlab-upload = makeBinScript "gitlab-upload" ''
- ${pkgs.curl} -f --header "PRIVATE-TOKEN: $GITLAB_API_TOKEN" --upload-file result/bin/gtree https://gitlab.com/api/v4/projects/${project_id}/packages/generic/${name}/${version}/$1
- '';
- in rec {
- # `nix build`
- packages.gtreeStatic = naersk-lib.buildPackage {
- pname = "gtree";
- root = ./.;
-
- nativeBuildInputs = staticInputs;
-
- CARGO_BUILD_TARGET = target;
- CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS =
- "-C target-feature=+crt-static";
- CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS =
- "-C target-feature=+crt-static";
-
- OPENSSL_STATIC = true;
- OPENSSL_DIR = "${pkgs.pkgsStatic.openssl}";
- OPENSSL_LIB_DIR = "${pkgs.pkgsStatic.openssl.out}/lib";
- OPENSSL_INCLUDE_DIR = "${pkgs.pkgsStatic.openssl.dev}/include";
+ #####################################
+ # Build Binaries
+ gtree = craneLib.buildPackage {
+ inherit cargoArtifacts src;
+ inherit nativeBuildInputs OPENSSL_DIR OPENSSL_LIB_DIR
+ OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR CARGO_BUILD_TARGET
+ CARGO_BUILD_RUSTFLAGS;
};
- devShell = pkgs.mkShell {
- nativeBuildInputs = staticInputs;
+ default = self.packages.${system}.gtree;
+ };
- shellHook = ''
- export CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C target-feature=+crt-static"
- export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C target-feature=+crt-static"
+ devShells.default = pkgs.mkShell {
+ inherit nativeBuildInputs OPENSSL_DIR OPENSSL_LIB_DIR
+ OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR CARGO_BUILD_TARGET
+ CARGO_BUILD_RUSTFLAGS;
+ };
- export OPENSSL_STATIC=1
- export OPENSSL_DIR="${pkgs.pkgsStatic.openssl}"
- export OPENSSL_LIB_DIR="${pkgs.pkgsStatic.openssl.out}/lib"
- export OPENSSL_INCLUDE_DIR="${pkgs.pkgsStatic.openssl.dev}/include"
- '';
- };
- }));
+ formatter = pkgs.nixfmt;
+ });
}