From 0b343cd45fe4efc1493cf21808c2c2cd7ee50fc3 Mon Sep 17 00:00:00 2001 From: Anthony Griffon Date: Tue, 27 Feb 2024 18:04:28 +0100 Subject: [PATCH 1/2] feat: add flake --- .envrc | 1 + .gitignore | 57 ++++++++++++++++ app/roster/src/main.rs | 1 + flake.lock | 143 +++++++++++++++++++++++++++++++++++++++++ flake.nix | 100 ++++++++++++++++++++++++++++ 5 files changed, 302 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 81369db..edbf4ec 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/app/roster/src/main.rs b/app/roster/src/main.rs index ee1901a..5fea4d9 100644 --- a/app/roster/src/main.rs +++ b/app/roster/src/main.rs @@ -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() diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1977f29 --- /dev/null +++ b/flake.lock @@ -0,0 +1,143 @@ +{ + "nodes": { + "crane": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1708794349, + "narHash": "sha256-jX+B1VGHT0ruHHL5RwS8L21R6miBn4B6s9iVyUJsJJY=", + "owner": "ipetkov", + "repo": "crane", + "rev": "2c94ff9a6fbeb9f3ea0107f28688edbe9c81deaa", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1706830856, + "narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1708976803, + "narHash": "sha256-yvRygcySjjSvj5JTaCdo7lPqJ/2mBV2XQ94Oaq/14qw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "548a86b335d7ecd8b57ec617781f5e652ab0c38e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1706550542, + "narHash": "sha256-UcsnCG6wx++23yeER4Hg18CXWbgNpqNXcHIo5/1Y+hc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "97b17f32362e475016f942bbdfda4a4a72a8a652", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "flake-parts": "flake-parts", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1708999822, + "narHash": "sha256-X55GxqI3oDEfqy38Pt7xyypYNly4bkd/RajFE+FGn+A=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "1a618c62479a6896ac497aaa0d969c6bd8e24911", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "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" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..20f26a2 --- /dev/null +++ b/flake.nix @@ -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 " " ["cargo-instruments@0.4.8" "cargo-about@0.6.1"]; + 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)]; + }; + }; + }; + }; +} From 1e8b90d22f2d2085cd628377692bdb5e5ea27ca5 Mon Sep 17 00:00:00 2001 From: Anthony Griffon Date: Tue, 27 Feb 2024 18:44:08 +0100 Subject: [PATCH 2/2] misc: enable renovate for nix --- renovate.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/renovate.json b/renovate.json index 39a2b6e..911d7d0 100644 --- a/renovate.json +++ b/renovate.json @@ -2,5 +2,8 @@ "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": [ "config:base" - ] + ], + "nix": { + "enabled": true + } }