Skip to content

Commit

Permalink
feat: add flake
Browse files Browse the repository at this point in the history
  • Loading branch information
miax-gevu committed Oct 22, 2024
1 parent ccb0a41 commit a4326e9
Show file tree
Hide file tree
Showing 3 changed files with 227 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
129 changes: 129 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

97 changes: 97 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
description = "Dev";

inputs = {
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
flake-parts.url = "github:hercules-ci/flake-parts";
};

outputs = inputs @ {
flake-parts,
nixpkgs,
flake-utils,
crane,
rust-overlay,
...
}: let
inherit (nixpkgs.lib) optional concatStringsSep;
systems = flake-utils.lib.system;
flake = flake-utils.lib.eachDefaultSystem (system: let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
config = { allowUnfree = true; };
};

aarch64DarwinExternalCargoCrates = concatStringsSep " " ["[email protected]"];

defaultShellConf = {
buildInputs = [
pkgs.clang
pkgs.openssl

pkgs.libclang
pkgs.pkg-config
pkgs.protobuf
pkgs.protoc-gen-go
pkgs.protoc-gen-go-grpc

pkgs.libiconv
pkgs.buf
];

nativeBuildInputs = with pkgs;
[ ]
++ optional (system == systems.aarch64-darwin) [
darwin.apple_sdk.frameworks.QuartzCore
darwin.apple_sdk.frameworks.Foundation
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.CoreServices
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
]
++ optional (system != systems.aarch64-darwin) [
pkgs.syslinux
];

shellHook = ''
'';

};
in {
devShells.default = pkgs.mkShell defaultShellConf;
});
in
flake-parts.lib.mkFlake {inherit inputs;} {
inherit flake;

systems = flake-utils.lib.defaultSystems;

perSystem = {
config,
system,
...
}: {
_module.args = {
inherit crane;
pkgs = import nixpkgs {
inherit system;
overlays = [(import rust-overlay)];
};
};
};
};
}

0 comments on commit a4326e9

Please sign in to comment.