From 4ff4c0790636d88d20dce0ee70912e806444f28a Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Thu, 8 Apr 2021 21:27:32 -0400 Subject: [PATCH] nix autoformat etc --- .vscode/extensions.json | 3 ++- .vscode/settings.json | 3 ++- default.nix | 25 ++++++++++--------- flake.nix | 55 ++++++++++++++++++++++------------------- 4 files changed, 47 insertions(+), 39 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 4a2528f..42ebd62 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,6 @@ { "recommendations": [ - "matklad.rust-analyzer" + "matklad.rust-analyzer", + "jnoortheen.nix-ide" ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 12b229e..72a39e2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix" + "nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix", + "editor.formatOnSave": true } \ No newline at end of file diff --git a/default.nix b/default.nix index dfb939d..873ece4 100644 --- a/default.nix +++ b/default.nix @@ -1,12 +1,13 @@ -# This file exists for legacy Nix installs (nix-build & nix-env) -# https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix -# You generally do *not* have to modify this ever. -(import ( - let - lock = builtins.fromJSON (builtins.readFile ./flake.lock); - in fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; - sha256 = lock.nodes.flake-compat.locked.narHash; } -) { - src = ./.; -}).defaultNix \ No newline at end of file +(import + ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { + src = ./.; + }).defaultNix diff --git a/flake.nix b/flake.nix index d7774de..b229835 100644 --- a/flake.nix +++ b/flake.nix @@ -19,15 +19,16 @@ }; outputs = { self, nixpkgs, utils, rust-overlay, crate2nix, ... }: - let + let name = "bouncy"; - in utils.lib.eachDefaultSystem + in + utils.lib.eachDefaultSystem (system: - let + let # Imports - pkgs = import nixpkgs { - inherit system; - overlays = [ + pkgs = import nixpkgs { + inherit system; + overlays = [ rust-overlay.overlay (self: super: { # Because rust-overlay bundles multiple rust packages into one @@ -42,28 +43,31 @@ generatedCargoNix; # Create the cargo2nix project - project = pkgs.callPackage (generatedCargoNix { - inherit name; - src = ./.; - }) { - # Individual crate overrides go here - # Example: https://github.com/balsoft/simple-osd-daemons/blob/6f85144934c0c1382c7a4d3a2bbb80106776e270/flake.nix#L28-L50 - defaultCrateOverrides = pkgs.defaultCrateOverrides // { - # The himalaya crate itself is overriden here. Typically we - # configure non-Rust dependencies (see below) here. - ${name} = oldAttrs: { - inherit buildInputs nativeBuildInputs; - } // buildEnvVars; + project = pkgs.callPackage + (generatedCargoNix { + inherit name; + src = ./.; + }) + { + # Individual crate overrides go here + # Example: https://github.com/balsoft/simple-osd-daemons/blob/6f85144934c0c1382c7a4d3a2bbb80106776e270/flake.nix#L28-L50 + defaultCrateOverrides = pkgs.defaultCrateOverrides // { + # The himalaya crate itself is overriden here. Typically we + # configure non-Rust dependencies (see below) here. + ${name} = oldAttrs: { + inherit buildInputs nativeBuildInputs; + } // buildEnvVars; + }; }; - }; # Configuration for the non-Rust dependencies buildInputs = with pkgs; [ openssl.dev ]; - nativeBuildInputs = with pkgs; [ rustc cargo pkgconfig ]; + nativeBuildInputs = with pkgs; [ rustc cargo pkgconfig nixpkgs-fmt ]; buildEnvVars = { PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig"; }; - in rec { + in + rec { packages.${name} = project.rootCrate.build; # `nix build` @@ -77,10 +81,11 @@ defaultApp = apps.${name}; # `nix develop` - devShell = pkgs.mkShell { - inherit buildInputs nativeBuildInputs; - RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; - } // buildEnvVars; + devShell = pkgs.mkShell + { + inherit buildInputs nativeBuildInputs; + RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; + } // buildEnvVars; } ); }