-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(nix): refactor for flake support and add package build (#220)
* chore(nix): refactor for flake support and add package build Pins nixpkgs to a known working version for the flake. Things should be unchanged for non-flake-users. * chore(nix): trim unnecessary deps from shell.nix * chore(nix): relocate most nix files to the nix directory For flake and direnv users, this is a small refactor that won't be noticeable aside from the locations of the files for editing. For anyone who was previously using `nix-build` and `nix-shell`, they'll now have to `nix-build ./nix` and `nix-shell ./nix/shell.nix`. Co-authored-by: Eliza Weisman <[email protected]>
- Loading branch information
1 parent
e020d66
commit f12429b
Showing
9 changed files
with
152 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
use nix; | ||
if command -v use_flake 2>&1 >/dev/null; then | ||
use flake; | ||
else | ||
use nix ./nix/shell.nix; | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
target | ||
/.direnv | ||
**/target | ||
**/result | ||
**/*.swp |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
description = "The Tokio console: a debugger for async Rust."; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs/release-21.11"; | ||
flake-utils = { | ||
url = "github:numtide/flake-utils"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let | ||
pkgs = import nixpkgs { inherit system; }; | ||
tokio-console = import ./nix { inherit pkgs; }; | ||
devShell = import ./nix/shell.nix { inherit pkgs; }; | ||
in | ||
{ | ||
inherit devShell; | ||
packages = { inherit tokio-console; }; | ||
defaultPackage = tokio-console; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ pkgs ? import <nixpkgs> { } }: | ||
pkgs.callPackage ./tokio-console.nix { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
scope@{ pkgs ? import <nixpkgs> { } }: | ||
with pkgs; | ||
let | ||
tokio-console = import ./default.nix { inherit pkgs; }; | ||
|
||
env = buildEnv { | ||
name = "console-env"; | ||
paths = [ ] | ||
++ lib.optional stdenv.isDarwin libiconv | ||
++ tokio-console.buildInputs | ||
++ tokio-console.nativeBuildInputs; | ||
}; | ||
in | ||
mkShell { | ||
buildInputs = [ env ]; | ||
|
||
CARGO_TERM_COLOR = "always"; | ||
RUST_BACKTRACE = "full"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ lib | ||
, protobuf | ||
, rustPlatform | ||
, nix-gitignore | ||
}: | ||
let | ||
inherit (nix-gitignore) gitignoreFilterPure withGitignoreFile; | ||
# Workaround for the builtins.filterSource issue mentioned in | ||
# https://nixos.org/manual/nix/unstable/expressions/builtins.html | ||
# Since this might be built from a flake, the source path may be a store path, | ||
# so we need to provide our own version of gitignoreSource that avoids | ||
# builtins.filterSource in favor of builtins.path. | ||
gitignoreSource = patterns: path: | ||
builtins.path { | ||
filter = gitignoreFilterPure (_: _: true) (withGitignoreFile patterns path) path; | ||
path = path; | ||
name = "src"; | ||
}; | ||
|
||
# Ignore some extra things that don't factor into the main build to help with | ||
# caching. | ||
extraIgnores = '' | ||
/.envrc | ||
/*.nix | ||
/flake.* | ||
/netlify.toml | ||
/.github | ||
/assets | ||
/*.md | ||
/.gitignore | ||
/LICENSE | ||
''; | ||
|
||
src = gitignoreSource extraIgnores ../.; | ||
|
||
cargoTOML = lib.importTOML "${src}/console/Cargo.toml"; | ||
in | ||
rustPlatform.buildRustPackage rec { | ||
pname = cargoTOML.package.name; | ||
version = cargoTOML.package.version; | ||
|
||
nativeBuildInputs = [ | ||
protobuf | ||
]; | ||
|
||
inherit src; | ||
|
||
cargoLock = { | ||
lockFile = "${src}/Cargo.lock"; | ||
}; | ||
|
||
meta = { | ||
inherit (cargoTOML.package) description homepage license; | ||
maintainers = cargoTOML.package.authors; | ||
}; | ||
} |