Skip to content

Commit

Permalink
Merge pull request #33 from Miaxos/nix-flake
Browse files Browse the repository at this point in the history
Nix flake
  • Loading branch information
Miaxos authored Feb 28, 2024
2 parents 19b6409 + 1e8b90d commit ee2e432
Show file tree
Hide file tree
Showing 6 changed files with 306 additions and 1 deletion.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
57 changes: 57 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

target/
private/
deployment/

# dependencies
node_modules
.pnp
.pnp.js

# testing
coverage

# build output
.next/
out/
/build
dist
target

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# turbo
.turbo

# ide
.idea
.vscode
.now

# direnv
.envrc
.direnv/

# Jujutsu
.jj/

# Direnv
.envrc
.env
.direnv/

# Nix
/result
1 change: 1 addition & 0 deletions app/roster/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ fn main() -> anyhow::Result<()> {
// Initialize Roster WAN clusturing

// Initialize Roster LAN clusturing
//

// Initialize server with Redis Protocol to accept connections;
let server = ServerConfigBuilder::default()
Expand Down
143 changes: 143 additions & 0 deletions flake.lock

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

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

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;
};

aarch64DarwinExternalCargoCrates = concatStringsSep " " ["[email protected]" "[email protected]"];
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;

defaultShellConf = {
buildInputs = [
toolchain
];

nativeBuildInputs = with pkgs;
[
# Testing
cargo-insta
cargo-nextest

# Benchmark tool to send multiple requests
hey

# Rust
mold
]
++ optional (system == systems.aarch64-darwin) [
# cargo-binstall
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) [
cargo-about
];

shellHook = ''
# project_root="$(git rev-parse --show-toplevel 2>/dev/null || jj workspace root 2>/dev/null)"
# export CARGO_INSTALL_ROOT="./.cargo";
# if [[ "${system}" == "aarch64-darwin" ]]; then
# cargo binstall --no-confirm --no-symlinks --quiet ${aarch64DarwinExternalCargoCrates}
# fi
'';
};
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)];
};
};
};
};
}
5 changes: 4 additions & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
]
],
"nix": {
"enabled": true
}
}

0 comments on commit ee2e432

Please sign in to comment.