Skip to content

Commit

Permalink
add flake support
Browse files Browse the repository at this point in the history
  • Loading branch information
ocfox committed Mar 24, 2023
1 parent 96335ac commit d03ec53
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
fi

nix_direnv_watch_file devenv.nix
nix_direnv_watch_file devenv.lock
nix_direnv_watch_file devenv.yaml
if ! use flake . --impure
then
echo "devenv could not be build. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2
fi
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
target
.devenv
.direnv
102 changes: 102 additions & 0 deletions flake.lock

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

42 changes: 42 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, fenix, flake-utils, naersk, nixpkgs }:
flake-utils.lib.eachDefaultSystem (system: {
packages.default =
let
pkgs = nixpkgs.legacyPackages.${system};
toolchain = with fenix.packages.${system}; combine [
minimal.cargo
minimal.rustc
];
in
(naersk.lib.${system}.override {
cargo = toolchain;
rustc = toolchain;
}).buildPackage {
hardeningDisable = [ "all" ];
buildInputs = with pkgs; [
clang
zlib
];
nativeBuildInputs = with pkgs; [
elfutils
pkg-config
];
src = ./.;
};
});
}

0 comments on commit d03ec53

Please sign in to comment.